remove virtual column attribute from procedure_presentation data

This commit is contained in:
simon lehericey 2024-09-13 10:20:59 +02:00
parent d8a0adc6ed
commit eddbe77c09
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
namespace :after_party do
desc 'Deployment task: clean_virtual_column_from_procedure_presentation'
task clean_virtual_column_from_procedure_presentation: :environment do
ids = ProcedurePresentation.where("jsonb_typeof(displayed_fields) = 'array' AND EXISTS ( select 1 from jsonb_array_elements(displayed_fields) AS element where element ? 'virtual')").ids
progress = ProgressReport.new(ids.count)
ProcedurePresentation.where(id: ids).find_each do |procedure_presentation|
procedure_presentation.displayed_fields = procedure_presentation.displayed_fields.map do |field|
field.except('virtual')
end
procedure_presentation.save!(validate: false)
progress.inc
end
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end