Fix SQLite migration warning
Eliminate `Skipping unsupported ALTER for creation of implicit
constraint` warning when upgrading SQLite database with batch
operation.
@@ -17,9 +17,21 @@ import sqlalchemy as sa
def upgrade():
- op.add_column('products', sa.Column('is_review_status_change_disabled',
+ ctx = op.get_context()
+ dialect = ctx.dialect.name
+
+ new_col = sa.Column('is_review_status_change_disabled',
sa.Boolean(),
- server_default=sa.sql.false()))
+ server_default=sa.sql.false())
+
+ # To eliminate 'Skipping unsupported ALTER for creation of implicit
+ # constraint' warning we use batch operation to create the new column in
+ # case of SQLite.
+ if dialect == 'sqlite':
+ with op.batch_alter_table('products') as batch_op:
+ batch_op.add_column(new_col)
+ else:
+ op.add_column('products', new_col)
def downgrade():
