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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Warn if trying to migrate WikiContent broken journals
Oliver Günther2f8271451471
diff --git a/db/migrate/20220818074159_fix_deleted_data_journals.rb b/db/migrate/20220818074159_fix_deleted_data_journals.rbindex 45a5d784016..a33d8d6a278 100644--- a/db/migrate/20220818074159_fix_deleted_data_journals.rb+++ b/db/migrate/20220818074159_fix_deleted_data_journals.rb@@ -31,6 +31,33 @@ class FixDeletedDataJournals < ActiveRecord::Migration[7.0]get_missing_journals.each do |journable_type, relation|Rails.logger.debug { "Cleaning up journals on #{journable_type}" }+ if unmigratable_journal_classes.key?(journable_type) && relation.count > 0+ raise <<~ERROR+ We have found missing journal entries for the #{journable_type} model.++ Unfortunately, you cannot update directly to OpenProject #{OpenProject::VERSION.to_semver},+ as subsequent migrations are not yet processed for this model.++ To fix this issue, please try one of these options:++ Upgrade first to Openproject 13.0.0, and then to this version.++ ----++ Skip this migration by connecting to the database, and running the following SQL command:++ INSERT INTO schema_migrations (version) VALUES (20220818074159);++ Then, run this migration step again. It will skip this migration.++ Once migrated, remove this migration entry again by running this SQL command:++ DELETE FROM schema_migrations WHERE version='20220818074159';++ Then, run this migration step again. Only this skipped migration will be performed.+ ERROR+ end+relation.find_each { |journal| fix_journal_data(journal) }count = relation.count@@ -131,13 +158,18 @@ class FixDeletedDataJournals < ActiveRecord::Migration[7.0]# Lookup table for items that were already deleteddef lookup_journal_class_table(journable_type)- lookup = { "WikiContent" => %w[Journal::WikiContentJournal wiki_content_journals] }- lookup.fetch(journable_type) do+ unmigratable_journal_classes.fetch(journable_type) dojournal_class = journable_type.constantize.journal_class[journal_class.to_s, journal_class.table_name]endend+ def unmigratable_journal_classes+ {+ "WikiContent" => %w[Journal::WikiContentJournal wiki_content_journals]+ }+ end+def take_over_from_successor(journal)# The successors may also have their data deleted.# in this case, look for the first journal with data. If non can be found, instantiate from the journaled object.