Skip to content

Multi-operation migration support for drop_column operations #591

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 6 commits into from
Jan 14, 2025

Conversation

andrew-farries
Copy link
Collaborator

Ensure that drop_column operations can be used as part of multi-operation migrations:

Add testcases for:

  • rename table, drop column
  • add column, drop column

Theses changes help ensure that drop_column operations can be used as part of multi-operation migrations.

Part of #239

@andrew-farries andrew-farries force-pushed the op-add-column-multi-op-tests branch from a0c5c62 to 2733675 Compare January 14, 2025 15:43
@andrew-farries andrew-farries force-pushed the op-drop-column-multi-op-tests branch from 9408cd8 to 4015541 Compare January 14, 2025 15:43
Base automatically changed from op-add-column-multi-op-tests to main January 14, 2025 15:47
Take the table name from the schema instead of the operation, to account
for any renames that may have occurred by preceding operations in the
  same migration
Add a `Deleted` field to the `Column` struct in order to allow
`OpDropColumn` to soft delete columns in the virtual schema.

Update `RemoveColumn` to set the `Deleted` field to `true` instead of
removing a column from the `columns` map.

Add an `UnRemoveColumn` method to allow columns to be unremoved. This can
be used by `OpDropColumn` to rollback the effects of a column deletion
in the virtual schema.

When looking up a column in the schema, ignore columns that have been
marked as deleted.

When creating views in the new schema, skip columns that have been marked
as deleted.
Take the name of the column whose addition should be rolled back by
looking up the name of the column in the schema, rather than assuming
the name is the one given in the operation; this ensures that
indirections are handled correctly.
Mark the dropped column as no longer deleted so that it becomes visible
to preceding rollback operations in the same migration.
@andrew-farries andrew-farries force-pushed the op-drop-column-multi-op-tests branch from 4015541 to e726c8e Compare January 14, 2025 15:48
@andrew-farries andrew-farries merged commit 9118345 into main Jan 14, 2025
28 checks passed
@andrew-farries andrew-farries deleted the op-drop-column-multi-op-tests branch January 14, 2025 15:52
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