Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20191206122926_update_index_for_pool_repositories.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f88e8e94ee158c74805aaace6aa12ddb42b951e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class UpdateIndexForPoolRepositories < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    # This index is less restrictive then the one we already have, no need to
    # update data.
    add_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true
    remove_concurrent_index :pool_repositories, :source_project_id
  end

  def down
    # Not adding this index as a unique one, since while the new index existed
    # we could have created multiple pool repositories for a project. In that
    # case this rollback would fail.
    add_concurrent_index :pool_repositories, :source_project_id
    remove_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true
  end
end