Class: ActiveRecord::Migration::Compatibility::V5_1

Inherits:
V5_2
  • Object
show all
Defined in:
lib/active_record/migration/compatibility.rb

Direct Known Subclasses

V5_0

Instance Method Summary collapse

Instance Method Details

#change_column(table_name, column_name, type, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/active_record/migration/compatibility.rb', line 19

def change_column(table_name, column_name, type, options = {})
  if adapter_name == "PostgreSQL"
    clear_cache!
    sql = connection.send(:change_column_sql, table_name, column_name, type, options)
    execute "ALTER TABLE #{quote_table_name(table_name)} #{sql}"
    change_column_default(table_name, column_name, options[:default]) if options.key?(:default)
    change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)
    change_column_comment(table_name, column_name, options[:comment]) if options.key?(:comment)
  else
    super
  end
end

#create_table(table_name, options = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/active_record/migration/compatibility.rb', line 32

def create_table(table_name, options = {})
  if adapter_name == "Mysql2"
    super(table_name, options: "ENGINE=InnoDB", **options)
  else
    super
  end
end