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

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

class AddIndexOnNameAndIdToPublicGroups < Gitlab::Database::Migration[1.0]
  INDEX_NAME = 'index_namespaces_public_groups_name_id'
  PUBLIC_VISIBILITY_LEVEL = 20

  disable_ddl_transaction!

  def up
    add_concurrent_index :namespaces, [:name, :id],
                         name: INDEX_NAME,
                         where: "type = 'Group' AND visibility_level = #{PUBLIC_VISIBILITY_LEVEL}"
  end

  def down
    remove_concurrent_index_by_name :namespaces, INDEX_NAME
  end
end