Class: ActiveRecord::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/low_card_tables.rb

Overview

ActiveRecord migration methods (e.g., #create_table, #remove_column, etc.) are actually defined on the connection classes used by ActiveRecord. Here, we make sure that we get a chance to patch any connection used in any migration properly, so that we can add our migration support to it. See LowCardTables::ActiveRecord::Migrations for more information.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._low_card_patch_connection_class_if_necessary(connection_class) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/low_card_tables.rb', line 57

def _low_card_patch_connection_class_if_necessary(connection_class)
  @_low_card_patched_connection_classes = { }
  @_low_card_patched_connection_classes[connection_class] ||= begin
    connection_class.send(:include, ::LowCardTables::ActiveRecord::Migrations)
    true
  end
end

.migrate_with_low_card_connection_patching(*args, &block) ⇒ Object



40
41
42
43
# File 'lib/low_card_tables.rb', line 40

def migrate_with_low_card_connection_patching(*args, &block)
  _low_card_patch_connection_class_if_necessary(connection.class)
  migrate_without_low_card_connection_patching(*args, &block)
end

Instance Method Details

#migrate_with_low_card_connection_patching(*args, &block) ⇒ Object



48
49
50
51
# File 'lib/low_card_tables.rb', line 48

def migrate_with_low_card_connection_patching(*args, &block)
  self.class._low_card_patch_connection_class_if_necessary(connection.class)
  migrate_without_low_card_connection_patching(*args, &block)
end