From 3a97024b21102046154c567f85a39927f1ea33fc Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Sun, 4 Jun 2023 11:25:30 +0545 Subject: [PATCH] sqlalchemy url obtained from settings for alembic migrations --- src/backend/app/alembic.ini | 5 +++-- src/backend/app/migrations/env.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/app/alembic.ini b/src/backend/app/alembic.ini index ed8b40c909..7166e16918 100644 --- a/src/backend/app/alembic.ini +++ b/src/backend/app/alembic.ini @@ -60,8 +60,7 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne # are written from script.py.mako # output_encoding = utf-8 -sqlalchemy.url = postgresql+psycopg2://fmtm:fmtm@fmtm-db:5432/testingfmtm - +sqlalchemy.url = [post_write_hooks] # post_write_hooks defines scripts or Python functions that are run @@ -112,3 +111,5 @@ formatter = generic [formatter_generic] format = %(levelname)-5.5s [%(name)s] %(message)s datefmt = %H:%M:%S + + diff --git a/src/backend/app/migrations/env.py b/src/backend/app/migrations/env.py index 90d1e4240a..c3d1cf071b 100644 --- a/src/backend/app/migrations/env.py +++ b/src/backend/app/migrations/env.py @@ -2,10 +2,13 @@ from sqlalchemy import engine_from_config from sqlalchemy import pool +from config import settings +from geoalchemy2 import alembic_helpers from alembic import context config = context.config +config.set_main_option("sqlalchemy.url", settings.SQLALCHEMY_URL) if config.config_file_name is not None: fileConfig(config.config_file_name)