summaryrefslogtreecommitdiff
path: root/db/migrate/20200912193210_add_scheduling_issues_temp_indexes.rb
blob: bc2b8d4ce97272620dab60754d3a626d7d7c8b94 (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 AddSchedulingIssuesTempIndexes < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    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

  def down
    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
end