Sha256: 97c1e477d53efea059ed8c49e116be13b0ee6e5af217dd40fd65e1bd5d31446a
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true class LausanneVotesEnabledToVotesChoices < ActiveRecord::Migration[5.2] class Component < ApplicationRecord self.table_name = :decidim_components end def up budget_components.each do |component| steps = component["settings"] && component["settings"]["steps"] default_step = component["settings"] && component["settings"]["default_step"] if steps.present? new_steps_settings = component["settings"]["steps"].each_with_object({}) do |(step, config), new_config| votes_value = config["votes_enabled"] ? "enabled" : "disabled" new_config[step] = config.merge("votes": votes_value).except("votes_enabled") new_config end component["settings"]["steps"] = new_steps_settings component.save! elsif default_step.present? votes_value = component["settings"]["default_step"]["votes_enabled"] ? "enabled" : "disabled" new_default_step_settings = component["settings"]["default_step"].merge("votes": votes_value).except("votes_enabled") component["settings"]["default_step"] = new_default_step_settings component.save! end end end def budget_components @budget_components ||= Component.where(manifest_name: "lausanne_budgets") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-lausanne-budgets-0.1.0 | db/migrate/20200804175222_lausanne_votes_enabled_to_votes_choices.rb |