summaryrefslogtreecommitdiff
path: root/db/migrate/20190802235445_add_index_on_id_and_type_and_public_to_keys.rb
blob: 9b4d74b4bea7cc28d1400ada764e96c4cbe703d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

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

  DOWNTIME = false

  disable_ddl_transaction!

  INDEX_NAME = "index_on_deploy_keys_id_and_type_and_public"

  def up
    add_concurrent_index(:keys,
                         [:id, :type],
                         where: "public = 't'",
                         unique: true,
                         name: INDEX_NAME)
  end

  def down
    remove_concurrent_index_by_name(:keys, INDEX_NAME)
  end
end