Sha256: 8d2592f3e1d3eddcb615cc87f58022af8375f61b610f0e655c6f32d19fcf6d84

Contents?: true

Size: 1.94 KB

Versions: 5

Compression:

Stored size: 1.94 KB

Contents

require "pg_ha_migrations/version"
require "rails"
require "active_record"
require "active_record/migration"
require "relation_to_struct"

module PgHaMigrations
  Config = Struct.new(
    :disable_default_migration_methods,
    :check_for_dependent_objects,
    :allow_force_create_table
  )

  def self.config
    @config ||= Config.new(
      true,
      false,
      true
    )
  end

  def self.configure
    yield config
  end

  LOCK_TIMEOUT_SECONDS = 5
  LOCK_FAILURE_RETRY_DELAY_MULTLIPLIER = 5

  # Safe versus unsafe in this context specifically means the following:
  # - Safe operations will not block for long periods of time.
  # - Unsafe operations _may_ block for long periods of time.
  UnsafeMigrationError = Class.new(Exception)

  # Invalid migrations are operations which we expect to not function
  # as expected or get the schema into an inconsistent state
  InvalidMigrationError = Class.new(Exception)

  # Unsupported migrations use ActiveRecord::Migration features that
  # we don't support, and therefore will likely have unexpected behavior.
  UnsupportedMigrationError = Class.new(Exception)

  # This gem only supports the PostgreSQL adapter at this time.
  UnsupportedAdapter = Class.new(Exception)
end

require "pg_ha_migrations/blocking_database_transactions"
require "pg_ha_migrations/blocking_database_transactions_reporter"
require "pg_ha_migrations/unsafe_statements"
require "pg_ha_migrations/safe_statements"
require "pg_ha_migrations/dependent_objects_checks"
require "pg_ha_migrations/allowed_versions"
require "pg_ha_migrations/railtie"
require "pg_ha_migrations/hacks/disable_ddl_transaction"
require "pg_ha_migrations/hacks/cleanup_unnecessary_output"

module PgHaMigrations::AutoIncluder
  def inherited(klass)
    super(klass) if defined?(super)

    klass.prepend(PgHaMigrations::UnsafeStatements)
    klass.prepend(PgHaMigrations::SafeStatements)
  end
end

ActiveRecord::Migration.singleton_class.prepend(PgHaMigrations::AutoIncluder)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_ha_migrations-1.3.0 lib/pg_ha_migrations.rb
pg_ha_migrations-1.2.5 lib/pg_ha_migrations.rb
pg_ha_migrations-1.2.4 lib/pg_ha_migrations.rb
pg_ha_migrations-1.2.3 lib/pg_ha_migrations.rb
pg_ha_migrations-1.2.2 lib/pg_ha_migrations.rb