Module: OnlineMigrations::SchemaCache72

Defined in:
lib/online_migrations/schema_cache.rb

Instance Method Summary collapse

Instance Method Details

#clear_data_source_cache!(pool, name) ⇒ Object



196
197
198
199
200
201
202
203
204
205
206
# File 'lib/online_migrations/schema_cache.rb', line 196

def clear_data_source_cache!(pool, name)
  if (renamed_table = renamed_table?(pool, name))
    super(pool, renamed_table)
  end

  if renamed_column?(pool, name)
    super(pool, column_rename_table(name))
  end

  super
end

#columns(pool, table_name) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/online_migrations/schema_cache.rb', line 172

def columns(pool, table_name)
  if (renamed_table = renamed_table?(pool, table_name))
    super(pool, renamed_table)
  elsif renamed_column?(pool, table_name)
    columns = super(pool, column_rename_table(table_name))
    OnlineMigrations.config.column_renames[table_name].each do |old_column_name, new_column_name|
      duplicate_column(old_column_name, new_column_name, columns)
    end
    columns
  else
    super.reject { |column| column.name.end_with?("_for_type_change") }
  end
end

#indexes(pool, table_name) ⇒ Object



186
187
188
189
190
191
192
193
194
# File 'lib/online_migrations/schema_cache.rb', line 186

def indexes(pool, table_name)
  if (renamed_table = renamed_table?(pool, table_name))
    super(pool, renamed_table)
  elsif renamed_column?(pool, table_name)
    super(pool, column_rename_table(table_name))
  else
    super
  end
end

#primary_keys(pool, table_name) ⇒ Object

Active Record >= 7.2 changed signature of the methods, see github.com/rails/rails/pull/48716.



162
163
164
165
166
167
168
169
170
# File 'lib/online_migrations/schema_cache.rb', line 162

def primary_keys(pool, table_name)
  if (renamed_table = renamed_table?(pool, table_name))
    super(pool, renamed_table)
  elsif renamed_column?(pool, table_name)
    super(pool, column_rename_table(table_name))
  else
    super
  end
end