Module: Migration::SafeMigrate::SafeMigration

Defined in:
lib/migration/safe_migrate.rb

Constant Summary collapse

@@enable_safe =
true

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disable_safe!Object



17
18
19
# File 'lib/migration/safe_migrate.rb', line 17

def self.disable_safe!
  @@enable_safe = false
end

.enable_safe!Object



13
14
15
# File 'lib/migration/safe_migrate.rb', line 13

def self.enable_safe!
  @@enable_safe = true
end

Instance Method Details

#migrate(direction) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/migration/safe_migrate.rb', line 21

def migrate(direction)
  if direction == :up && version &&
       version > Migration::SafeMigrate.earliest_post_deploy_version &&
       @@enable_safe != false && !is_post_deploy_migration?
    Migration::SafeMigrate.enable!
  end

  super
ensure
  Migration::SafeMigrate.disable!
end