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

class ModifyConcurrentIndexToBuildsMetadata < ActiveRecord::Migration[5.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :ci_builds_metadata, [:build_id],
                         where: "interruptible = true",
                         name: "index_ci_builds_metadata_on_build_id_and_interruptible"
    remove_concurrent_index_by_name(:ci_builds_metadata, 'index_ci_builds_metadata_on_build_id_and_interruptible_false')
  end

  def down
    remove_concurrent_index_by_name(:ci_builds_metadata, 'index_ci_builds_metadata_on_build_id_and_interruptible')
    add_concurrent_index :ci_builds_metadata, [:build_id],
                         where: "interruptible = false",
                         name: "index_ci_builds_metadata_on_build_id_and_interruptible_false"
  end
end