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

class AddIndexOnExpiredUnlockedNonTraceJobArtifacts < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  INDEX_NAME = 'index_ci_job_artifacts_expire_at_unlocked_non_trace'

  def up
    add_concurrent_index :ci_job_artifacts, :expire_at,
      name: INDEX_NAME,
      where: 'locked = 0 AND file_type != 3 AND expire_at IS NOT NULL'
  end

  def down
    remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME
  end
end