Sha256: 26ccfbfb2371095baa5157fc8152fdce77db4f94879560fbb3c1ccd8d769526a

Contents?: true

Size: 835 Bytes

Versions: 50

Compression:

Stored size: 835 Bytes

Contents

# frozen_string_literal: true

class AddUpcomingEventsAsContentBlock < 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
    Organization.find_each do |organization|
      next if ContentBlock.where(decidim_organization_id: organization.id).exists?(manifest_name: "upcoming_events")

      last_weight = ContentBlock.where(decidim_organization_id: organization.id).order("weight DESC").limit(1).pluck(:weight).last.to_i

      ContentBlock.create!(
        decidim_organization_id: organization.id,
        weight: last_weight,
        scope: :homepage,
        manifest_name: :upcoming_events,
        published_at: Time.current
      )
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.4 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.27.9 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.29.0 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.3 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.27.8 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.29.0.rc4 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.29.0.rc3 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.29.0.rc2 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.29.0.rc1 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.2 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.27.7 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.1 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.27.6 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.26.10 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.26.9 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.0 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.27.5 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.0.rc5 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb
decidim-meetings-0.28.0.rc4 db/migrate/20180809134748_add_upcoming_events_as_content_block.rb