Maintenance: Improve performance for db_strategy reset on postgresql.

This commit is contained in:
Rolf Schmidt 2021-03-22 10:45:41 +01:00 committed by Thorsten Eckel
parent beee44522b
commit 0b09063197

View file

@ -1,9 +1,18 @@
RSpec.configure do |config| RSpec.configure do |config|
config.around(:each, db_strategy: :reset) do |example| config.around(:each, db_strategy: :reset) do |example|
if ActiveRecord::Base.connection.instance_values['config'][:adapter] != 'postgresql'
self.use_transactional_tests = false self.use_transactional_tests = false
end
example.run example.run
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'].reenable
Rake::Task['zammad:db:reset'].invoke Rake::Task['zammad:db:reset'].invoke
end end
end
end end