I'm working on a Flask app using Flask-Migrate (and therefore Alembic) to manage changes to the DB. I've run into an issue early on where changing some not-nullable boolean columns has triggered an error in the underlying DB.
I am removing one boolean column, and renaming another (which amounts to two deletes and an add).
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('user', sa.Column('is_enabled', sa.Boolean(), nullable=False))
op.drop_column('user', 'is_disabled')
op.drop_column('user', 'is_deleted')
# ### end Alembic commands ###
Since there is already data in the database, the add needs a default value to use for existing rows. However, the SQLAlchemy folks have already passed on adding (portable) support for server_default
in Boolean columns.
Given these conditions, is there any way to do this migration and maintain database portability, or do I need to limit the code to one database, and start coding server_default
values based on the underlying DB driver for boolean columns?