Skip to content
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

Convert DROP COLUMN SQL to pgroll operation #521

Merged
merged 7 commits into from
Dec 11, 2024

Conversation

ryanslade
Copy link
Collaborator

@ryanslade ryanslade commented Dec 10, 2024

Part of #504

@ryanslade
Copy link
Collaborator Author

@andrew-farries What should we do about more complicated statements? The fun spec is:

DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ]

Copy link
Collaborator

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

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

@andrew-farries What should we do about more complicated statements? The fun spec is:

DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ]

In general we have to be careful to generate pgroll operations only when we're sure we won't lose information present in the SQL. In cases where there are extra options present in the SQL that we can't represent in the pgroll operation we should fall back to generating a raw SQL operation.

In this case:

IF EXISTS is being ignored by the conversion to other operation types. This may or may not be the right behaviour, but we can follow it here and address it later for all operations.

pkg/sql2pgroll/convert.go Show resolved Hide resolved
@ryanslade
Copy link
Collaborator Author

@andrew-farries Thanks for the help, this is ready for review.

pkg/sql2pgroll/alter_table.go Outdated Show resolved Hide resolved
pkg/sql2pgroll/alter_table_test.go Show resolved Hide resolved
@ryanslade
Copy link
Collaborator Author

Once merged, do we mark the entry in the table at #504 with orange or green? We still fall back to raw sql in some cases so not sure if that is considered "done done"

@andrew-farries
Copy link
Collaborator

Once merged, do we mark the entry in the table at #504 with orange or green? We still fall back to raw sql in some cases so not sure if that is considered "done done"

I think we can set it to 🟢 . The 'fallback to raw sql' testcases serve as a good list of extra options for the respective pgroll operations to support, but we don't need to commit to supporting all of them as part of #504.

@ryanslade ryanslade merged commit d1db25d into main Dec 11, 2024
27 checks passed
@ryanslade ryanslade deleted the rs/sql2pgroll-drop-column branch December 11, 2024 08:21
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.

2 participants