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

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

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    remove_concurrent_index_by_name(:issue_links, 'tmp_idx_blocking_type_links')
    remove_concurrent_index_by_name(:issue_links, 'tmp_idx_blocked_by_type_links')
    remove_concurrent_index_by_name(:issues, 'tmp_idx_index_issues_with_outdate_blocking_count')
  end

  def down
    add_concurrent_index :issue_links, [:source_id], where: 'link_type = 1', name: 'tmp_idx_blocking_type_links'
    add_concurrent_index :issue_links, [:target_id], where: 'link_type = 2', name: 'tmp_idx_blocked_by_type_links'
    add_concurrent_index :issues, :id, where: '(state_id = 1 AND blocking_issues_count = 0)', name: 'tmp_idx_index_issues_with_outdate_blocking_count'
  end
end