Sha256: 2f7e0bdeca20e028feb7fb2e668bb50ba05968fecbdf1bc4418c5671ff8db73a

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

module RooOnRails
  module Railties
    class Database < Rails::Railtie
      initializer 'roo_on_rails.database', after: 'active_record.initialize_database' do
        ActiveSupport.on_load :active_record do
          Rails.logger.debug('[roo_on_rails.database] loading')

          config = ActiveRecord::Base.configurations[Rails.env]
          config['variables'] ||= {}
          statement_timeout = ENV.fetch('DATABASE_STATEMENT_TIMEOUT', 200)
          # Use -1 to disable setting the statement timeout
          unless statement_timeout == '-1'
            config['variables']['statement_timeout'] = statement_timeout
          end
          if ENV.key?('DATABASE_REAPING_FREQUENCY')
            config['reaping_frequency'] = ENV['DATABASE_REAPING_FREQUENCY']
          end
          ActiveRecord::Base.establish_connection
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roo_on_rails-2.1.2 lib/roo_on_rails/railties/database.rb
roo_on_rails-2.1.0 lib/roo_on_rails/railties/database.rb