Repository navigation
Drop removed database-level annotations after table and column operations - #39666
Open
seragAhmed wants to merge 1 commit into
Open
seragAhmed wants to merge 1 commit into
seragAhmed wants to merge 1 commit into
Conversation
…ions - In MigrationsModelDiffer.Sort, move annotations removed by an AlterDatabaseOperation into a separate AlterDatabaseOperation that runs after the column, alter and obsolete sequence operations - Additions, changes and the collation change stay in the original operation, which keeps its place before the table operations - This fixes Down() (and Up()) dropping a database object, such as an Npgsql collation, before reverting the columns that use it Fixes dotnet#39563 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
MigrationsModelDiffer.Sortnow splits anAlterDatabaseOperationwhen it removes annotations. The removed annotations go into a secondAlterDatabaseOperation(old annotations only, no new ones), which runs after the column, alter and obsolete-sequence operations. Additions, changes and the collation change stay in the original operation, in its usual place before the table operations. If nothing is left in the original operation, only the removal operation is emitted.This way, providers drop a database object, such as an Npgsql collation, enum or extension, only after the columns that used it have been reverted. That applies to both
Down()andUp(). The removal operation carries no new annotations, so SQL Server doesn't re-emit edition options or the memory-optimized setup for it.Tests (in
SqlServerModelDifferTest, which has real database-level annotations):Removed_database_annotations_are_dropped_after_column_operationsDatabase_annotation_removals_are_split_from_other_database_changesAlter_table_MemoryOptimized: inDown, the database-levelMemoryOptimizedremoval now comes after theAlterTableOperation. SQL Server generates no SQL for that removal.Fixes #39563