Class: ActiveRecord::Migration::Compatibility::V5_0
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Namespace Children | |
|
Modules:
| |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
self,
V5_1,
V5_2,
V6_0,
V6_1,
V7_0,
V7_0::LegacyIndexName,
V7_1,
V7_2,
V8_0,
V8_0::RemoveForeignKeyColumnMatch,
V8_1,
::ActiveRecord::Migration::Current,
Migration
|
|
| Inherits: |
ActiveRecord::Migration::Compatibility::V5_1
|
| Defined in: | activerecord/lib/active_record/migration/compatibility.rb |
Instance Method Summary
-
#add_belongs_to(table_name, ref_name, **options)
Alias for #add_reference.
- #add_column(table_name, column_name, type, **options)
- #add_reference(table_name, ref_name, **options) (also: #add_belongs_to)
- #create_join_table(table_1, table_2, column_options: {}, **options)
- #create_table(table_name, **options)
- #compatible_table_definition(t) private
V5_1 - Inherited
V5_2 - Inherited
V6_0 - Inherited
V6_1 - Inherited
V7_0 - Inherited
V7_0::LegacyIndexName - Included
V8_0 - Inherited
V8_0::RemoveForeignKeyColumnMatch - Included
::ActiveRecord::Migration::Current - Inherited
Instance Method Details
#add_belongs_to(table_name, ref_name, **options)
Alias for #add_reference.
# File 'activerecord/lib/active_record/migration/compatibility.rb', line 422
alias :add_belongs_to :add_reference
#add_column(table_name, column_name, type, **options)
[ GitHub ]# File 'activerecord/lib/active_record/migration/compatibility.rb', line 409
def add_column(table_name, column_name, type, **) if type == :primary_key type = :integer [:primary_key] = true elsif type == :datetime [:precision] ||= nil end super end
#add_reference(table_name, ref_name, **options) Also known as: #add_belongs_to
[ GitHub ]# File 'activerecord/lib/active_record/migration/compatibility.rb', line 419
def add_reference(table_name, ref_name, **) super(table_name, ref_name, type: :integer, **) end
#compatible_table_definition(t) (private)
[ GitHub ]# File 'activerecord/lib/active_record/migration/compatibility.rb', line 425
def compatible_table_definition(t) t.singleton_class.prepend(TableDefinition) super end
#create_join_table(table_1, table_2, column_options: {}, **options)
[ GitHub ]# File 'activerecord/lib/active_record/migration/compatibility.rb', line 404
def create_join_table(table_1, table_2, column_options: {}, **) .reverse_merge!(type: :integer) super end
#create_table(table_name, **options)
[ GitHub ]# File 'activerecord/lib/active_record/migration/compatibility.rb', line 381
def create_table(table_name, **) if connection.adapter_name == "PostgreSQL" if [:id] == :uuid && !.key?(:default) [:default] = "uuid_generate_v4()" end end unless ["Mysql2", "Trilogy"].include?(connection.adapter_name) && [:id] == :bigint if [:integer, :bigint].include?([:id]) && !.key?(:default) [:default] = nil end end # Since 5.1 PostgreSQL adapter uses bigserial type for primary # keys by default and MySQL uses bigint. This compat layer makes old migrations utilize # serial/int type instead -- the way it used to work before 5.1. unless .key?(:id) [:id] = :integer end super end