Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20201112145311_add_index_on_sha_for_initial_deployments.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 15debddb9cceb11441e7fe796c244e27c032ba13 (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 AddIndexOnShaForInitialDeployments < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  NEW_INDEX_NAME = 'index_deployments_on_environment_status_sha'
  OLD_INDEX_NAME = 'index_deployments_on_environment_id_and_status'

  disable_ddl_transaction!

  def up
    add_concurrent_index :deployments, %i[environment_id status sha], name: NEW_INDEX_NAME
    remove_concurrent_index_by_name :deployments, OLD_INDEX_NAME
  end

  def down
    add_concurrent_index :deployments, %i[environment_id status], name: OLD_INDEX_NAME
    remove_concurrent_index_by_name :services, NEW_INDEX_NAME
  end
end