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
# File 'lib/strong_migrations/migration.rb', line 9

def method_missing(method, *args)
  return super if is_a?(ActiveRecord::Schema)

  # Active Record 7.0.2+ versioned schema
  return super if defined?(ActiveRecord::Schema::Definition) && is_a?(ActiveRecord::Schema::Definition)

  strong_migrations_checker.perform(method, *args) do
    super
  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

#safety_assuredObject



21
22
23
24
25
# File 'lib/strong_migrations/migration.rb', line 21

def safety_assured
  strong_migrations_checker.safety_assured do
    yield
  end
end

#stop!(message, header: "Custom check") ⇒ Object



27
28
29
# File 'lib/strong_migrations/migration.rb', line 27

def stop!(message, header: "Custom check")
  raise StrongMigrations::UnsafeMigration, "\n=== #{header} #strong_migrations ===\n\n#{message}\n"
end