8000 Alter sequence owner before dropping the column by agedemenli · Pull Request #668 · xataio/pgroll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Alter sequence owner before dropping the column #668

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

Merged
merged 4 commits into from
Feb 11, 2025

Conversation

agedemenli
Copy link
Contributor
@agedemenli agedemenli commented Feb 10, 2025

Check if there's any sequence for the column before dropping it. If the column type is serial, pg_get_serial_sequence will return the sequence name. With this PR, we will be changing the owner column of the seqeunce to the new column so that we can safely drop the old one.
Fixes: #633

@agedemenli agedemenli requested a review from kvch February 10, 2025 12:07
@agedemenli agedemenli marked this pull request as ready for review February 10, 2025 12:07
Copy link
Contributor
@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start. But unfortunately, the bug can surface in all migration types if the column that has a serial sequence is being duplicated. Thus, it is not enough to change the owner only in create constraint operation. The issue must be addressed in more migration types where RenameDuplicatedColumn is called. The function that does the ownership change could be moved to duplicate.go or rename.go.

@agedemenli agedemenli requested a review from kvch February 11, 2025 08:45
Copy link
Contributor
@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Do you mind adding a few more tests for dropping multi-column constraints and altering columns?

@agedemenli agedemenli requested a review from kvch February 11, 2025 13:35
@agedemenli agedemenli merged commit f3432da into main Feb 11, 2025
28 checks passed
@agedemenli agedemenli deleted the alter-sequence-owner-before-drop-col branch February 11, 2025 14:56
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.

Cannot drop foreign key constraints that include a column with a serial type
2 participants
0