feat(container): harden v0.1.1 publication

This commit is contained in:
2026-08-15 15:14:36 +09:00
parent fd080496b3
commit 9c8baac70b
14 changed files with 287 additions and 72 deletions
+12 -7
View File
@@ -7,6 +7,7 @@ from importlib import resources
import psycopg
from alembic import command
from alembic.config import Config
from alembic.script import ScriptDirectory
from app.core.config import Settings
@@ -61,15 +62,19 @@ def bootstrap_or_upgrade_to_head(settings: Settings) -> str:
def current_revision(settings: Settings) -> str | None:
output: list[str] = []
"""Read the database revision without applying or stamping migrations."""
with _connect(settings) as conn, conn.cursor() as cur:
cur.execute("SELECT version_num FROM alembic_version")
row = cur.fetchone()
return str(row[0]) if row else None
def capture(message: str, *_args, **_kwargs) -> None:
if message.strip():
output.append(message.strip())
config = get_alembic_config(settings)
command.current(config, verbose=False)
return output[-1] if output else None
def head_revision(settings: Settings) -> str:
"""Return the single packaged Alembic head without touching the database."""
heads = ScriptDirectory.from_config(get_alembic_config(settings)).get_heads()
if len(heads) != 1:
raise RuntimeError(f"expected one Alembic head, found {len(heads)}")
return heads[0]
def _connect(settings: Settings) -> psycopg.Connection: