fix: Enhance Alembic configuration by setting script location and database URL validation in migration process
All checks were successful
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Successful in 1m17s
All checks were successful
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Successful in 1m17s
This commit is contained in:
parent
26e06ddeaa
commit
32841ea727
@ -220,10 +220,17 @@ async def run_migrations():
|
||||
logger.info("Running database migrations...")
|
||||
# Get the path to the alembic.ini file
|
||||
alembic_ini_path = os.path.join(os.path.dirname(__file__), '..', 'alembic.ini')
|
||||
|
||||
# Create Alembic configuration
|
||||
alembic_cfg = Config(alembic_ini_path)
|
||||
|
||||
# Set the script_location to the absolute path
|
||||
script_location = os.path.join(os.path.dirname(__file__), '..', 'alembic')
|
||||
alembic_cfg.set_main_option('script_location', script_location)
|
||||
|
||||
# Set the sqlalchemy.url
|
||||
if not settings.DATABASE_URL:
|
||||
raise ValueError("DATABASE_URL is not configured in settings.")
|
||||
alembic_cfg.set_main_option('sqlalchemy.url', settings.DATABASE_URL)
|
||||
|
||||
# Run the migration
|
||||
command.upgrade(alembic_cfg, "head")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user