Repository navigation
feat: a 5.x snapshot with exclusion constraints moves over with no operations - #94
Merged
Merged
Conversation
…erations The kernel gets LegacyDeclarationReader<TDeclaration>: a reader for an earlier package's annotation, asked for the source side of a diff and refused in the target. The PostgreSQL package reads 5.x's CustomExclusion:Constraints into PgExclusion, and refuses by name what PgExclusion cannot say. The fixture under test/Fixtures/ComplexIndexes5x is scaffolded by the published EFCore.ComplexIndexes.PostgreSQL 5.6.0 on net10.0 and checked in as scaffolded. Its snapshot diffs to nothing against the same model declared with SchemaKit, and the database its migration builds has the catalog EnsureCreated() builds, on PostgreSQL 16 and 18. Closes #92 Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 12, 2026
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 #92
Problem
A project that comes from
EFCore.ComplexIndexes5.x has its exclusion constraints in the snapshot as 5.x stored them, in the annotationCustomExclusion:Constraints. The planner read only SchemaKit's own annotations. The firstmigrations addafter the move therefore saw no constraint in the snapshot and wrote anADD CONSTRAINTfor each one the model declares, which fails at apply (42P07) on a database that already has them.Change
LegacyDeclarationReader<TDeclaration>reads an earlier package's annotation into declarations, andAddLegacyDeclarationReader<TReader>()registers it. Both carrySK9001like the rest of the contract. The planner asks the readers for the source side of a diff and resolves what they return like any declaration. In the model a migration leads to, the annotation is refused.CustomExclusion:ConstraintsintoPgExclusion(Legacy/Internal/ComplexIndexes5xExclusionReader). What 5.x could store andPgExclusioncannot say is refused by name, with the way off it: a constraint of equality elements only, an access method other than GiST and one-element SP-GiST, a constraint on the root of a TPC hierarchy, and any property 5.x never wrote.test/Fixtures/ComplexIndexes5x/generate.shbuilds anet10.0consumer ofEFCore.ComplexIndexes.PostgreSQL5.6.0 from nuget.org outside the repository and scaffolds its first migration. The snapshot and the migration are checked in as scaffolded; the tests compile them as they are. The model holds every form 5.x could store: the two-argument overload with its default name, a lambda filter, a string filter with a placeholder, explicit names, both deferrals, a verbatim expression, a path through a complex type, a table in a schema with mapped column names, and SP-GiST.Tests
Locally: 468 kernel tests, 103 PostgreSQL tests offline, 38 on a live server, on PostgreSQL 16.15 and 18.6.
HasDifferencesis false.EnsureCreated()builds for the SchemaKit model, bypg_get_constraintdef. A constraint 5.x built still refuses an overlap (23P01).RENAME CONSTRAINT, another condition a drop and an add, and both apply to the database 5.x built. Against a model that declares nothing, all five constraints are dropped under the names 5.x gave them.Guards shown to fail. 26 defects were seeded one at a time in a scratch copy, and each failed the test meant for it: the planner asking no reader, the target not refused, each of the reader's rules (TPC, the method's case, SP-GiST taking the first of several parts, both deferral mappings, an unknown property passed over, the filter or the name left out, the parts reversed, an expression read as a column), the registration removed from the package, the mark removed from the new method. One is worth naming: with SchemaKit's default name prefix changed, the handover test still passes offline, since both sides go through one resolver. The drop statements of the undeclared model and the catalog comparison on the live server are what fail.
Decisions in this PR that are not confirmed
Legacynamespace". 5.x's descriptor quotes every name and SchemaKit writes a name as the provider does, so the two would never compare equal as text. The reader instead produces thePgExclusionthat declares the same object, and the kernel resolves it. The fixture and the catalog comparison are what say the two agree; the plan carries a dated note.SK9001), so another package can read its own predecessor. It could be internal withInternalsVisibleTo, which the PostgreSQL package deliberately does not have.PgExclusionthat can say them.Not in this PR
🤖 Generated with Claude Code