Co-authored-by: Arnaud Dartois <admin@tordais.cc>
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:
- First boot applies migrations and
/healthzbecomes healthy. - A second startup against the migrated database remains healthy.
- A synthetic database role with access to the database/schema but no
SELECTonpublic.__EFMigrationsHistorycauses migration startup to exhaust all five attempts, emit the final Critical failure, and exit nonzero without logging migration success. - Granting that role
SELECTand restarting Central allows migration startup and health checks to succeed. - 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.