Ensure we reset column names when renaming timestamps

pull/10161/head
Oliver Günther 3 years ago
parent 388bd45c07
commit 1ca8ead759
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 9
      db/migrate/20201005184411_rename_timestamps.rb

@ -36,6 +36,15 @@ class RenameTimestamps < ActiveRecord::Migration[6.0]
rename_column table, old_column_name, new_column_name
change_column_default table, new_column_name, from: nil, to: -> { 'CURRENT_TIMESTAMP' }
# Ensure we reset column information because otherwise,
# +updated_on+ will still be used.
begin
cls = table.to_s.singularize.classify.constantize
cls.reset_column_information
rescue StandardError => e
warn "Could not reset_column_information for table #{table}: #{e.message}"
end
end
def add_timestamp_column(table, column_name, from_column = nil)

Loading…
Cancel
Save