fix(persistence): two migrations were never discovered by EF — schema drifts from model on every install#727
Open
kevinheneveld wants to merge 1 commit into
Conversation
… drifts from model on every install 20251124102000_AddMoveJobSourcePath shipped without a [Migration] attribute or Designer, so EF migration discovery never saw it: every SQLite install is missing MoveJobs.SourcePath while the model maps it, and the first full-entity MoveJobs query (or insert) fails at runtime with "no such column: m.SourcePath". Restore the Designer (model as of that migration) so it is discovered and applied; EF applies it on next startup regardless of later migrations already being recorded. The same audit found a second drift: ProcessExecutionLog has been in the model and every snapshot since late 2025, but no discovered migration ever created its table — IProcessExecutionLogRepository writes fail on real databases. Add AddProcessExecutionLogs to create it. Neither drift was catchable by the test suite: migrations are hand-written and the suite runs on the EF InMemory provider, which never executes them. Add SqliteMigrationSchemaTests, which migrates a real (in-memory) SQLite database and verifies every mapped column of every entity exists — so this entire class of drift fails CI instead of production. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
87bbe5b to
3103996
Compare
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.
The bug
20251124102000_AddMoveJobSourcePath.csshipped without a[Migration]attribute or Designer file, so EF's migration discovery has never seen it. Every SQLite install is missingMoveJobs.SourcePathwhile the model maps it — verifiable on any instance:Any full-entity MoveJobs query or insert dies with
SQLite Error 1: 'no such column: m.SourcePath'— I hit it live on a new endpoint, but move-job persistence itself is affected.The fix
AddMoveJobSourcePath(attributes + model as of that migration). EF applies not-yet-recorded migrations on next startup regardless of later ones already being in history, so existing installs heal themselves on upgrade.ProcessExecutionLoghas been in the model and every snapshot since late 2025, but no discovered migration ever created its table (SELECT name FROM sqlite_master WHERE name='ProcessExecutionLogs'is empty on real installs). New migrationAddProcessExecutionLogscreates it.SqliteMigrationSchemaTestsmigrates a real (shared in-memory) SQLite database and asserts every mapped column of every entity exists in the migrated schema. Hand-written migrations + an InMemory-provider test suite is exactly the combination that let this ship silently; this test makes the whole class of drift fail CI. It found the second bug above on its first run.Heads-up
There are 16 more migration files without a
[Migration]attribute/Designer (mostlyAddXxxToApplicationSettingsand pre-org-migration files) — equally invisible to EF. The schema test passing means the current model doesn't depend on any of them (their changes were superseded or re-rooted), but they're dead code worth cleaning up separately. List available on request.Tests
Full suite passing (1017/1017), including the 2 new schema tests.
🤖 Generated with Claude Code