in files/gitlab-ctl-commands/lib/postgresql/decomposition_migration.rb [8:68]
def migrate!
unless @ctl.service_enabled?('postgresql')
puts 'There is no PostgreSQL instance enabled in Omnibus, exiting...'
exit 1
end
puts <<~MSG
This script will migrate this GitLab instance to a two-database setup.
WARNING:
- This script is experimental. See https://docs.gitlab.com/ee/administration/postgresql/multiple_databases.html
- Once migrated to a two-database setup, you cannot migrate it back.
Ensure:
- The new database 'gitlabhq_production_ci' has been created, for example:
gitlab-psql -c "CREATE DATABASE gitlabhq_production_ci WITH OWNER 'gitlab'"
- The following changes are added to /etc/gitlab/gitlab.rb configuration file
but do **not** run 'gitlab-ctl reconfigure' yet:
gitlab_rails['env'] = { 'GITLAB_ALLOW_SEPARATE_CI_DATABASE' => 'true' }
gitlab_rails['databases']['ci']['enable'] = true
gitlab_rails['databases']['ci']['db_database'] = 'gitlabhq_production_ci'
This script will:
- Disable background migrations because they should not be active during this migration
See https://docs.gitlab.com/ee/development/database/batched_background_migrations.html
- Stop the Gitlab Instance
- Copy data in gitlabhq_production to gitlabhq_production_ci (by dumping, then restoring)
- Apply configuration changes in /etc/gitlab/gitlab.rb using 'gitlab-ctl reconfigure'
- Prevent errorneous database access
- Re-enable background migrations
- Restart GitLab
This script will not:
- Clean up data in the databases
Please confirm the upgrade by pressing 'y':
MSG
prompt = $stdin.gets.chomp
exit(1) unless prompt.casecmp('y').zero?
disable_background_migrations unless background_migrations_initally_disabled?
stop_gitlab_services
run_migration
post_migrate
puts <<~MSG
GitLab is now running on two databases. Data related to CI is now written to the ci
database.
You can also remove duplicated data by running:
'sudo gitlab-rake gitlab:db:truncate_legacy_tables:main'
'sudo gitlab-rake gitlab:db:truncate_legacy_tables:ci'
MSG
end