Sha256: e7b61ff1253a1495040c28cf1cd00c6617dbfdd740a4489d935fef7aefa24fa5

Contents?: true

Size: 602 Bytes

Versions: 3

Compression:

Stored size: 602 Bytes

Contents

module MigrationLockTimeout
  module LockManager

    def migrate(direction)
      timeout_disabled = self.class.disable_lock_timeout
      time = self.class.lock_timeout_override ||
        MigrationLockTimeout.try(:config).try(:default_timeout)
      if !timeout_disabled && direction == :up && time && !disable_ddl_transaction
        safety_assured? do
          execute "SET LOCAL lock_timeout = '#{time}s'"
        end
      end
      super
    end

    def safety_assured?
      if defined?(StrongMigrations)
        safety_assured { yield }
      else
        yield
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
migration-lock-timeout-1.4.0 lib/migration_lock_timeout/lock_manager.rb
migration-lock-timeout-1.3.0 lib/migration_lock_timeout/lock_manager.rb
migration-lock-timeout-1.2.0 lib/migration_lock_timeout/lock_manager.rb