From 0b09063197ba8a3bcb0b7d8476fbe08f30b42903 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Mon, 22 Mar 2021 10:45:41 +0100 Subject: [PATCH] Maintenance: Improve performance for db_strategy reset on postgresql. --- spec/support/db_strategies.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/support/db_strategies.rb b/spec/support/db_strategies.rb index a4a8c831f..575ea85cb 100644 --- a/spec/support/db_strategies.rb +++ b/spec/support/db_strategies.rb @@ -1,9 +1,18 @@ RSpec.configure do |config| config.around(:each, db_strategy: :reset) do |example| - self.use_transactional_tests = false + if ActiveRecord::Base.connection.instance_values['config'][:adapter] != 'postgresql' + self.use_transactional_tests = false + end example.run - Rake::Task['zammad:db:reset'].reenable - Rake::Task['zammad:db:reset'].invoke + if ActiveRecord::Base.connection.instance_values['config'][:adapter] == 'postgresql' + Models.all.each_key do |model| + model.connection.schema_cache.clear! + model.reset_column_information + end + else + Rake::Task['zammad:db:reset'].reenable + Rake::Task['zammad:db:reset'].invoke + end end end