fix: explicitly specify the DB name when migrating (#2039)

This commit is contained in:
Vlad Stan 2023-10-17 11:56:38 +03:00 committed by GitHub
parent e522a53340
commit d64e2f42f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -89,7 +89,7 @@ async def migrate_databases():
current_versions = await get_dbversions(conn)
core_version = current_versions.get("core", 0)
await run_migration(conn, core_migrations, core_version)
await run_migration(conn, core_migrations, "core", core_version)
for ext in get_valid_extensions():
current_version = current_versions.get(ext.code, 0)

View file

@ -25,12 +25,13 @@ async def migrate_extension_database(ext: Extension, current_version):
)
async with ext_db.connect() as ext_conn:
await run_migration(ext_conn, ext_migrations, current_version)
await run_migration(ext_conn, ext_migrations, ext.code, current_version)
async def run_migration(db: Connection, migrations_module: Any, current_version: int):
async def run_migration(
db: Connection, migrations_module: Any, db_name: str, current_version: int
):
matcher = re.compile(r"^m(\d\d\d)_")
db_name = migrations_module.__name__.split(".")[-2]
for key, migrate in migrations_module.__dict__.items():
match = matcher.match(key)
if match: