Commit a961d0a1 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'clear_all_connections_before_db_purge' into 'master'

Clear all connections just before db:test:purge

See merge request gitlab-org/gitlab!80849
parents c230f294 f7d1ec18
...@@ -170,6 +170,13 @@ namespace :gitlab do ...@@ -170,6 +170,13 @@ namespace :gitlab do
Rake::Task['gitlab:db:create_dynamic_partitions'].invoke Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
end end
desc "Clear all connections"
task :clear_all_connections do
ActiveRecord::Base.clear_all_connections!
end
Rake::Task['db:test:purge'].enhance(['gitlab:db:clear_all_connections'])
# During testing, db:test:load restores the database schema from scratch # During testing, db:test:load restores the database schema from scratch
# which does not include dynamic partitions. We cannot rely on application # which does not include dynamic partitions. We cannot rely on application
# initializers here as the application can continue to run while # initializers here as the application can continue to run while
......
...@@ -20,6 +20,14 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do ...@@ -20,6 +20,14 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
allow(Rake::Task['db:seed_fu']).to receive(:invoke).and_return(true) allow(Rake::Task['db:seed_fu']).to receive(:invoke).and_return(true)
end end
describe 'clear_all_connections' do
it 'calls clear_all_connections!' do
expect(ActiveRecord::Base).to receive(:clear_all_connections!)
run_rake_task('gitlab:db:clear_all_connections')
end
end
describe 'mark_migration_complete' do describe 'mark_migration_complete' do
context 'with a single database' do context 'with a single database' do
let(:main_model) { ActiveRecord::Base } let(:main_model) { ActiveRecord::Base }
......
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