From d64e2f42f563d01c62f0cc000044f7b8f1ae778d Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 17 Oct 2023 11:56:38 +0300 Subject: [PATCH] fix: explicitly specify the DB name when migrating (#2039) --- lnbits/commands.py | 2 +- lnbits/core/helpers.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lnbits/commands.py b/lnbits/commands.py index 44e55681b..548da5d48 100644 --- a/lnbits/commands.py +++ b/lnbits/commands.py @@ -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) diff --git a/lnbits/core/helpers.py b/lnbits/core/helpers.py index feb2d4dac..68ad4f34a 100644 --- a/lnbits/core/helpers.py +++ b/lnbits/core/helpers.py @@ -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: