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

20200831074356_validate_not_null_constraint_on_mr_metrics.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8fd54186db327da20a7d8ab4bf722fcf4b5759d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

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

  TMP_INDEX_NAME = 'tmp_index_on_mr_metrics_target_project_id_null'
  DOWNTIME = false

  disable_ddl_transaction!

  def up
    validate_not_null_constraint :merge_request_metrics, :target_project_id

    remove_concurrent_index_by_name :merge_request_metrics, name: TMP_INDEX_NAME
  end

  def down
    add_concurrent_index :merge_request_metrics, :id, where: 'target_project_id IS NULL', name: TMP_INDEX_NAME
  end
end