Sha256: fcde1944c7ea1e6e55ed06cfbd607777ce6ed0a0749b51763bf15b243987008a

Contents?: true

Size: 1.05 KB

Versions: 75

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

class AddSlugToDecidimConsultationsQuestions < ActiveRecord::Migration[5.1]
  class Question < ApplicationRecord
    self.table_name = :decidim_consultations_questions
  end

  def change
    add_column :decidim_consultations_questions,
               :decidim_organization_id,
               :integer,
               index: {
                 name: "index_decidim_questions_on_decidim_organization_id"
               }

    add_column :decidim_consultations_questions, :slug, :string

    Question.find_each do |question|
      question.decidim_organization_id = question.consultation.decidim_organization_id
      question.slug = "q-#{question.id}"
      question.save
    end

    change_column_null :decidim_consultations_questions, :decidim_organization_id, false
    change_column_null :decidim_consultations_questions, :slug, false

    add_index :decidim_consultations_questions,
              [:decidim_organization_id, :slug],
              name: "index_unique_question_slug_and_organization",
              unique: true
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
decidim-consultations-0.27.9 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.8 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.7 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.6 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.10 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.9 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.5 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.8 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.4 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.3 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.7 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.5 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.2 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.4 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.3 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.0.rc2 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.27.0.rc1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.26.2 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb