123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Migration::Current

Do not use. This class is for internal use only.

Overview

This must be defined before the inherited hook, below

Instance Method Summary

Instance Method Details

#change_table(table_name, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration.rb', line 587

def change_table(table_name, **options)
  if block_given?
    super { |t| yield compatible_table_definition(t) }
  else
    super
  end
end

#compatible_table_definition(t)

Ancestors are walked oldest-version-first, so the newest version's module ends up first in method lookup — the same order the per-class overrides produced.

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration.rb', line 614

def compatible_table_definition(t)
  (self.class.ancestors & Compatibility.version_classes).each do |version_class|
    next unless version_class.const_defined?(:TableDefinition, false)
    t.singleton_class.prepend(version_class.const_get(:TableDefinition, false))
  end
  t
end

#create_join_table(table_1, table_2, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration.rb', line 595

def create_join_table(table_1, table_2, **options)
  if block_given?
    super { |t| yield compatible_table_definition(t) }
  else
    super
  end
end

#create_table(table_name, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration.rb', line 579

def create_table(table_name, **options)
  if block_given?
    super { |t| yield compatible_table_definition(t) }
  else
    super
  end
end

#drop_table(*table_names, **options)

[ GitHub ]

  
# File 'activerecord/lib/active_record/migration.rb', line 603

def drop_table(*table_names, **options)
  if block_given?
    super { |t| yield compatible_table_definition(t) }
  else
    super
  end
end