Skip to content

SQL Server: a second clustered complex index in a later migration, and an index named like the table's key, fail only at apply #90

Closed

Description

@CaffeinatedCoder

Problem

ValidateCreatedIndexes rejects a second clustered complex index only among the creates of one migration. If cx_one (clustered) already exists and a later migration adds cx_two with .IsClustered(), it scaffolds CREATE CLUSTERED INDEX [cx_two] ON [things] ([Address_Code]); and fails at apply. docs/sqlserver.md says a second clustered index is rejected at migrations add.

Two related gaps in SQL Server validation, both loud:

  • The clustered-slot check also runs on the source (snapshot) model, unlike every other check, which validates the target only. A snapshot holding a clustered key plus a clustered complex index (only reachable from snapshots scaffolded before 5.0.2) throws even on the migration that fixes it.
  • A complex index named like its own table's key (indexName: "PK_things") scaffolds CREATE INDEX [PK_things] ON [things] and fails at apply: ValidateNoNativeIndexNameCollision checks native indexes, not keys.

Fix

Count clustered declarations on the whole target table; validate the clustered slot on the target only; include keys and unique constraints in the native name-collision check on SQL Server.

Found by the 5.5.0 pre-tag analysis (core and SQL Server).

Activity

  1. added this to the 5.5.1 milestone on Oct 19, 2026
  2. added
    bug
    severity/low
    package/sqlserver
    area/indexes
    on Oct 19, 2026
  3. modified the milestones: 5.5.1, 5.5.0 on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/indexesbugpackage/sqlserverseverity/low

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions