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

historic journables: prevent accessing column information on a non-migrated database

Sebastian Fiedlschuster7db3f9a39c6f
diff --git a/app/models/journable/timestamps.rb b/app/models/journable/timestamps.rb
index 2f66c02cdcb..53fb992c5b5 100644
--- a/app/models/journable/timestamps.rb
+++ b/app/models/journable/timestamps.rb
@@ -71,13 +71,15 @@ module Journable::Timestamps
end
prepended do
- column_names_missing_in_journal.each do |missing_column_name|
- define_method missing_column_name do
- if historic?
- Rails.logger.warn "Accessing missing column '#{missing_column_name}' on historic data. " \
- "The column is not present in the '#{self.class.journal_class.table_name}' table."
+ if ActiveRecord::Base.connected? and not ActiveRecord::Base.connection.migration_context.needs_migration?
+ column_names_missing_in_journal.each do |missing_column_name|
+ define_method missing_column_name do
+ if historic?
+ Rails.logger.warn "Accessing missing column '#{missing_column_name}' on historic data. " \
+ "The column is not present in the '#{self.class.journal_class.table_name}' table."
+ end
+ super()
end
- super()
end
end
end