Class: ActiveRecord::Migration::Compatibility::V7_0

Inherits:
V7_1
  • Object
show all
Includes:
LegacyIndexName
Defined in:
lib/active_record/migration/compatibility.rb

Direct Known Subclasses

V6_1

Defined Under Namespace

Modules: LegacyIndexName, TableDefinition

Instance Method Summary collapse

Instance Method Details

#add_column(table_name, column_name, type, **options) ⇒ Object



100
101
102
103
# File 'lib/active_record/migration/compatibility.rb', line 100

def add_column(table_name, column_name, type, **options)
  options[:_skip_validate_options] = true
  super
end

#add_foreign_key(from_table, to_table, **options) ⇒ Object



148
149
150
151
152
153
# File 'lib/active_record/migration/compatibility.rb', line 148

def add_foreign_key(from_table, to_table, **options)
  if connection.adapter_name == "PostgreSQL" && options[:deferrable] == true
    options[:deferrable] = :immediate
  end
  super
end

#add_index(table_name, column_name, **options) ⇒ Object



105
106
107
108
# File 'lib/active_record/migration/compatibility.rb', line 105

def add_index(table_name, column_name, **options)
  options[:name] = legacy_index_name(table_name, column_name) if options[:name].nil?
  super
end

#add_reference(table_name, ref_name, **options) ⇒ Object Also known as: add_belongs_to



110
111
112
113
# File 'lib/active_record/migration/compatibility.rb', line 110

def add_reference(table_name, ref_name, **options)
  options[:_skip_validate_options] = true
  super
end

#change_column(table_name, column_name, type, **options) ⇒ Object



129
130
131
132
133
134
135
# File 'lib/active_record/migration/compatibility.rb', line 129

def change_column(table_name, column_name, type, **options)
  options[:_skip_validate_options] = true
  if connection.adapter_name == "Mysql2" || connection.adapter_name == "Trilogy"
    options[:collation] ||= :no_collation
  end
  super
end

#change_column_null(table_name, column_name, null, default = nil) ⇒ Object



137
138
139
# File 'lib/active_record/migration/compatibility.rb', line 137

def change_column_null(table_name, column_name, null, default = nil)
  super(table_name, column_name, !!null, default)
end

#create_table(table_name, **options) ⇒ Object



116
117
118
119
120
121
# File 'lib/active_record/migration/compatibility.rb', line 116

def create_table(table_name, **options)
  options[:_uses_legacy_table_name] = true
  options[:_skip_validate_options] = true

  super
end

#disable_extension(name, **options) ⇒ Object



141
142
143
144
145
146
# File 'lib/active_record/migration/compatibility.rb', line 141

def disable_extension(name, **options)
  if connection.adapter_name == "PostgreSQL"
    options[:force] = :cascade
  end
  super
end

#rename_table(table_name, new_name, **options) ⇒ Object



123
124
125
126
127
# File 'lib/active_record/migration/compatibility.rb', line 123

def rename_table(table_name, new_name, **options)
  options[:_uses_legacy_table_name] = true
  options[:_uses_legacy_index_name] = true
  super
end