Commit 1feb992a authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'pb-fix-db-migrate-for-geo' into 'master'

Don't create partitions for geo rake tasks

See merge request gitlab-org/gitlab!82028
parents 1bf9f6de ad3aa2af
......@@ -163,6 +163,11 @@ namespace :gitlab do
end
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
# We'll temporarily skip this enhancement for geo, since in some situations we
# wish to setup the geo database before the other databases have been setup,
# and partition management attempts to connect to the main database.
next if name == 'geo'
Rake::Task["db:migrate:#{name}"].enhance do
Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
end
......@@ -181,6 +186,11 @@ namespace :gitlab do
end
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
# We'll temporarily skip this enhancement for geo, since in some situations we
# wish to setup the geo database before the other databases have been setup,
# and partition management attempts to connect to the main database.
next if name == 'geo'
Rake::Task["db:schema:load:#{name}"].enhance do
Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
end
......
......@@ -489,6 +489,20 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
expect { run_rake_task('db:migrate:main') }.not_to raise_error
end
end
describe 'db:migrate:geo' do
it 'does not invoke gitlab:db:create_dynamic_partitions' do
skip 'Skipping because geo database is not setup' unless geo_configured?
expect(Rake::Task['gitlab:db:create_dynamic_partitions']).not_to receive(:invoke)
expect { run_rake_task('db:migrate:geo') }.not_to raise_error
end
def geo_configured?
!!ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: 'geo')
end
end
end
describe 'gitlab:db:reset_as_non_superuser' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment