2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-01-12 20:00:59 +01:00
|
|
|
namespace :after_party do
|
|
|
|
desc 'Deployment task: moving Attestations from Procedure to ProcedureRevision'
|
|
|
|
task revise_attestation_templates: :environment do
|
|
|
|
rake_puts "Running deploy task 'revise_attestation_templates'"
|
|
|
|
|
2022-01-26 18:27:57 +01:00
|
|
|
revisions = ProcedureRevision
|
2022-02-11 08:45:16 +01:00
|
|
|
.joins(procedure: :legacy_attestation_template)
|
2022-01-26 18:27:57 +01:00
|
|
|
.where(attestation_template_id: nil)
|
|
|
|
|
|
|
|
progress = ProgressReport.new(revisions.count)
|
|
|
|
|
|
|
|
revisions.find_each do |revision|
|
2022-02-11 08:45:16 +01:00
|
|
|
attestation_template_id = revision.procedure.legacy_attestation_template.id
|
2022-01-26 18:27:57 +01:00
|
|
|
revision.update_column(:attestation_template_id, attestation_template_id)
|
2022-01-12 20:00:59 +01:00
|
|
|
|
|
|
|
progress.inc
|
|
|
|
end
|
|
|
|
progress.finish
|
|
|
|
|
|
|
|
# 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
|