-
Notifications
You must be signed in to change notification settings - Fork 218
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
fix(se): render constraint renames as separate sql statements #4906
base: main
Are you sure you want to change the base?
fix(se): render constraint renames as separate sql statements #4906
Conversation
Neat. Could you add a test that shows this working now (and failing before your change)? Problem with prisma/prisma#18274 was that it does not have concrete steps for us to reproduce the problem - from your decsription above I assume this only applies for migration where a primary key is renamed while other things happen in the table? |
CodSpeed Performance ReportMerging #4906 will not alter performanceComparing Summary
|
…uditmorina/schema-engine/fix-invalid-rename-primary-key-constraint
…uditmorina/schema-engine/fix-invalid-rename-primary-key-constraint
@janpio as instructed, I added tests that show the correct rendering of the migration. And I can confirm that as you put it, the problem applies for migrations where primary key is renamed, together with other changes in the same table, as part of the same migration. |
When applying/generating migrations, renaming primary key constraints in SQL (Postgres) requires statements to be separate from other table alter statements.
If we have multiple changes in the same table, the rename should be rendered as a separate sql statement otherwise it will throw a database error (picture below):
In this PR, I excluded the
RenamePrimaryKey
from alter tablelines
and am appending it toafter_statements
to be executed as a separateALTER TABLE
statement, that way the corresponding sql statements would render correctly.Related issue: