fix: Use env variable to get alembic config file in exporter (#3882)

Signed-off-by: Litchi Pi <litchi.pi@proton.me>
This commit is contained in:
Litchi Pi 2024-07-12 14:18:06 +02:00 committed by GitHub
parent d0f8b5773d
commit 3b81d3b18a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import datetime import datetime
import os
import uuid import uuid
from os import path from os import path
from pathlib import Path from pathlib import Path
@ -151,7 +152,12 @@ class AlchemyExporter(BaseService):
alembic_data = db_dump["alembic_version"] alembic_data = db_dump["alembic_version"]
alembic_version = alembic_data[0]["version_num"] alembic_version = alembic_data[0]["version_num"]
alembic_cfg = Config(str(PROJECT_DIR / "alembic.ini")) alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FILE", default=str(PROJECT_DIR / "alembic.ini"))
if not path.isfile(alembic_cfg_path):
raise Exception("Provided alembic config path doesn't exist")
alembic_cfg = Config(alembic_cfg_path)
# alembic's file resolver wants to use the "mealie" subdirectory when called from within the server package # alembic's file resolver wants to use the "mealie" subdirectory when called from within the server package
# Just override this to use the correct migrations path # Just override this to use the correct migrations path
alembic_cfg.set_main_option("script_location", path.join(PROJECT_DIR, "alembic")) alembic_cfg.set_main_option("script_location", path.join(PROJECT_DIR, "alembic"))