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

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

  DOWNTIME = false
  INDEX_NAME = 'index_successful_deployments_on_cluster_id_and_environment_id'

  disable_ddl_transaction!

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

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