Automatically add default value when using flask db migrate
with default
column instead of server_default
#1591
lulunac27a
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
Hii, That's working as expected. Use server_default in the definition if you want that to be rendered by alembic |
Beta Was this translation helpful? Give feedback.
4 replies
-
To enforce a database-level default, explicitly use server_default in your model: num = db.Column(db.Float, server_default='0', nullable=False) This will generate the expected |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I run
flask db migrate
with a column with nullable field and a default value fromnum = db.Column(db.Float, default=0, nullable=False)
withdefault
keyboard parameter from Flask-SQLAlchemy, it returnssa.Column('num', sa.Float(), nullable=False)
, instead ofsa.Column('num', sa.Float(), nullable=False, server_default='0')
.Beta Was this translation helpful? Give feedback.
All reactions