Merge pull request #9061 from colinux/fix-procedure-revision-draft-active-mismatch

fix(revision): backfill missing published_at on published revisions
This commit is contained in:
Colin Darie 2023-05-16 17:50:31 +00:00 committed by GitHub
commit 57ef6fe48d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,18 @@
namespace :after_party do
desc 'Deployment task: fix_procedure_revision_publiee_without_published_at'
task fix_procedure_revision_publiee_without_published_at: :environment do
puts "Running deploy task 'fix_procedure_revision_publiee_without_published_at'"
Procedure.unscoped.publiees_ou_closes.includes(:published_revision).find_each do |procedure| # rubocop:disable DS/Unscoped
next unless procedure.published_revision.published_at.nil?
rake_puts "Found Procedure##{procedure.id}, set published_at on published revision ##{procedure.published_revision.id}: #{procedure.published_at}"
procedure.published_revision.update!(published_at: procedure.published_at)
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end