Files
Heimdall/skills/database-migration-startup/SKILL.md
T
arnaud.dartois ec80e31e33
Heimdall Gitea / Detect CI scope (push) Successful in 4s
Heimdall Gitea / Build and tests (push) Skipped
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 2s
test(storage): document migration startup acceptance for #300 (#332)
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-12 11:12:37 +01:00

2.1 KiB

name, description
name description
database-migration-startup Diagnose and validate Heimdall Central's EF Core PostgreSQL migration startup, including first boot, restart, retry exhaustion, and recovery.

Database migration startup

src/Heimdall.Web/Program.cs calls Program.ApplyMigrationsAsync before configuring recurring Hangfire jobs and seeding identity data. The method uses one AppDbContext, retries a failed Database.MigrateAsync five times with exponential delays, logs the terminal exception at Critical, then rethrows so Central cannot become ready with a failed migration.

For startup incidents, correlate the EF CommandError with the following Program retry/final logs. A failed EF command log alone does not prove that startup failed: a later retry may have succeeded. Preserve the provider exception and SQLSTATE when available, but never record a connection string, password, user identifier, or database row. Do not suppress EF command errors to hide a symptom.

Acceptance

Run bash skills/database-migration-startup/acceptance.sh from a clean checkout. The recipe builds Central from this source with one unique local image tag, uses a fresh PostgreSQL database and generated credentials, and checks:

  1. First boot applies migrations and /healthz becomes healthy.
  2. A second startup against the migrated database remains healthy.
  3. A synthetic database role with access to the database/schema but no SELECT on public.__EFMigrationsHistory causes migration startup to exhaust all five attempts, emit the final Critical failure, and exit nonzero without logging migration success.
  4. Granting that role SELECT and restarting Central allows migration startup and health checks to succeed.
  5. The EXIT trap removes only this Compose project and its exact image tag, then verifies that its containers, volumes, network, and image are absent. Shared PostgreSQL and .NET base images are retained.

This synthetic permission failure verifies fail-closed and recovery behavior; it does not establish the cause of a separate deployment's EF error. Record production evidence only when an event includes the provider exception/SQLSTATE and correlated startup outcome.