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.23.3 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.23.2 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.23.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.23.1.rc1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.23.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.22.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.21.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.20.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.20.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.19.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.18.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.19.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.17.2 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.18.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.17.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.16.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.17.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.16.0 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.15.2 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb
decidim-consultations-0.15.1 db/migrate/20180115170933_add_slug_to_decidim_consultations_questions.rb