overlay/mealie/mealie_init_db.patch
2024-01-10 00:33:04 +01:00

26 lines
923 B
Diff

diff --git a/mealie/db/init_db.py b/mealie/db/init_db.py
index 90dd91a8..d19a5eac 100644
--- a/mealie/db/init_db.py
+++ b/mealie/db/init_db.py
@@ -1,3 +1,4 @@
+import os
from collections.abc import Callable
from pathlib import Path
from time import sleep
@@ -85,7 +86,14 @@ def main():
if max_retry == 0:
raise ConnectionError("Database connection failed - exiting application.")
- alembic_cfg = Config(str(PROJECT_DIR / "alembic.ini"))
+ alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FPATH")
+ if not alembic_cfg_path:
+ alembic_cfg_path = str(PROJECT_DIR / "alembic.ini")
+
+ if not os.path.isfile(alembic_cfg_path):
+ raise Exception("Provided alembic config path doesn't exist")
+
+ alembic_cfg = Config(alembic_cfg_path)
if db_is_at_head(alembic_cfg):
logger.debug("Migration not needed.")
else: