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



97
98
99
100
# File 'lib/active_record/migration/compatibility.rb', line 97

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



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

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



102
103
104
105
# File 'lib/active_record/migration/compatibility.rb', line 102

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



107
108
109
110
# File 'lib/active_record/migration/compatibility.rb', line 107

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

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



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

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



134
135
136
# File 'lib/active_record/migration/compatibility.rb', line 134

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



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

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

  super
end

#disable_extension(name, **options) ⇒ Object



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

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

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



120
121
122
123
124
# File 'lib/active_record/migration/compatibility.rb', line 120

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