Import velofy.config as pkg_config everywhere

This commit is contained in:
Alexander Hess 2026-11-30 20:19:35 +01:00
commit cf2534f41e
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -6,7 +6,7 @@ from logging import config as log_config
import sqlalchemy as sa
from alembic import context
from velofy import config as velofy_config
from velofy import config as pkg_config
from velofy import db
@ -24,7 +24,7 @@ def include_object(obj, _name, type_, _reflected, _compare_to):
if (
type_ in {"table", "column"}
and hasattr(obj, "schema") # => fix for rare edge case
and obj.schema != velofy_config.CLEAN_SCHEMA
and obj.schema != pkg_config.CLEAN_SCHEMA
):
return False
@ -32,17 +32,17 @@ def include_object(obj, _name, type_, _reflected, _compare_to):
# Without a `pool`, the `connection` really closes after the migrations
engine = sa.create_engine(velofy_config.DATABASE_URI, poolclass=sa.pool.NullPool)
engine = sa.create_engine(pkg_config.DATABASE_URI, poolclass=sa.pool.NullPool)
test_schema = f"_{velofy_config.CLEAN_SCHEMA}" if os.getenv("TESTING") else ""
test_schema = f"_{pkg_config.CLEAN_SCHEMA}" if os.getenv("TESTING") else ""
with engine.connect() as connection:
context.configure(
connection=connection,
include_object=include_object,
target_metadata=db.Base.metadata,
version_table=f"{velofy_config.ALEMBIC_TABLE}{test_schema}",
version_table_schema=velofy_config.ALEMBIC_TABLE_SCHEMA,
version_table=f"{pkg_config.ALEMBIC_TABLE}{test_schema}",
version_table_schema=pkg_config.ALEMBIC_TABLE_SCHEMA,
)
with context.begin_transaction():