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



95
96
97
98
# File 'lib/active_record/migration/compatibility.rb', line 95

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



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

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



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

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



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

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

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



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

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



132
133
134
# File 'lib/active_record/migration/compatibility.rb', line 132

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



111
112
113
114
115
116
# File 'lib/active_record/migration/compatibility.rb', line 111

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

  super
end

#disable_extension(name, **options) ⇒ Object



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

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

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



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

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