Class: ActiveRecord::Migration::Compatibility::V5_0
- Inherits:
-
V5_1
- Object
- V6_0
- V5_2
- V5_1
- ActiveRecord::Migration::Compatibility::V5_0
show all
- Defined in:
- lib/active_record/migration/compatibility.rb
Direct Known Subclasses
V4_2
Defined Under Namespace
Modules: TableDefinition
Instance Method Summary
collapse
Methods inherited from V5_1
#change_column
Methods inherited from V5_2
#add_timestamps, #change_table
Methods inherited from V6_0
#change_table
Instance Method Details
#add_column(table_name, column_name, type, **options) ⇒ Object
225
226
227
228
229
230
231
|
# File 'lib/active_record/migration/compatibility.rb', line 225
def add_column(table_name, column_name, type, **options)
if type == :primary_key
type = :integer
options[:primary_key] = true
end
super
end
|
#add_reference(table_name, ref_name, **options) ⇒ Object
Also known as:
add_belongs_to
233
234
235
|
# File 'lib/active_record/migration/compatibility.rb', line 233
def add_reference(table_name, ref_name, **options)
super(table_name, ref_name, type: :integer, **options)
end
|
#create_join_table(table_1, table_2, column_options: {}, **options) ⇒ Object
220
221
222
223
|
# File 'lib/active_record/migration/compatibility.rb', line 220
def create_join_table(table_1, table_2, column_options: {}, **options)
column_options.reverse_merge!(type: :integer)
super
end
|
#create_table(table_name, **options) ⇒ Object
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/active_record/migration/compatibility.rb', line 197
def create_table(table_name, **options)
if connection.adapter_name == "PostgreSQL"
if options[:id] == :uuid && !options.key?(:default)
options[:default] = "uuid_generate_v4()"
end
end
unless connection.adapter_name == "Mysql2" && options[:id] == :bigint
if [:integer, :bigint].include?(options[:id]) && !options.key?(:default)
options[:default] = nil
end
end
unless options.key?(:id)
options[:id] = :integer
end
super
end
|