[Blocker] Move EF Core migrations out of application startup
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 10
- Forks
- 0
- Avg merge
- 2h 52m
- Merged PRs (30d)
- 20
Description
Tier 1 — release blocker
Problem
Database.MigrateAsync() runs on every boot inside Program.cs and rethrows on failure, so a bad migration or a cold/throttled SQL connection takes the whole site down at startup. With more than one instance, migrations race against each other. This has already caused an Azure startup failure (commit 06b8f0a, "fix: add missing user display name migration").
Evidence
LearnStack/Program.cs:57-70
Proposed fix
- Generate a migration bundle in CI:
dotnet ef migrations bundle --self-contained. - Run the bundle as a deployment step against the target database, before the app is swapped in.
- Keep startup read-only — at most a
CanConnectAsynccheck wired into the health endpoint. - Optionally guard with a pending-migration check that fails the health probe rather than the process.
Acceptance criteria
- App startup performs no schema changes
- Deploy pipeline applies migrations as an explicit, observable step
- A failed migration blocks the swap instead of crashing production
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LearnStack/Program.cs:57-70 and trace the current Database.MigrateAsync() startup path. Review how the deployment pipeline can run dotnet ef migrations bundle --self-contained before swap and how the health endpoint should report connectivity or pending migrations. Done means startup performs no schema changes, deployment applies migrations observably, and failures block the swap rather than crash the app.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, database, devops
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100