Improve Migrations handling
DB Migrations are difficult to manage. There's three databases that migrations can run against - GitLab, Praefect and Geo Tracking - Where the process differs along with the hard requirement that migrations need to run directly against the database and bypass PgBouncer.
In practice then this requires the following flow:
- Update
gitlab.rb
with database settings that point directly to the database and skip PgBouncer (if PgBouncer is being used) and to temporarily setgitlab_rails['auto_migrate']
/praefect['auto_migrate']
/geo_secondary['auto_migrate']
totrue
. - Run
reconfigure
to propagate config and run migrations.- There is
gitlab-ctl gitlab:db:configure
available for GitLab only as a specific command butreconfigure
is required anyways to propagate config. The same is the case for Geo withdb:migrate:geo
. There is no specific command for Praefect (raised separately).
- There is
- Update
gitlab.rb
settings to point to PgBouncer again and setgitlab_rails['auto_migrate']
/praefect['auto_migrate']
/geo_secondary['auto_migrate']
tofalse
. - Run
reconfigure
again to propagate config.
This is quite a complex flow to run DB migrations and is prone to user error. It's also difficult to automate. This should be improved.
Some ideas:
- Have a migrations command for GitLab, Praefect and Geo Tracking that accepts config directly to run migrations (direct db connection details, etc...)
- Add new config that users can configure with the direct Database connection details for migrations and have a migrations command for GitLab, Praefect and Geo Tracking that follows that config
- Add a failsafe check in the process to detect if migrations are running through PgBouncer in error to prevent this from happening
Edited by Grant Young