From 55080706ce5005e06805fbb662ce6edc5c48742d Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 13 May 2021 11:48:41 +0200 Subject: [PATCH] Convert geo_areas properties to jsonb --- ...316_use_jsonb_in_geo_areas_properties.rake | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/tasks/deployment/20210513093316_use_jsonb_in_geo_areas_properties.rake diff --git a/lib/tasks/deployment/20210513093316_use_jsonb_in_geo_areas_properties.rake b/lib/tasks/deployment/20210513093316_use_jsonb_in_geo_areas_properties.rake new file mode 100644 index 000000000..0f075cb6d --- /dev/null +++ b/lib/tasks/deployment/20210513093316_use_jsonb_in_geo_areas_properties.rake @@ -0,0 +1,22 @@ +namespace :after_party do + desc 'Deployment task: use_jsonb_in_geo_areas_properties' + task use_jsonb_in_geo_areas_properties: :environment do + puts "Running deploy task 'use_jsonb_in_geo_areas_properties'" + + geo_areas = GeoArea.where("properties::text LIKE ?", "%--- !ruby%") + progress = ProgressReport.new(geo_areas.count) + geo_areas.find_each do |geo_area| + geo_area.properties = geo_area.properties + if !geo_area.save + geo_area.destroy + end + 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