Module: OnlineMigrations::SchemaCache71

Defined in:
lib/online_migrations/schema_cache.rb

Instance Method Summary collapse

Instance Method Details

#clear_data_source_cache!(connection, name) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/online_migrations/schema_cache.rb', line 118

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

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

  super
end

#columns(connection, table_name) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/online_migrations/schema_cache.rb', line 94

def columns(connection, table_name)
  if (renamed_table = renamed_table?(connection, table_name))
    super(connection, renamed_table)
  elsif renamed_column?(connection, table_name)
    columns = super(connection, 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(connection, table_name) ⇒ Object



108
109
110
111
112
113
114
115
116
# File 'lib/online_migrations/schema_cache.rb', line 108

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

#primary_keys(connection, table_name) ⇒ Object

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



84
85
86
87
88
89
90
91
92
# File 'lib/online_migrations/schema_cache.rb', line 84

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