RSpec.configure do |config|

  config.around(:each, db_strategy: :reset) do |example|
    self.use_transactional_tests = false
    example.run
    Rake::Task['zammad:db:reset'].reenable
    Rake::Task['zammad:db:reset'].invoke
  end
end

RSpec.configure do |config|

  config.around(:each, db_strategy: :reset) do |example|
    if ActiveRecord::Base.connection.instance_values['config'][:adapter] != 'postgresql'
      self.use_transactional_tests = false
    end
    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'].invoke
    end
  end
end

Improve performance for db_strategy reset on postgresql.
Maintenance: Improve performance for db_strategy reset on postgresql.
