Sha256: daa51b289af3d5b0820ca31a50b501edaf68cb69d9f5f0af758302e4ead8ed86

Contents?: true

Size: 756 Bytes

Versions: 13

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

class AddCoreContentBlocks < ActiveRecord::Migration[5.2]
  class Organization < ApplicationRecord
    self.table_name = :decidim_organizations
  end

  class ContentBlock < ApplicationRecord
    self.table_name = :decidim_content_blocks
  end

  def change
    default_blocks = Decidim.content_blocks.for(:homepage).select(&:default)

    Organization.pluck(:id).each do |organization_id|
      default_blocks.each_with_index do |manifest, index|
        weight = (index + 1) * 10
        ContentBlock.create(
          decidim_organization_id: organization_id,
          weight:,
          scope: :homepage,
          manifest_name: manifest.name,
          published_at: Time.current
        )
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.4 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.29.0 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.3 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.29.0.rc4 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.29.0.rc3 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.29.0.rc2 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.29.0.rc1 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.2 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.1 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.0 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.0.rc5 db/migrate/20180730071851_add_core_content_blocks.rb
decidim-core-0.28.0.rc4 db/migrate/20180730071851_add_core_content_blocks.rb