Skip to content

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 set gitlab_rails['auto_migrate'] / praefect['auto_migrate'] / geo_secondary['auto_migrate'] to true.
  • Run reconfigure to propagate config and run migrations.
    • There is gitlab-ctl gitlab:db:configure available for GitLab only as a specific command but reconfigure is required anyways to propagate config. The same is the case for Geo with db:migrate:geo. There is no specific command for Praefect (raised separately).
  • Update gitlab.rb settings to point to PgBouncer again and set gitlab_rails['auto_migrate'] / praefect['auto_migrate'] / geo_secondary['auto_migrate'] to false.
  • 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:

Edited by Grant Young