Repository navigation
Description
Found by a sweep of release/5.x @ d28c938 for base operations the differs do not account for (the shape of #182); reproduced in a scratch MigrationHarness.SqlServerDiff test. Not applied to a live server; the failure is SQL Server's Msg 5074 for a column a filtered index reads, which AlterColumnUnderIndexTests.SqlServer_alter_filter_column_under_index (#156) already pins.
Problem
On SQL Server, an unchanged complex index is moved out of the way of an ALTER COLUMN only when its filter or INCLUDE list spells the column in exactly the column's case. SQL Server reads identifiers case-insensitively under its default collation, so a filter [note] IS NULL on a column Note depends on it. The differ does not see that, emits no drop or create, and the ALTER COLUMN fails at apply (Msg 5074).
ColumnsReadBy and ColumnsNamedIn (CustomMigrationsModelDiffer.cs:651–669) collect the columns an index reads with StringComparer.Ordinal and text.Contains(name, StringComparison.Ordinal). The SQL Server checks columns.Contains(alter.Name) and filterColumns.Contains(rename.NewName) (SqlServerComplexIndexMigrationsModelDiffer.cs:67, :75) inherit that. Meanwhile ValidateIncludedColumns accepts an INCLUDE entry in another case on purpose, because it compares with IndexNameComparer, which ignores case on SQL Server. The package's own validation approves a spelling that its recreation check cannot see.
Model: members with Note (HasMaxLength(200)) and
b.HasComplexIndex(x => x.Email, isUnique: true, filter: "[note] IS NULL", indexName: "ux_members_email_without_note");
// or
b.HasComplexIndex(x => x.Email, ix => ix.HasName("ix_members_email").IncludeProperties("note"));Narrow Note to HasMaxLength(100). The operations are AlterColumnOperation alone. Had the filter said [Note], the index would be dropped before it and created after, which is #84.
Traced, not run: a case-only column rename (Note → NOTE) under the filter [note] IS NULL misses the filterColumns check of #182 the same way, and sp_rename fails.
Placeholder filters ({Note}) and property-path INCLUDE entries resolve to the exact column name and are not affected.
Change
Compare column names in ColumnsReadBy and ColumnsNamedIn with the provider's identifier comparison: IndexNameComparer or a sibling virtual. That is case-insensitive on SQL Server and SQLite and ordinal on PostgreSQL. Ignoring case is the safe direction: at worst it costs a needless rebuild on a case-sensitive collation.
The migration fails at apply today, so no database holds its result. The fix changes what this model scaffolds, and it ships on release/5.x.
Tests
SqlServerDifftests for both models above: the index is dropped before theAlterColumnOperationand created after it.- A case-only column rename under the filter: the index is rebuilt around the
RenameColumnOperation. - A PostgreSQL counterpart where case matters: a filter naming
"note"against a columnNoteis a different column, and nothing is rebuilt.
Activity
docs: resolve the CLAUDE.md merge conflict, and repair the line it ca…
CaffeinatedCoder commentedon Oct 23, 2026
Fixed on release/5.x by #194, shipping in 5.6.0. Closed by hand:
Closesacts only on merges intomain.The columns an index reads now compare under the provider's identifier rule (
IndexNameComparer): on SQL Server a filter's[note]or an INCLUDE entrynotereads the columnNote, so the index is moved out of the way of anALTER COLUMNor rename of it. PostgreSQL still compares exactly.Merge pull request #194 from CaffeinatedCoder/fix/189-case-insensitiv…