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

20230529182720_recreate_billable_index.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e56dd7005a60d32da3ef09bc987e75e5914b54b (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 RecreateBillableIndex < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  INDEX_NAME = "index_users_for_active_billable_users"

  def up
    remove_concurrent_index_by_name :users, INDEX_NAME

    add_concurrent_index :users, :id, name: INDEX_NAME,
      where: "state = 'active' AND (user_type IN (0, 6, 4, 13)) AND (user_type IN (0, 4, 5))"
  end

  def down
    remove_concurrent_index_by_name :users, INDEX_NAME

    add_concurrent_index :users, :id, name: INDEX_NAME,
      where: "state = 'active' AND (user_type IS NULL OR user_type IN (6, 4, 13)) " \
             "AND (user_type IS NULL OR user_type IN (4, 5))"
  end
end