Skip to content

SQLAlchemy 2.0 models declared with DeclarativeBase migration not created (on sqlite) by flask-migrate #509

Discussion options

You must be logged in to vote

Ok! I understand now.
Thx
A

For flask-newbie like me.

Models must be subclassed from the Model class of Flask-SQLAlchemy library not from the (generic) SQLAlchemy DeclarativeBase class.
In my case db is the Flask-SQLAlchemy object and I have corrected in:

class Layout(db.Model):......
class Routes(db.Model):......
class Nodes(db.Model):......

If you need to customize, you have to subclass Model and instanciate SQLAlchemy with the model_class parameter like this:

class MyBase(Model):......
db = SQLAlchemy(model_class=MyBase):.....
'class Layout(db.Model)'

as documented in the advanced customization.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@alessandromannini
Comment options

@miguelgrinberg
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by alessandromannini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants