lib/strong_migrations/checker.rb in strong_migrations-1.6.1 vs lib/strong_migrations/checker.rb in strong_migrations-1.6.2
- old
+ new
@@ -3,26 +3,29 @@
include Checks
include SafeMethods
attr_accessor :direction, :transaction_disabled, :timeouts_set
+ class << self
+ attr_accessor :safe
+ end
+
def initialize(migration)
@migration = migration
@new_tables = []
@new_columns = []
- @safe = false
@timeouts_set = false
@committed = false
end
- def safety_assured
- previous_value = @safe
+ def self.safety_assured
+ previous_value = safe
begin
- @safe = true
+ self.safe = true
yield
ensure
- @safe = previous_value
+ self.safe = previous_value
end
end
def perform(method, *args)
check_version_supported
@@ -158,10 +161,10 @@
@lock_timeout_checked = true
end
def safe?
- @safe || ENV["SAFETY_ASSURED"] || (direction == :down && !StrongMigrations.check_down) || version_safe?
+ self.class.safe || ENV["SAFETY_ASSURED"] || (direction == :down && !StrongMigrations.check_down) || version_safe?
end
def version_safe?
version && version <= StrongMigrations.start_after
end