Use DROP SCHEMA ... CASCADE in db:drop_tables
What does this MR do and why?
As reported in #347140 (closed), gitlab:db:drop_tables
is failing when trying to drop all the tables, because some objects still depend on the gitlab_partitions_dynamic
schema.
I think this is being caused by detached partitions, which wouldn't automatically be dropped when we drop the parent table earlier in the same rake task (we do a DROP TABLE ... CASCADE
there).
If we add CASCADE
on the DROP SCHEMA
as well, this will drop any of those dangling partitions.
How to set up and validate locally
- On master, create a "detached partition" in
gitlab_partitions_dynamic
create table gitlab_partitions_dynamic.web_hook_logs_000000 (like public.web_hook_logs);
- Run the rake task
rails gitlab:db:drop_tables
- Repeat those steps on this branch and the extra table will be dropped automatically when the schema is dropped.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Patrick Bair