Class: ActiveRecord::Postgres::Constraints::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/active_record/postgres/constraints/railtie.rb

Instance Method Summary collapse

Instance Method Details

#apply_patch!Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_record/postgres/constraints/railtie.rb', line 17

def apply_patch!
  Rails.logger.info do
    'Applying Postgres Constraints patches to ActiveRecord'
  end
  AR_CAS::TableDefinition.include TableDefinition
  AR_CAS::PostgreSQLAdapter.include PostgreSQLAdapter
  AR_CAS::AbstractAdapter::SchemaCreation.prepend SchemaCreation

  ::ActiveRecord::Migration::CommandRecorder.include CommandRecorder
  ::ActiveRecord::SchemaDumper.prepend SchemaDumper
end

#pg?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
# File 'lib/active_record/postgres/constraints/railtie.rb', line 29

def pg?
  config = ActiveRecord::Base.connection_config
  return true if config && config[:adapter].in?(%w[postgresql postgis])

  Rails.logger.warn do
    'Not applying Postgres Constraints patches to ActiveRecord ' \
      'since the database is not postgres'
  end
  false
end