Module: StrongMigrations::Migration
- Defined in:
- lib/strong_migrations/migration.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/strong_migrations/migration.rb', line 9
def method_missing(method, *args)
return super if is_a?(ActiveRecord::Schema)
return super if defined?(ActiveRecord::Schema::Definition) && is_a?(ActiveRecord::Schema::Definition)
catch(:safe) do
strong_migrations_checker.perform(method, *args) do
super
end
end
end
|
Instance Method Details
#migrate(direction) ⇒ Object
3
4
5
6
7
|
# File 'lib/strong_migrations/migration.rb', line 3
def migrate(direction)
strong_migrations_checker.direction = direction
super
connection.begin_db_transaction if strong_migrations_checker.transaction_disabled
end
|
#revert ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/strong_migrations/migration.rb', line 23
def revert(*)
if strong_migrations_checker.version_safe?
safety_assured { super }
else
super
end
end
|
#safety_assured ⇒ Object
31
32
33
34
35
|
# File 'lib/strong_migrations/migration.rb', line 31
def safety_assured
strong_migrations_checker.class.safety_assured do
yield
end
end
|
#stop!(message, header: "Custom check") ⇒ Object
37
38
39
|
# File 'lib/strong_migrations/migration.rb', line 37
def stop!(message, header: "Custom check")
raise StrongMigrations::UnsafeMigration, "\n=== #{} #strong_migrations ===\n\n#{message}\n"
end
|