Sha256: 13a9405052d51b1a8e726527810b266fcaf759891abb58804d0cf75b6b6b52e4
Contents?: true
Size: 865 Bytes
Versions: 50
Compression:
Stored size: 865 Bytes
Contents
# frozen_string_literal: true class AddScopesToInitiativesVotes < ActiveRecord::Migration[5.2] class InitiativeVote < ApplicationRecord self.table_name = :decidim_initiatives_votes belongs_to :initiative, foreign_key: "decidim_initiative_id", class_name: "Initiative" end class Initiative < ApplicationRecord self.table_name = :decidim_initiatives belongs_to :scoped_type, class_name: "InitiativesTypeScope" end class InitiativesTypeScope < ApplicationRecord self.table_name = :decidim_initiatives_type_scopes end def change add_column :decidim_initiatives_votes, :decidim_scope_id, :integer InitiativeVote.reset_column_information InitiativeVote.includes(initiative: :scoped_type).find_each do |vote| vote.decidim_scope_id = vote.initiative.scoped_type.decidim_scopes_id vote.save! end end end
Version data entries
50 entries across 50 versions & 1 rubygems