Sha256: 91ff55e27c3249d7190a76e37ed1232519a14c4697da9db05b6fb2c63d6cd61a

Contents?: true

Size: 719 Bytes

Versions: 44

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

class AddQuestionnaireToExistingElections < ActiveRecord::Migration[5.2]
  class Election < ApplicationRecord
    self.table_name = :decidim_elections_elections

    has_one :questionnaire,
            class_name: "Questionnaire",
            dependent: :destroy,
            inverse_of: :questionnaire_for,
            as: :questionnaire_for
  end

  class Questionnaire < ApplicationRecord
    self.table_name = :decidim_forms_questionnaires

    belongs_to :questionnaire_for, polymorphic: true
  end

  def change
    Election.find_each do |election|
      next unless election.questionnaire

      election.update!(
        questionnaire: Questionnaire.new
      )
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.9 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.28.3 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.8 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.28.2 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.7 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.28.1 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.6 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.26.10 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.26.9 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.28.0 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.5 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.28.0.rc5 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.28.0.rc4 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.26.8 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.4 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.3 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.26.7 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.26.5 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb
decidim-elections-0.27.2 db/migrate/20200915142713_add_questionnaire_to_existing_elections.rb