Sha256: f2d4af9f32cc7cafaf8f2f8524124f939d739972d3b19c5b54a4f619e026882d

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

# nodoc
module PGTrunk
  # @private
  # Turn in PGTrunk-relates stuff in the Rails app
  class Railtie < Rails::Railtie
    require_relative "railtie/command_recorder"
    require_relative "railtie/custom_types"
    require_relative "railtie/migration"
    require_relative "railtie/migrator"
    require_relative "railtie/schema_dumper"
    require_relative "railtie/schema_migration"
    require_relative "railtie/statements"

    initializer("pg_trunk.load") do
      ActiveSupport.on_load(:active_record) do
        # overload schema dumper to use gem-specific object fetchers
        ActiveRecord::SchemaDumper.prepend PGTrunk::SchemaDumper
        # add custom type casting
        ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend PGTrunk::CustomTypes
        # add migration methods
        ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend PGTrunk::Statements
        # register those methods for migration directions
        ActiveRecord::Migration::CommandRecorder.include PGTrunk::CommandRecorder
        # support the registry table `pg_trunk` in addition to `schema_migrations`
        ActiveRecord::SchemaMigration.prepend PGTrunk::SchemaMigration
        # fix migration to enable different syntax without the name of the table
        ActiveRecord::Migration.prepend PGTrunk::Migration
        # make the migrator to remove stale records from `pg_trunk`
        ActiveRecord::Migrator.prepend PGTrunk::Migrator
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_trunk-0.2.0 lib/pg_trunk/core/railtie.rb
pg_trunk-0.1.3 lib/pg_trunk/core/railtie.rb
pg_trunk-0.1.2 lib/pg_trunk/core/railtie.rb
pg_trunk-0.1.1 lib/pg_trunk/core/railtie.rb
pg_trunk-0.1.0 lib/pg_trunk/core/railtie.rb