summaryrefslogtreecommitdiff
path: root/db/post_migrate/20210616145254_add_partial_index_for_ci_builds_token.rb
blob: 6e169a6f0e1e1763975a0a4d406920a59a1f6504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class AddPartialIndexForCiBuildsToken < ActiveRecord::Migration[6.1]
  include Gitlab::Database::MigrationHelpers

  disable_ddl_transaction!

  NAME = 'index_ci_builds_on_token_partial'

  def up
    add_concurrent_index :ci_builds, :token, unique: true, where: 'token IS NOT NULL', name: NAME
  end

  def down
    remove_concurrent_index_by_name :ci_builds, NAME
  end
end