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

Inherits:
V7_1
  • Object
show all
Includes:
LegacyIndexName
Defined in:
activerecord/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



88
89
90
91
# File 'activerecord/lib/active_record/migration/compatibility.rb', line 88

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

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



93
94
95
96
# File 'activerecord/lib/active_record/migration/compatibility.rb', line 93

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

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



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

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

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



130
131
132
# File 'activerecord/lib/active_record/migration/compatibility.rb', line 130

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

#change_table(table_name, **options) ⇒ Object



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

def change_table(table_name, **options)
  if block_given?
    super { |t| yield compatible_table_definition(t) }
  else
    super
  end
end

#create_table(table_name, **options) ⇒ Object



98
99
100
101
102
103
104
105
106
107
# File 'activerecord/lib/active_record/migration/compatibility.rb', line 98

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

  if block_given?
    super { |t| yield compatible_table_definition(t) }
  else
    super
  end
end

#disable_extension(name, **options) ⇒ Object



134
135
136
137
138
139
# File 'activerecord/lib/active_record/migration/compatibility.rb', line 134

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

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



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

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