Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Ensure we reset column names when renaming timestamps

Oliver Günther1ca8ead75957
diff --git a/db/migrate/20201005184411_rename_timestamps.rb b/db/migrate/20201005184411_rename_timestamps.rb
index b9090bd746f..4e136ddddcb 100644
--- a/db/migrate/20201005184411_rename_timestamps.rb
+++ b/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)