[+] improve alembic

This commit is contained in:
Siarhei Siniak 2025-07-04 10:41:27 +03:00
parent d9f5c20557
commit f8eb591b05

@ -18,7 +18,10 @@ if config.config_file_name is not None:
# for 'autogenerate' support # for 'autogenerate' support
# from myapp import mymodel # from myapp import mymodel
# target_metadata = mymodel.Base.metadata # target_metadata = mymodel.Base.metadata
target_metadata = None # target_metadata = None
from online.fxreader.pr34.test_task_2025_06_30_v1.tickers.settings import Settings
from online.fxreader.pr34.test_task_2025_06_30_v1.tickers.models import Base
target_metadata = Base.metadata
# other values from the config, defined by the needs of env.py, # other values from the config, defined by the needs of env.py,
# can be acquired: # can be acquired:
@ -27,7 +30,6 @@ target_metadata = None
def run_migrations_offline() -> None: def run_migrations_offline() -> None:
from online.fxreader.pr34.test_task_2025_06_30_v1.tickers.settings import Settings
"""Run migrations in 'offline' mode. """Run migrations in 'offline' mode.
@ -61,10 +63,16 @@ def run_migrations_online() -> None:
and associate a connection with the context. and associate a connection with the context.
""" """
url = Settings.singleton().db_url
connectable = engine_from_config( connectable = engine_from_config(
config.get_section(config.config_ini_section, {}), config.get_section(
config.config_ini_section, {}
),
prefix="sqlalchemy.", prefix="sqlalchemy.",
poolclass=pool.NullPool, poolclass=pool.NullPool,
url=url,
) )
with connectable.connect() as connection: with connectable.connect() as connection: