summaryrefslogtreecommitdiff
path: root/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb
blob: 5896102af1cbfb941ca5bc415184c7c1a79dcde5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class AddPartialIndexForLegacySuccessfulDeployments < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'partial_index_deployments_for_legacy_successful_deployments'.freeze

  disable_ddl_transaction!

  def up
    add_concurrent_index(:deployments, :id, where: "finished_at IS NULL AND status = 2", name: INDEX_NAME)
  end

  def down
    remove_concurrent_index_by_name(:deployments, INDEX_NAME)
  end
end