fix: Update Alembic configuration to use absolute paths for ini file and script location in migration process
All checks were successful
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Successful in 1m15s

This commit is contained in:
mohamad 2025-06-01 17:13:09 +02:00
parent 32841ea727
commit 43e2d88ffe

View File

@ -218,12 +218,13 @@ async def run_migrations():
"""Run database migrations.""" """Run database migrations."""
try: try:
logger.info("Running database migrations...") logger.info("Running database migrations...")
# Get the path to the alembic.ini file # Get the absolute path to the alembic.ini file
alembic_ini_path = os.path.join(os.path.dirname(__file__), '..', 'alembic.ini') base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
alembic_ini_path = os.path.join(base_path, 'alembic.ini')
alembic_cfg = Config(alembic_ini_path) alembic_cfg = Config(alembic_ini_path)
# Set the script_location to the absolute path # Set the script_location to the absolute path
script_location = os.path.join(os.path.dirname(__file__), '..', 'alembic') script_location = os.path.join(base_path, 'alembic')
alembic_cfg.set_main_option('script_location', script_location) alembic_cfg.set_main_option('script_location', script_location)
# Set the sqlalchemy.url # Set the sqlalchemy.url