Fix database migrations

The pattern of adding a column and then reading a table with it
no longer works in SQLAlchemy 1.3.20. This has been reported
upstream [1].

[1] https://github.com/sqlalchemy/sqlalchemy/issues/5669

Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b
(cherry picked from commit f5cf6b958c)
This commit is contained in:
Feilong Wang 2020-11-05 14:31:36 +13:00 committed by Bharat Kunwar
parent 205a227d31
commit 512bf5c320
2 changed files with 6 additions and 1 deletions

View File

@ -28,7 +28,8 @@ import sqlalchemy as sa # noqa: E402
def upgrade():
insecure_column = sa.Column('insecure', sa.Boolean(), default=False)
op.add_column('baymodel', insecure_column)
baymodel = sa.sql.table('baymodel', insecure_column)
baymodel = sa.sql.table('baymodel',
sa.Column('insecure', sa.Boolean(), default=False))
op.execute(
baymodel.update().values({'insecure': True})
)

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fixes database migrations with SQLAlchemy 1.3.20.