From 0037abee5c6f42fcc3b72c99bb971e2f072a2840 Mon Sep 17 00:00:00 2001 From: ayuki_j <19406594+ayuki-joto@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:33:45 +0900 Subject: [PATCH] feat: add replace to null decidim_proposals command --- lib/tasks/replace_to_null.rake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/tasks/replace_to_null.rake b/lib/tasks/replace_to_null.rake index 108a2be30..0f224b79f 100644 --- a/lib/tasks/replace_to_null.rake +++ b/lib/tasks/replace_to_null.rake @@ -26,4 +26,16 @@ namespace :replace_to_null do end end end + + desc 'fix proposal edit bug.Make all "" columns of decidim_proposals_proposals table null' + task decidim_proposals: :environment do + Decidim::Proposals::Proposal.transaction do + Decidim::Proposals::Proposal.all.each do |proposal| + proposal.answer = nil if proposal.answer == "" + proposal.cost_report = nil if proposal.cost_report == "" + proposal.execution_period = nil if proposal.execution_period == "" + proposal.save! + end + end + end end