Browse Source

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
changes/81/761481/1
Feilong Wang 9 months ago
parent
commit
f5cf6b958c
  1. 3
      magnum/db/sqlalchemy/alembic/versions/1d045384b966_add_insecure_baymodel_attr.py
  2. 4
      releasenotes/notes/migrations-1.3.20-60e5f990422f2ca5.yaml

3
magnum/db/sqlalchemy/alembic/versions/1d045384b966_add_insecure_baymodel_attr.py

@ -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})
)

4
releasenotes/notes/migrations-1.3.20-60e5f990422f2ca5.yaml

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