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.26.1 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.26.0 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.26.0.rc2 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.26.0.rc1 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.2 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.1 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.0 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.0.rc4 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.0.rc3 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.0.rc2 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.25.0.rc1 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.24.3 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.23.6 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.24.2 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.23.5 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.24.1 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.24.0 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.24.0.rc2 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.23.4 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb
decidim-consultations-0.24.0.rc1 db/migrate/20180130142411_rename_vote_indexes_to_endorsement_indexes.rb