Module: MigrationLockTimeout::LockManager

Defined in:
lib/migration_lock_timeout/lock_manager.rb

Instance Method Summary collapse

Instance Method Details

#migrate(direction) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/migration_lock_timeout/lock_manager.rb', line 4

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

#safety_assured?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
# File 'lib/migration_lock_timeout/lock_manager.rb', line 16

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