Class: ActiveRecord::Migration::Compatibility::V4_2

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

Defined Under Namespace

Modules: TableDefinition

Instance Method Summary collapse

Methods inherited from V5_0

#create_join_table

Instance Method Details

#add_reference(**options) ⇒ Object Also known as: add_belongs_to



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

def add_reference(*, **options)
  options[:index] ||= false
  super
end

#add_timestamps(_, **options) ⇒ Object



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

def add_timestamps(_, **options)
  options[:null] = true if options[:null].nil?
  super
end

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



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

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

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



103
104
105
106
107
108
109
110
111
# File 'lib/active_record/migration/compatibility.rb', line 103

def create_table(table_name, options = {})
  if block_given?
    super do |t|
      yield compatible_table_definition(t)
    end
  else
    super
  end
end

#index_exists?(table_name, column_name, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


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

def index_exists?(table_name, column_name, options = {})
  column_names = Array(column_name).map(&:to_s)
  options[:name] =
    if options[:name].present?
      options[:name].to_s
    else
      index_name(table_name, column: column_names)
    end
  super
end

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



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

def remove_index(table_name, options = {})
  options = { column: options } unless options.is_a?(Hash)
  options[:name] = index_name_for_remove(table_name, options)
  super(table_name, options)
end