"""Programmatisches Anwenden der Alembic-Migrationen. Wird beim App-Start aufgerufen, damit ein frisch geklontes/gestartetes System sofort das aktuelle Schema hat – ohne dass man ``alembic`` von Hand ausführen muss. Das Install-/Update-Skript ruft ``alembic upgrade head`` zusätzlich auf; das ist idempotent. """ from pathlib import Path from alembic import command from alembic.config import Config # backend/ (eine Ebene über app/) BACKEND_DIR = Path(__file__).resolve().parent.parent def _config() -> Config: cfg = Config(str(BACKEND_DIR / "alembic.ini")) cfg.set_main_option("script_location", str(BACKEND_DIR / "migrations")) return cfg def upgrade_to_head() -> None: command.upgrade(_config(), "head")