Ensure migration script use correct alembic table
At the moment migration script does misbehave and will fail on attempt to migrate database from old SQLAlchemy Migrate to Alembic due to misconfigured alembic_table. Right now alembic_version table is being used by taskflow. With that it was existing before 2024.1, where Masakari has adopted alembic as well. As a result, masakari-manage db sync returns early from _migrate_legacy_database as it treats taskflow alembic DB as it's own. And when it tries to apply migrations - it fails as table already exist. masakari-manage db version also shows taskflow version instead of masakari version which is misleading. Passing correct version_table to MigrationContext fixes the issue. Change-Id: I67e04640ec76cf000aadfc5834d89da7a772a8d6
This commit is contained in:
parent
15def73bb8
commit
ca1e09dee2
@ -47,7 +47,9 @@ def _migrate_legacy_database(engine, connection, config):
|
||||
|
||||
# Likewise, if we've already migrated to alembic, we don't have anything to
|
||||
# do
|
||||
context = alembic_migration.MigrationContext.configure(connection)
|
||||
context = alembic_migration.MigrationContext.configure(
|
||||
connection,
|
||||
opts={'version_table': 'masakari_alembic_version'})
|
||||
if context.get_current_revision():
|
||||
return
|
||||
|
||||
@ -175,5 +177,8 @@ def db_version():
|
||||
"""Get database version."""
|
||||
engine = db_api.get_engine()
|
||||
with engine.connect() as connection:
|
||||
m_context = alembic_migration.MigrationContext.configure(connection)
|
||||
m_context = alembic_migration.MigrationContext.configure(
|
||||
connection,
|
||||
opts={'version_table': 'masakari_alembic_version'}
|
||||
)
|
||||
return m_context.get_current_revision()
|
||||
|
Loading…
Reference in New Issue
Block a user