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

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

  DOWNTIME = false

  disable_ddl_transaction!

  NEW_INDEX_NAME = 'idx_packages_build_infos_on_package_id'
  OLD_INDEX_NAME = 'index_packages_build_infos_on_package_id'

  def up
    add_concurrent_index :packages_build_infos, :package_id, name: NEW_INDEX_NAME
    remove_concurrent_index_by_name :packages_build_infos, OLD_INDEX_NAME
  end

  def down
    # No op. It is possible records would validate the UNIQUE constraint, so it
    # cannot be added back to the index.
  end
end