Closed tonykaralis closed 2 years ago
Update: DROP commands (without CASCADE) wont work on PKs that are used as FKs in other tables.
writer.WriteLine($"alter table {Expected.Identifier} drop constraint if exists {Expected.PrimaryKeyName};");
writer.WriteLine($"alter table {Expected.Identifier} add {Actual.PrimaryKeyDeclaration()};");
We therefore have 2 bugs that are a result of the above commands:
@tonykaralis released in 1.0.4 👍
Follow on rom #39.
Migrations are being generated when primary key constraint names have changed. When the constraint is not used in another table the migrations complete successfully, however when a constraint is used in another table the migrations fail. This is due to using alter table with drop and then add commands. An alternative would be to use alter table with rename command.
Things to consider: The current commands work well as they cover scenarios where the actual primary key column name changes, whereas this bug occurs when the PK constraint name changes. A rename might work for constraints but not for the actual column.