Repository navigation
fix: the consumer's model is told by reference, not by where it stands in a diff - #122
Merged
Merged
Conversation
…s in a diff The planner took the second argument of a diff for the model the migration leads to. EF Core's scaffolder asks for Down as GetDifferences(model, snapshot) whenever Up is not empty, and migrations remove asks HasDifferences of two snapshots. So the rules for the consumer's model ran on a snapshot: the first migration after a move from 5.x could not be scaffolded when it held a change of its own, and a 5.x migration could not be removed. The consumer's model is now the context's own design-time model, by reference. The refusal of an earlier package's annotation, the derived-type refusal and the name claims are asked of that one model on either side of a diff; every other model is only read. In the context's own model, what 5.x declared is refused with a reader for it or without one: without one it was passed over there. Closes #98 Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
Closes #98
Problem
A project moves from
EFCore.ComplexIndexes5.x, declares the same exclusion constraints withDeclarePostgres, and its firstmigrations addholds one change of its own. The command fails:The annotation is in the snapshot, not in the model.
migrations removeof the last 5.x migration fails the same way.The planner took the second argument of a diff for "the model the migration leads to". EF Core's
MigrationsScaffolderdoes not call it that way only: Down isGetDifferences(model, snapshot)whenever Up is not empty, andRemoveMigrationasksHasDifferences(lastMigration.TargetModel, snapshot). So every rule written for the consumer's model also ran on a snapshot: the refusal of an earlier package's annotation, the derived-type refusal of #82, and the name claims of #96. The handover tests diff to no operations, and then EF Core never asks for Down.Change
SchemaOperationPlanner.IsOwn). Where a model stands in a diff says nothing. The three rules are asked of that one model on either side; every other model, a snapshot or a migration's target model, is only read.LegacyFormats.DeclaredIn). Without a reader it was passed over there: the model said an index exists that no migration makes.CLAUDE.md's rules for the planner say what the code does now, with the reason a test of such a rule has to diff both ways.Tests
Locally: 517 kernel tests (4 of them on a live server), 178 of the PostgreSQL package with the live ones on PostgreSQL 16 and 18, 125 probes.
LegacyHandoverTests, on the snapshot the published 5.6.0 scaffolded: the first migration after the move with a new column isAddColumnOperationup andDropColumnOperationdown;HasDifferences(snapshot, snapshot)is false.LegacyDeclarationReaderTests: the old format in a snapshot is read where a diff ends: no operations against the model that declares the same, the object created again against one that dropped it, and two snapshots compared.SchemaOperationPlannerTests: a snapshot with a declaration on a derived type of a shared table diffs to nothing against the base-type declaration, both ways.NameClaimTests: a snapshot that holds a collision is read on either side; the context's own model is held to its names where a diff starts as well.UnreadLegacyAnnotationTests: what 5.x declared in the context's own model is refused with a reader or without, also byHasDifferences; what nothing reads is refused where a diff ends.They fail without the fix. The eight new tests and the extended one fail against
main@ 948496a.Guards shown to fail, seven defects seeded one at a time in a scratch copy, each failing at least one test: an earlier format with a reader refused in every model; what 5.x declared not refused in the own model; what nothing reads not required in a snapshot; the derived-type refusal on every model; name claims asked of whatever a diff ends with; name claims not asked of the own model where a diff starts; no model taken for the context's own (28 tests fail, which is every refusal for the consumer's model).
From a packed consumer outside the repository, with
dotnet-ef11.0.0-rc.3:migrations addrefuses a constraint named like its table's primary key withSK1001, so the scaffolder hands the differ the same model instance; a second migration with a new column scaffolds Up and Down; a third is empty;migrations removeworks twice.Not run: the tool itself over a 5.x snapshot. The tests call the entry points the scaffolder calls; the run through
dotnet efbelongs to the consumer smoke test (#34), where it is noted.Decisions in this PR that are not confirmed
Not in this PR
#101's refusal of a TPC root, which is a rule for the consumer's model and builds on this.
🤖 Generated with Claude Code