Improve the warning on leftover missing journals

pull/11230/head
Oliver Günther 2 years ago
parent 8f0067c8c2
commit 64e0252f71
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 34
      db/migrate/20220818074159_fix_deleted_data_journals.rb

@ -6,7 +6,7 @@ class FixDeletedDataJournals < ActiveRecord::Migration[7.0]
relation.find_each { |journal| fix_journal_data(journal) }
count = relation.count
raise "There shouldn't be any missing data left for #{journable_type}, but found #{count}" if count > 0
unfixed_journals_found(journable_type, relation, count) if count > 0
end
end
@ -14,6 +14,38 @@ class FixDeletedDataJournals < ActiveRecord::Migration[7.0]
# nothing to do
end
def unfixed_journals_found(journable_type, relation, count)
unless ENV['SKIP_MISSING_JOURNALS'] == 'true'
warning = <<~WARNING
There shouldn't be any missing data left for #{journable_type}, but found #{count}.
You can choose to ignore this error by setting the environment variable `SKIP_MISSING_JOURNALS=true`
and re-run the migration / configure step.
This will allow the migration to continue and print the affected journals.
Please report them to this bug ticket in our community: https://community.openproject.org/wp/43839
Aborting the migration at this point.
WARNING
raise warning
end
warning = ["SKIP_MISSING_JOURNALS was set to true."]
warning << "Please add the following output to the bug ticket in our community: https://community.openproject.org/wp/43839"
warning << "--- BEGIN ---"
relation.find_each do |journal|
warning << "Journal -> #{journal.inspect}"
warning << "Journable? -> #{journal.journable.inspect}"
warning << "Predecessor? -> #{journal.previous.inspect}"
warning << "Successor? -> #{journal.successor.inspect}"
end
warning << "--- END ---"
warn warning.join("\n")
end
def fix_journal_data(journal)
# Best case, no successor
# restore data from work package itself

Loading…
Cancel
Save