Repository navigation
SQL Server: check the clustered slot and key names on the whole target table - #105
Merged
Merged
Conversation
This was referenced Oct 20, 2026
CaffeinatedCoder
changed the base branch from
fix/91-guard-in-constructors
to
main
October 20, 2026 06:08
CaffeinatedCoder
force-pushed
the
fix/90-sqlserver-clustered-and-key-names
branch
from
October 20, 2026 06:09
a678e57 to
2a0060b
Compare
…arget table (#90) Three gaps in the SQL Server satellite's validation, each failing only at apply or refusing a valid migration: - A second clustered complex index added in a later migration scaffolded CREATE CLUSTERED INDEX [cx_two] and failed at apply: ValidateCreatedIndexes counted clustered indexes among one migration's creates only. - The clustered-slot check ran from TransformIndexAnnotation, so on the source (snapshot) model too: a snapshot holding a clustered key plus a clustered complex index refused even the migration that fixes it. - A complex index named like its table's key (PK_things) scaffolded and failed at apply: the core's name check covers native indexes, not keys. The core differ gains an internal hook, ValidateTargetIndexes, called with every complex index of the target model. The SQL Server differ overrides it to count clustered declarations per table (complex indexes, the primary key, clustered unique constraints and native indexes) and to compare complex index names with the table's primary key and unique constraints, ignoring case as the default collation does. The ValidateCreatedIndexes override and the check in TransformIndexAnnotation are gone. Verified: six new SqlServerDifferTests; with the source change reverted, the later-migration, snapshot, primary-key name, unique-constraint name and clustered-unique-constraint tests fail (and the native-index one on its message). Full unit suite green; pack shows no ApiCompat break. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CaffeinatedCoder
force-pushed
the
fix/90-sqlserver-clustered-and-key-names
branch
from
October 20, 2026 06:26
2a0060b to
dd59a41
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.
Closes #90
Was stacked on #103 (#91), now merged; rebased onto
main.Problem
Three gaps in the SQL Server satellite's validation:
cx_one(clustered) already applied, a migration addingcx_twowith.IsClustered()scaffoldedCREATE CLUSTERED INDEX [cx_two] ON [things] (...)and failed at apply.ValidateCreatedIndexescounted clustered indexes among one migration's creates only, whiledocs/sqlserver.mdpromised a rejection atmigrations add.TransformIndexAnnotation, which runs for both sides of the diff, so a snapshot holding a clustered key plus a clustered complex index (reachable only from snapshots scaffolded before 5.0.2) refused even the migration that fixes it. Every other check validates the target only.indexName: "PK_things"scaffoldedCREATE INDEX [PK_things] ON [things]and failed at apply: the core's collision check covers nativeHasIndexdeclarations, not keys.Change
CustomMigrationsModelDiffer: a new internal hook,ValidateTargetIndexes(IRelationalModel target, IReadOnlyCollection<IndexDescriptor>), called once with every complex index the target model declares, after the existing target-only checks. It is internal becauseIndexDescriptoris; the satellites see it throughInternalsVisibleTo, so the public surface is unchanged.SqlServerComplexIndexMigrationsModelDifferoverrides it, per target table:IsClustered(false)), a unique constraint declared clustered (new), or a clustered native index.ValidateCreatedIndexesoverride and the clustered check inTransformIndexAnnotationare removed. Pack shows no ApiCompat break.docs/sqlserver.md: the deliberate-rejections list covers both.### Fixedline in the root and SQL Server changelogs.Tests
SqlServerDifferTestsgains eight tests: a second clustered index in a later migration (rejected), the clustered slot moving between two complex indexes in one migration (allowed), a source snapshot holding a conflict (diffable), a clustered native index, a clustered unique constraint, a name equal to the primary key's in a different case, a name equal to a unique constraint's (all rejected), and another table's key name (allowed).Verified by reverting
src/: six fail. Five are the fixes (later migration, snapshot, primary-key name, unique-constraint name, clustered unique constraint), and the sixth is the native-index test, failing on its message only. That branch existed before with no test, one of the seeds #96 lists; this is its first. Full unit suite: 403 passed.The SQL Server lane (#100) applies the clustered cases to a live server.
🤖 Generated with Claude Code