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

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

class AddIndexGroupIdToServices < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'index_services_on_unique_group_id_and_type'

  disable_ddl_transaction!

  def up
    add_concurrent_index :services, [:group_id, :type], unique: true, name: INDEX_NAME

    add_concurrent_foreign_key :services, :namespaces, column: :group_id
  end

  def down
    remove_foreign_key_if_exists :services, column: :group_id

    remove_concurrent_index_by_name :services, INDEX_NAME
  end
end