Sha256: 90530eea87ad3d98b2eb0346584ed4bb89c0c173e2b5ecf609c8b706f3bfff41

Contents?: true

Size: 1.29 KB

Versions: 75

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

class RenameVoteIndexesToEndorsementIndexes < ActiveRecord::Migration[5.1]
  def change
    rename_index :decidim_consultations_endorsements,
                 :index_consultations_votes_on_author,
                 :index_consultations_endorsements_on_author

    rename_index :decidim_consultations_endorsements,
                 :index_consultations_votes_on_consultation_question,
                 :index_consultations_endorsements_on_consultation_question

    reversible do |dir|
      dir.up { create_authorable_unique }
      dir.down { create_author_unique }
    end
  end

  def create_authorable_unique
    remove_index :decidim_consultations_endorsements, name: "index_question_votes_author_unique"

    add_index :decidim_consultations_endorsements,
              %w(decidim_consultation_question_id decidim_author_id decidim_user_group_id),
              name: "index_question_votes_author_unique",
              unique: true
  end

  def create_author_unique
    remove_index :decidim_consultations_endorsements, name: "index_question_votes_author_unique"

    add_index :decidim_consultations_endorsements,
              %w(decidim_consultation_question_id decidim_author_id),
              name: "index_question_votes_author_unique",
              unique: true
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

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