-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
@andrew-farries What should we do about more complicated statements? The fun spec is: DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ] |
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.
@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:
RESTRICT
is the default behaviour, so we can safely generate the operation.CASCADE
is not an option thatop_drop_column
currently supports so we have to fall back to raw SQL in case it is present. There are already tests for this kind of 'fall back to raw SQL' behaviour: https://github.com/xataio/pgroll/blob/main/pkg/sql2pgroll/alter_table_test.go?plain=1#L63-L92. We should add testcases here (and update the test name)
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.
@andrew-farries Thanks for the help, this is ready for review. |
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 |
Part of #504