-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rename primary and foreign key operation #14988
Conversation
Sorry this was meant to be a Draft pull request but I accidentally created a normal one and it appears that you cant change this after it has been created (I've actually already bugged @natfriedman about this on twitter). |
bf2d695
to
c4f97dc
Compare
I've rebased this because it didn't apply cleanly anymore. |
c4f97dc
to
38b9f09
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few comments...
src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs
Outdated
Show resolved
Hide resolved
@Brar Just wanted to let you know that we haven't forgotten about this. However, due to other high-priority work it make take a bit of time for us to get back to this. |
@ajcvickers thanks, no worries. |
Also remember that today they generate drop and re-create operations so they would be no more broken than they already are. We have a separate issue to perform table and constraint rebuilds automatically as part of a migration. |
38b9f09
to
834d4d7
Compare
Ok, this is my suggestion for further discussions.
|
@ajcvickers @bricelam Now that 3.1 is out and you are beginning to work on 5.0 I assume that it's a good time for me to lobby for this PR again. cc: @roji |
I hope to get this in before the first preview of of 5.0.0. It might be early January before I get around to it. (I'm currently writing some docs to support the 3.1 release.) |
Thanks @bricelam! |
134cbcf
to
4052c41
Compare
@bricelam I've rebased this as I had some spare time today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to clean up the breaking changes and use our dependency object patterns.
src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs
Outdated
Show resolved
Hide resolved
test/EFCore.Relational.Specification.Tests/MigrationSqlGeneratorTestBase.cs
Outdated
Show resolved
Hide resolved
734be68
to
3887916
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New migration tests look great to me, thanks @Brar!
I think we can drop the ModelDiffer and MigrationSqlGenerator tests - the new migration tests exercise all those components as well, so these don't add any value. We still have these two test suites for tests which for some reason cannot be tested in MigrationsTestBase (#19668 is about cleaning that up). @bricelam can you confirm you're OK with that?
Other notes:
- Some tests are failing (at the very least some SQL baselines need updating)
- If we're adding rename support for constraints, we may as well do the same for checked constraints...
- I haven't reviewed anything else here other than the tests
3887916
to
5b58bb0
Compare
Sorry this was my fault.
I haven't removed anything yet, but I can certainly do so. Just waiting for @bricelam to confirm that he's OK with that.
👍 |
Sounds good to me |
5b58bb0
to
098934d
Compare
Hi @bricelam and @roji While most of the changes are pretty straightforward, I urge you to have a closer look at the last commit regarding the warning. |
@Brar - Skiiing always takes priority over anything else. |
453cfe0
to
5169298
Compare
Some database systems support renaming primary key constraints, foreign key constraints or unique constraints without rebuilding the table. Add the following operations to MigrationBuilder in order to support this: - RenamePrimaryKeyOperation - RenameUniqueConstraintOperation - RenameForeignKeyOperation
5169298
to
eafed8b
Compare
Ok @bricelam, I've rebased this once again. |
Since this has been inactive for quite a while and I don't think I can resume working on this any time soon I'm closing this now. |
Addresses #5662
I've kept separate commits for the three different constraint types but will squash them upon request..\build.cmd -test
on my system). The 2 failing tests seem to be completely unrelated to my changes as they also fail on a clean master checkout on my system:Microsoft.EntityFrameworkCore.Scaffolding.SqlServerDatabaseModelFactoryTest.Default_value_matching_clr_default_is_not_stored
fails forIgnoredDefault24 float NOT NULL DEFAULT 0.0E0
wherenull
is expected and the actual value is0.000000000000000e+000
Microsoft.EntityFrameworkCore.Scaffolding.SqlServerDatabaseModelFactoryTest.Hidden_columns_are_not_created
throws anSqlException
:Incorrect syntax near 'GENERATED'.\r\nIncorrect syntax near 'HIDDEN'.\r\nIncorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
Please review the guidelines for CONTRIBUTING.md for more details.