Sha256: d88868b4386d755633582992c3f54d901f5ba9d6d23a82b5ca5ae9e670362773

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 Bytes

Contents

module StrongMigrations
  module Migration
    def migrate(direction)
      strong_migrations_checker.direction = direction
      super
      connection.begin_db_transaction if strong_migrations_checker.transaction_disabled
    end

    def method_missing(method, *args)
      return super if is_a?(ActiveRecord::Schema)

      strong_migrations_checker.perform(method, *args) do
        super
      end
    end
    ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)

    def safety_assured
      strong_migrations_checker.safety_assured do
        yield
      end
    end

    def stop!(message, header: "Custom check")
      raise StrongMigrations::UnsafeMigration, "\n=== #{header} #strong_migrations ===\n\n#{message}\n"
    end

    private

    def strong_migrations_checker
      @strong_migrations_checker ||= StrongMigrations::Checker.new(self)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strong_migrations-0.7.9 lib/strong_migrations/migration.rb
strong_migrations-0.7.8 lib/strong_migrations/migration.rb
strong_migrations-0.7.7 lib/strong_migrations/migration.rb