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

20160616103005_remove_keys_fingerprint_index_if_exists.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 081df23f394dd400d8aa8c5ecf69f0f1c1d09909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# rubocop:disable RemoveIndex
class RemoveKeysFingerprintIndexIfExists < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  disable_ddl_transaction!

  # https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/250
  # That MR was added on gitlab-ee so we need to check if the index
  # already exists because we want to do is create an unique index instead.

  def up
    if index_exists?(:keys, :fingerprint)
      remove_index :keys, :fingerprint
    end
  end

  def down
    unless index_exists?(:keys, :fingerprint)
      add_concurrent_index :keys, :fingerprint
    end
  end
end