Skip to content

sp_IndexCleanup: preserve UNIQUE in merge script (#724)#725

Merged
erikdarlingdata merged 3 commits intodevfrom
fix/indexcleanup-preserve-unique-in-merge
Mar 26, 2026
Merged

sp_IndexCleanup: preserve UNIQUE in merge script (#724)#725
erikdarlingdata merged 3 commits intodevfrom
fix/indexcleanup-preserve-unique-in-merge

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Merge scripts for Key Superset indexes now preserve the UNIQUE keyword when the index is unique. Previously only checked for the MAKE UNIQUE action, missing the case where a unique constraint/index was the superset target with MERGE INCLUDES action.

Closes #724

Test plan

  • Unique constraint as superset → CREATE UNIQUE INDEX
  • Unique index as superset → CREATE UNIQUE INDEX
  • Regular NC as superset → CREATE INDEX (no change)

🤖 Generated with Claude Code

erikdarlingdata and others added 3 commits March 25, 2026 09:40
sp_IndexCleanup: performance + bug fix #721
…onstraints (#724)

The merge script generator only checked for action = 'MAKE UNIQUE'
when deciding whether to include UNIQUE in CREATE INDEX. When a unique
constraint/index was the Key Superset target (action = 'MERGE INCLUDES'),
the generated script dropped the UNIQUE keyword.

Now checks is_unique directly on the index being scripted.

Tested with both unique constraints and unique indexes on SQL2022.

Closes #724

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit d426372 into dev Mar 26, 2026
@erikdarlingdata erikdarlingdata deleted the fix/indexcleanup-preserve-unique-in-merge branch April 6, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant