Module: OnlineMigrations::Migration
- Defined in:
- lib/online_migrations/migration.rb
Instance Method Summary collapse
-
#safety_assured(reason = nil, &block) ⇒ Object
Mark a command in the migration as safe, despite using a method that might otherwise be dangerous.
-
#stop!(message, header: "Custom check") ⇒ Object
Stop running migrations.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/online_migrations/migration.rb', line 19 def method_missing(method, *args, &block) if ar_schema? super elsif command_checker.check(method, *args, &block) if in_transaction? super elsif method == :with_lock_retries connection.with_lock_retries(*args, &block) else connection.with_lock_retries { super } end end end |
Instance Method Details
#safety_assured(reason = nil, &block) ⇒ Object
Mark a command in the migration as safe, despite using a method that might otherwise be dangerous.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/online_migrations/migration.rb', line 48 def safety_assured(reason = nil, &block) config = OnlineMigrations.config safe_version = version && version <= config.start_after if config.require_safety_assured_reason && reason.blank? && !safe_version raise OnlineMigrations::Error, "Specify a safety reason explanation when calling #safety_assured." end command_checker.class.safety_assured(&block) end |
#stop!(message, header: "Custom check") ⇒ Object
Stop running migrations.
It is intended for use in custom checks.
70 71 72 |
# File 'lib/online_migrations/migration.rb', line 70 def stop!(, header: "Custom check") raise OnlineMigrations::UnsafeMigration, "⚠️ [online_migrations] #{header} ⚠️\n\n#{message}\n\n" end |