Class: OnlineMigrations::CommandChecker
- Inherits:
-
Object
- Object
- OnlineMigrations::CommandChecker
- Defined in:
- lib/online_migrations/command_checker.rb
Class Attribute Summary collapse
-
.safe ⇒ Object
Returns the value of attribute safe.
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
Class Method Summary collapse
Instance Method Summary collapse
- #check(command, *args, &block) ⇒ Object
-
#initialize(migration) ⇒ CommandChecker
constructor
A new instance of CommandChecker.
- #version_safe? ⇒ Boolean
Constructor Details
#initialize(migration) ⇒ CommandChecker
Returns a new instance of CommandChecker.
22 23 24 25 26 27 28 29 |
# File 'lib/online_migrations/command_checker.rb', line 22 def initialize(migration) @migration = migration @new_tables = [] @new_columns = [] @lock_timeout_checked = false @foreign_key_tables = Set.new @removed_indexes = [] end |
Class Attribute Details
.safe ⇒ Object
Returns the value of attribute safe.
9 10 11 |
# File 'lib/online_migrations/command_checker.rb', line 9 def safe @safe end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
20 21 22 |
# File 'lib/online_migrations/command_checker.rb', line 20 def direction @direction end |
Class Method Details
.safety_assured ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/online_migrations/command_checker.rb', line 11 def safety_assured prev_value = safe self.safe = true yield ensure self.safe = prev_value end |
Instance Method Details
#check(command, *args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/online_migrations/command_checker.rb', line 31 def check(command, *args, &block) check_database_version set_statement_timeout check_lock_timeout if !safe? do_check(command, *args, &block) run_custom_checks(command, args) if @foreign_key_tables.count { |t| !new_table?(t) } > 1 raise_error :multiple_foreign_keys end end true end |
#version_safe? ⇒ Boolean
50 51 52 |
# File 'lib/online_migrations/command_checker.rb', line 50 def version_safe? version && version <= OnlineMigrations.config.start_after end |