Update rake tasks to have multi-db versions
What does this MR do and why?
Update rake task mark_migration_complete
to support multiple databases. Related to #352770 (closed)
If only a single database is configured, you should only see the singular rake task gitlab:db:mark_migration_complete
.
If multiple databases are configured, you should see:
rake -T gitlab:db:mark_migration_complete
rake gitlab:db:mark_migration_complete[version] # GitLab | DB | Manually insert schema migration version
rake gitlab:db:mark_migration_complete:ci[version] # Gitlab | DB | Manually insert schema migration version on ci database
rake gitlab:db:mark_migration_complete:main[version] # Gitlab | DB | Manually insert schema migration version on main database
How to set up and validate locally
If you have a multi-database setup, you can test the individual tasks:
- Against
main
only:# rails gitlab:db:mark_migration_complete:main\[20220201120000\] Successfully marked '20220201120000' as complete on database main psql# select count(*) from schema_migrations where version = '20220201120000'; -- on main count ------- 1
- Against
ci
only:# GITLAB_USE_MODEL_LOAD_BALANCING=true rails gitlab:db:mark_migration_complete:ci\[20220201120000\] Successfully marked '20220201120000' as complete on database ci psql# select count(*) from schema_migrations where version = '20220201120000'; -- on ci count ------- 1
- Against all databases:
# GITLAB_USE_MODEL_LOAD_BALANCING=true rails gitlab:db:mark_migration_complete\[20220201120001\] Successfully marked '20220201120001' as complete on database main Successfully marked '20220201120001' as complete on database ci psql# select count(*) from schema_migrations where version = '20220201120001'; -- on main and ci both count ------- 1
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