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
+15 -2
View File
@@ -5,9 +5,13 @@ from __future__ import annotations
import typer
from app.cli.core.utils import print_json
from app.db.migrations import bootstrap_or_upgrade_to_head
from app.db.migrations import (
bootstrap_or_upgrade_to_head,
current_revision,
head_revision,
)
from app.repositories.factory import build_portfolio_db_config
from app.repositories.postgres import PostgresPortfolioRepository, create_database_if_missing, database_exists
from app.repositories.postgres import create_database_if_missing, database_exists
def initialize_database(*, settings, maintenance_db: str = "postgres") -> dict[str, object]:
@@ -90,6 +94,15 @@ def register_health_commands(app: typer.Typer) -> None:
}
if hasattr(repository, "ping"):
repository.ping()
if app_context.settings.db_enabled:
database_revision = current_revision(app_context.settings)
expected_revision = head_revision(app_context.settings)
health["database_revision"] = database_revision
health["expected_revision"] = expected_revision
if database_revision != expected_revision:
raise RuntimeError(
f"database revision {database_revision!r} is not packaged head {expected_revision!r}"
)
except Exception as exc:
app_context.console.print(f"health-check failed: {exc}")
raise typer.Exit(code=1) from exc