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

class DropPartialIndexDeploymentsForProjectIdAndTag < Gitlab::Database::Migration[2.1]
  INDEX_NAME = 'partial_index_deployments_for_project_id_and_tag'

  disable_ddl_transaction!

  def up
    remove_concurrent_index_by_name :deployments, name: INDEX_NAME
  end

  def down
    # This is based on the following `CREATE INDEX` command in db/init_structure.sql:
    # CREATE INDEX partial_index_deployments_for_project_id_and_tag ON deployments
    #   USING btree (project_id) WHERE (tag IS TRUE);
    add_concurrent_index :deployments, :project_id, name: INDEX_NAME, where: 'tag IS TRUE'
  end
end