Introduce EF Core migrations with legacy database baseline detection#364
Merged
Wiesenwischer merged 1 commit intomainfrom Apr 14, 2026
Merged
Introduce EF Core migrations with legacy database baseline detection#364Wiesenwischer merged 1 commit intomainfrom
Wiesenwischer merged 1 commit intomainfrom
Conversation
Before this change, the schema was created via EnsureCreated(), which
only works for brand new databases. Adding new columns (like the OCI
registry fields added in v0.61) broke existing installations with
"no such column" errors at runtime.
Changes:
- Add IDesignTimeDbContextFactory for dotnet-ef tooling
- Generate InitialCreate migration representing the pre-v0.61 schema
(without OCI columns) — this is the baseline for existing installs
- Generate AddOciRegistrySource migration (ALTER TABLE ADD COLUMN)
- Add explicit column configuration for OCI properties
- Replace EnsureDatabaseCreated() with MigrateDatabase() that:
1. Detects legacy databases (tables exist but no __EFMigrationsHistory)
2. Inserts InitialCreate as baseline so existing schema is treated as
already-migrated
3. Runs Migrate() to apply any subsequent migrations
Test harness:
- CustomWebApplicationFactory now uses Migrate() instead of EnsureCreated()
so integration tests exercise the same pipeline as production
- 4 new MigrationBaselineTests covering: fresh DB, legacy DB, data
preservation, and idempotency (2 runs in sequence)
All 2870 unit tests and 402 integration tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a production outage on test-ux-dokker after v0.61:
SQLite Error 1: 'no such column: s.RegistryPassword'.Root cause: the schema was created via
EnsureCreated()which only works for fresh databases. Adding new columns (like the OCI registry fields in v0.61) broke existing installations.Changes
DesignTimeDbContextFactory) for dotnet-ef toolingStackSourceConfigurationfor all OCI propertiesMigrateDatabase()replacesEnsureDatabaseCreated()inProgram.cs, with legacy database detection:__EFMigrationsHistorydoesn't → insertInitialCreateentry as baselineMigrate()→ applies subsequent migrations (AddOciRegistrySource) against the existing schemaTest plan
MigrationBaselineTests: fresh DB, legacy DB, data preservation, idempotencyUpgrade behavior
Existing installs (like test-ux-dokker) will on next startup:
__EFMigrationsHistorydoesn't exist → insertInitialCreateas appliedAddOciRegistrySource→ adds 5 OCI columns