Repository navigation
fix: check index and constraint names against tables, views and sequences (#82) - #106
Merged
Merged
Conversation
…nces ValidateNamesAcrossKinds put indexes and the constraints that own one into PostgreSQL's per-schema relation namespace, but not the relations themselves. A complex index named like another table of its schema, or an exclusion or temporal constraint named like a view or sequence, scaffolded and failed at apply with 42P07. The model's tables, views and sequences now join the relation-namespace check, still reported only when the other party is this package's. Proven by seeding: dropping the tables, the views or the sequences from the check each fails its own test, and ignoring their schema fails the other-schema test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # src/EFCore.ComplexIndexes.PostgreSQL/CHANGELOG.md
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 #82
Problem
PostgreSQL keeps index names unique among all relations of a schema: indexes, tables, views and sequences.
ValidateNamesAcrossKindsand the schema-scoped index-name check only collected indexes and constraints, soscaffolded cleanly and failed at apply with 42P07
relation "codes" already exists. An exclusion or temporal constraint (each owns an index) named like a view or sequence did the same.Change
NpgsqlComplexIndexMigrationsModelDiffer.ValidateNamesAcrossKindsalso adds the target model's tables, views (IRelationalModel.Views) and sequences (GetSequences()) to the per-schema relation namespace. As before, a collision is reported only when one side is this package's. Two of EF Core's own objects are left alone, and so is a temporal foreign key named like a table, since it owns no index.NamedObject.IsIndexBackedis renamedInRelationNamespaceto match what it now holds.ValidateNamesAcrossKindssection. One### Fixedline goes into the root and PostgreSQL changelogs.Not covered: the sequence PostgreSQL creates implicitly for an identity or serial column (
bookings_Id_seq) is not in the model, so a complex index with exactly that name still fails at apply. Reaching it takes a deliberately odd name, so this PR leaves it alone; it is filed as #115.Tests
NpgsqlNameCollisionTests: a complex index named like a table, an exclusion constraint named like a view, and a temporal constraint named like a sequence are each rejected, and the message names the relation. A temporal foreign key named like a table is accepted, and so is a complex index named like a table in another schema.🤖 Generated with Claude Code