feat: monorepo migration phase 5
App checks / changes (push) Canceled after 0s
App checks / tournament (push) Canceled after 0s
App checks / shifts (push) Canceled after 0s

This commit is contained in:
jfmcarreira committed 2026-10-07 15:20:27 +01:00
1 parent d534588e27
commit 66b72d1348
28 files changed
+406 -26

No files matched your search

@@ -0,0 +1 @@
"""Low-level infrastructure shared by the independently deployed CRR apps."""
@@ -0,0 +1,18 @@
from collections.abc import Mapping
from typing import Any
from sqlalchemy import URL, create_engine
from sqlalchemy.engine import Engine, make_url
def create_sync_engine(
url: str | URL,
*,
connect_args: Mapping[str, Any] | None = None,
**engine_options: Any,
) -> Engine:
"""Construct a synchronous engine without changing connection/schema policy."""
arguments = dict(connect_args or {})
if make_url(url).get_backend_name() == "sqlite":
arguments.setdefault("check_same_thread", False)
return create_engine(url, connect_args=arguments, **engine_options)
@@ -0,0 +1,23 @@
from pathlib import Path
from alembic.config import Config
from sqlalchemy import URL
from sqlalchemy.engine import Connection
def migration_config(
ini_path: str | Path,
script_location: str | Path,
*,
database_url: str | URL | None = None,
connection: Connection | None = None,
) -> Config:
"""Prepare Alembic wiring; the caller owns migration policy and connections."""
config = Config(str(Path(ini_path).resolve()))
config.set_main_option("script_location", str(Path(script_location).resolve()).replace("%", "%%"))
if database_url is not None:
url = database_url.render_as_string(hide_password=False) if isinstance(database_url, URL) else database_url
config.set_main_option("sqlalchemy.url", url.replace("%", "%%"))
if connection is not None:
config.attributes["connection"] = connection
return config