20191206122926_update_index_for_pool_repositories.rb 837 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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
18
19
20
    # 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.
21
    add_concurrent_index :pool_repositories, :source_project_id
22
    remove_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true
23
24
  end
end