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.
23 24 25 26 27 28 29 30 |
# File 'lib/online_migrations/command_checker.rb', line 23 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.
10 11 12 |
# File 'lib/online_migrations/command_checker.rb', line 10 def safe @safe end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
21 22 23 |
# File 'lib/online_migrations/command_checker.rb', line 21 def direction @direction end |
Class Method Details
.safety_assured ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/online_migrations/command_checker.rb', line 12 def safety_assured prev_value = safe self.safe = true yield ensure self.safe = prev_value end |
Instance Method Details
#check(command, *args, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/online_migrations/command_checker.rb', line 32 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
51 52 53 |
# File 'lib/online_migrations/command_checker.rb', line 51 def version_safe? version && version <= OnlineMigrations.config.start_after end |