Repository navigation
Release 5.4.1 - #33
Merged
Merged
Conversation
Both core name checks grouped by table, schema and name, which is how
SQL Server scopes index names but not SQLite: SQLite keeps them unique
across the database and leaves configured schemas out of the DDL. Two
tables sharing an index name - two complex indexes, or a complex and a
native one - scaffolded cleanly and failed when applied ("index ...
already exists"), and IndexNameCollisionTests asserted that exact model
was fine.
IndexNameScope (Table, Schema, Database) is now a protected virtual on
the core differ, applied by ValidateUniqueIndexNames and
ValidateNoNativeIndexNameCollision. The core default is Database,
SQLite's rule and the widest scope, since the core also serves providers
without a satellite; SQL Server overrides to Table, PostgreSQL to
Schema. On PostgreSQL the core now reports plain index clashes first;
ValidateNamesAcrossKinds still covers keys, constraint-backed indexes
and an unset schema against an explicit 'public'. Only collisions with
one of this package's declarations are reported, in the target model
only.
Reverting the source fails 5 tests: the 3 SQLite rejections (no
exception thrown) and 2 PostgreSQL message assertions, which 5.4.0
answered from the cross-kind check. Dropping the SQL Server or
PostgreSQL override, or defaulting the core to Schema, each fails the
tests pinning it.
Version 5.4.1, package-validation baseline 5.4.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
5.4.0 shipped as a fix release: the 4.0 name registry went out, the generic descriptor differ, the PostgreSQL delete constraint and the small items riding along did not. The roadmap still scheduled them for 5.4.0. They move to 5.5.0 unchanged, D0 and step 0 are marked shipped, and 4.0 notes the 5.4.1 index-name scope, which the generic differ's name validation has to honour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sixth MigrationsModelDiffer constructor parameter (logger) is on efcore main, which is 12.0.0 alpha; release/11.0 keeps five. EF Core 11 needs no #if around the differ constructor, so section 1, the D7 list of build differences and the section 8 bullet now say so. The temporal annotation constants 4.1 meant to mark [Obsolete] and remove in 6.0.0 are internal, so there is no CP0002 break to schedule, and not dead: NpgsqlComplexIndexSqlGenerator reads them to render migrations scaffolded before 5.0.2. Removing them would let a fresh database built from those migrations apply a plain UNIQUE or foreign key without the period. The item is dropped from 4.1, 4.3 and the sequence, and the 6.0 migration guide keeps the keys with the overrides that read them. Co-Authored-By: Claude Opus 5.5 <[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.
One fix, to the index-name check. Both core checks compared names per table on every provider. On SQLite, index names are unique across the whole database, so a name reused on another table scaffolded cleanly and failed when the migration was applied. The 5.4.0 PR listed this under "Not in this PR".
Changes
Index names are checked in the provider's namespace (
c26c169)CREATE INDEXunder a name used on any other table:index ix_name already exists. Confirmed withsqlite33.54.0 and with the engine bundled with Microsoft.Data.Sqlite.north.aagainstsouth.b.IndexNameScope { Table, Schema, Database }and aprotected virtual IndexNameScopeonCustomMigrationsModelDiffer.ValidateUniqueIndexNamesandValidateNoNativeIndexNameCollisionboth group by it.Database: SQLite's rule, and the widest scope. The core also serves providers without a satellite. Too wide costs a rename the database did not need; too narrow approves a migration that fails when applied.Table. Reusing a name across tables stays allowed.Schema. The core now reports a clash between two plain indexes first.ValidateNamesAcrossKindsstill covers keys, the indexes behind constraints, and a table in the default schema against one namingpublic, which only it normalizes. Each collision throws once, from whichever check sees it first.Roadmap: the planned 5.4.0 features move to 5.5.0 (docs commit)
Roadmap: two corrections (
635ce57)MigrationsModelDifferconstructor parameter (logger) is on EF Core'smain, which is 12.0.0 alpha.release/11.0keeps five parameters, so EF Core 11 needs no#ifaround the differ constructor. Sections 1, 3 (D7) and 8 are corrected.[Obsolete]and remove in 6.0.0 areinternal, so there's no API break to schedule. They're also still in use:NpgsqlComplexIndexSqlGeneratorreads them to render migrations scaffolded before 5.0.2. Removing them would give a fresh database built from those migrations a plainUNIQUEor foreign key without the period, and it would apply cleanly. The item is gone from 4.1, 4.3 and the sequence, and the 6.0 migration guide now keeps the keys.Consumer-visible effects
migrations addand names both tables. The migration could never have applied.UseComplexIndexes()),Migrate()raises the same error until the rename is made.Verification
net10.0, including the PostgreSQL 18 integration tests.IndexNameCollisionTestsdiffs the same models under all three scopes.Schemafails "tables in different schemas still share one index namespace".public-schema test pass either way. They document the premise and the cross-kind check's remaining job.dotnet pack -c Releasevalidates cleanly against the 5.4.0 baseline restored from nuget.org, withIndexNameScopeas an additive API. The consumer smoke test passed in this PR's CI.migration-safety-reviewwas run over the change. It found theMigrate()effect above, which is now in the changelog.Not in this PR
🤖 Generated with Claude Code