Sha256: f4ca8a3bd8da6c079444acf74d05574c253d3d5cec27f1a226f8a0344a7dc0cc
Contents?: true
Size: 1.3 KB
Versions: 75
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true class AddScopesForAllInitiativeTypes < ActiveRecord::Migration[5.1] class Scope < ApplicationRecord self.table_name = :decidim_scopes end class Organization < ApplicationRecord self.table_name = :decidim_organizations has_many :scopes, foreign_key: "decidim_organization_id", class_name: "Scope" end class InitiativesType < ApplicationRecord self.table_name = :decidim_initiatives_types belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Organization" end class InitiativesTypeScope < ApplicationRecord self.table_name = :decidim_initiatives_type_scopes end def up # This migrantion intent is simply to keep seed data at staging # environment consistent with the underlying data model. It is # not relevant for production environments. Organization.find_each do |organization| InitiativesType.where(organization: organization).find_each do |type| organization.scopes.each do |scope| InitiativesTypeScope.create( decidim_initiatives_types_id: type.id, decidim_scopes_id: scope.id, supports_required: 1000 ) end end end end def down Decidim::InitiativesTypeScope.destroy_all end end
Version data entries
75 entries across 75 versions & 1 rubygems