-
Notifications
You must be signed in to change notification settings - Fork 106
Multi-operation migration support for drop_table
operations
#587
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
Conversation
what will happen if you do a drop_table + create_table with the same name? I guess this one is tricky, but we will see others like this probably 🤔 |
c32fd12
to
f31ba70
Compare
This won't work currently. I've described the problem here: #239 (comment). |
I guess it should be fine as long as we are able to detect this situation and prevent the migration from moving forward, is that the case already? |
Add a `Deleted` field to the `Table` struct in order to allow `OpDeleteTable` to soft delete tables in the virtual schema. Update `RemoveTable` to set the `Deleted` field to `true` instead of removing a table from the `Tables` map. Add an `UnRemoveTable` method to allow tables to be unremoved. This can be used by `OpDeleteTable` to rollback the effects of a table deletion in the virtual schema. When looking up a table in the schema, ignore tables that have been marked as deleted. When creating views in the new schema, skip tables that have been marked as deleted.
So that `Rollback` of earlier operations in the migration see the table with the name that they expect.
So that the table is visible to `Rollback` methods of operations earlier in the migration.
Add a test that checks that dropping a table then renaming the table fails to validate.
Remove (soft-delete) the dropped table from the schema during `OpDropTable.Validate` so that validation of any subsequent operation in the same migration fails if it attempts to reference the removed table.
f31ba70
to
1a5b4a5
Compare
I thought some more about this and I think the 'create table, drop table, create table' case is now covered by #589 |
Ensure that
drop_table
operations can be used as part of multi-operation migrations:Add testcases for:
OpRenameTable.Validate
update the in-memory schema so that the following operation can validate using the new name of the tableOpDropTable
soft delete the table from the virtual schema, so thatOpDropTable.Rollback
can un-drop the table, making it visible to preceding operations in the table when the migration is rolled back.OpRenameTable
undo the table rename, so that the table is visible under its old name for preceding operations in the rollback.OpDropTable.Validate
remove the table from the virtual schema so that validation of the subsequent operation fails.Theses changes ensure that
drop_table
operations can be used as part of multi-operation migrations.Part of #239