Sha256: 9248123c950a494d381eee099336b7cfe32c9e4065db1b5f0e71fc2f869411a7

Contents?: true

Size: 1.17 KB

Versions: 31

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

class MoveOrganizationFieldsToHeroContentBlock < ActiveRecord::Migration[5.2]
  # This migration made use CarrierWave, which in future will be eliminated.
  # The organization homepage image was moved to the content block background
  # image using CarrierWave. This operation has been removed, so if there is
  # an existing homepage image previous to this migration the content block
  # background image should be loaded manually
  class Organization < ApplicationRecord
    self.table_name = :decidim_organizations
  end

  def change
    Decidim::ContentBlock.reset_column_information
    Organization.find_each do |organization|
      content_block = Decidim::ContentBlock.find_by(organization: organization, scope: :homepage, manifest_name: :hero)
      settings = {}
      welcome_text = organization.welcome_text || {}
      settings = welcome_text.inject(settings) { |acc, (k, v)| acc.update("welcome_text_#{k}" => v) }

      content_block.settings = settings
      content_block.settings_will_change!
      content_block.save!
    end

    remove_column :decidim_organizations, :welcome_text
    remove_column :decidim_organizations, :homepage_image
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-core-0.27.9 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.8 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.7 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.6 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.10 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.9 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.5 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.8 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.4 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.3 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.7 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.5 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.2 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.1 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.4 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.0 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.3 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.0.rc2 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.27.0.rc1 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb
decidim-core-0.26.2 db/migrate/20180810092428_move_organization_fields_to_hero_content_block.rb