Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210723173132_create_index_on_environments_auto_delete_at.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cfaff4d030485f7c7ba53d5ae822538a91cf02fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

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

  disable_ddl_transaction!

  INDEX_NAME = 'index_environments_on_state_and_auto_delete_at'

  def up
    add_concurrent_index :environments,
      %i[auto_delete_at],
      where: "auto_delete_at IS NOT NULL AND state = 'stopped'",
      name: INDEX_NAME
  end

  def down
    remove_concurrent_index_by_name :environments, INDEX_NAME
  end
end