module RooOnRails
  module Railties
    class Database < Rails::Railtie
      initializer 'roo_on_rails.database', after: 'active_record.initialize_database' do |_app|
        $stderr.puts 'initializer roo_on_rails.database'

        config = ActiveRecord::Base.configurations[Rails.env]
        config['variables'] ||= {}
        config['variables']['statement_timeout'] = ENV.fetch('DATABASE_STATEMENT_TIMEOUT', 200)

        ActiveRecord::Base.establish_connection
      end
    end
  end
end

module RooOnRails
  module Railties
    class Database < Rails::Railtie
      initializer 'roo_on_rails.database', after: 'active_record.initialize_database' do |_app|
        $stderr.puts 'initializer roo_on_rails.database'

        ActiveRecord::Base.configurations[Rails.env]['timeout'] = ENV.fetch('DATABASE_TIMEOUT', 200)
        ActiveRecord::Base.establish_connection
      end
    end
  end
end

--- 
+++ 
@@ -4,7 +4,10 @@
       initializer 'roo_on_rails.database', after: 'active_record.initialize_database' do |_app|
         $stderr.puts 'initializer roo_on_rails.database'
 
-        ActiveRecord::Base.configurations[Rails.env]['timeout'] = ENV.fetch('DATABASE_TIMEOUT', 200)
+        config = ActiveRecord::Base.configurations[Rails.env]
+        config['variables'] ||= {}
+        config['variables']['statement_timeout'] = ENV.fetch('DATABASE_STATEMENT_TIMEOUT', 200)
+
         ActiveRecord::Base.establish_connection
       end
     end
IP-469: Set statement timeout, not connection timeout, for DB
