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