summaryrefslogtreecommitdiff
path: root/db/migrate/20201211042306_add_deployments_finder_by_finished_at_index.rb
blob: f937ff7a4368c9a88026c697f7d8c24c03be210b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

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

  DOWNTIME = false
  INDEX_NAME = "index_deployments_on_project_and_finished"

  disable_ddl_transaction!

  def up
    add_concurrent_index :deployments,
      [:project_id, :finished_at],
      where: 'status = 2',
      name: INDEX_NAME
  end

  def down
    remove_concurrent_index :deployments,
      [:project_id, :finished_at],
      where: 'status = 2',
      name: INDEX_NAME
  end
end