Update db:drop_tables to have multi-db versions
What does this MR do and why?
Update rake task drop_tables
to support multiple databases. Related to #352770 (closed)
If only a single database is configured, you should continue to see only the singular rake task gitlab:db:drop_tables
.
If multiple databases are configured, you should see:
rake -T gitlab:db:drop_tables
rake gitlab:db:drop_tables # GitLab | DB | Drop all tables
rake gitlab:db:drop_tables:ci # GitLab | DB | Drop all tables on the ci database
rake gitlab:db:drop_tables:main # GitLab | DB | Drop all tables on the main database
How to set up and validate locally
If you have multiple databases setup, you can validate against a single database first:
- Drop all tables on
ci
database, and verify tables are gone:# GITLAB_USE_MODEL_LOAD_BALANCING=true rake gitlab:db:drop_tables:ci pbair@[local]:5432/gitlabhq_development_ci# \d List of relations Schema | Name | Type | Owner --------+-------------------+-------+------- public | schema_migrations | table | pbair (1 row)
- Drop all tables for all databases, and then the tables on
main
should also be gone:# GITLAB_USE_MODEL_LOAD_BALANCING=true rake gitlab:db:drop_tables pbair@[local]:5432/gitlabhq_development# \d List of relations Schema | Name | Type | Owner --------+-------------------+-------+------- public | schema_migrations | table | pbair (1 row)
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