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

20230522162742_cleanup_bigint_conversion_for_merge_request_metrics_for_self_hosts.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e56f8486f1ef5867161893951f432ffcef55361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

class CleanupBigintConversionForMergeRequestMetricsForSelfHosts < Gitlab::Database::Migration[2.1]
  include Gitlab::Database::MigrationHelpers::ConvertToBigint

  enable_lock_retries!

  TABLE = :merge_request_metrics

  def up
    return if should_skip?
    return unless column_exists?(TABLE, :id_convert_to_bigint)

    # rubocop:disable Migration/WithLockRetriesDisallowedMethod
    with_lock_retries do
      cleanup_conversion_of_integer_to_bigint(TABLE, :id)
    end
    # rubocop:enable Migration/WithLockRetriesDisallowedMethod
  end

  def down
    return if should_skip?
    return if column_exists?(TABLE, :id_convert_to_bigint)

    restore_conversion_of_integer_to_bigint(TABLE, :id)
  end

  def should_skip?
    com_or_dev_or_test_but_not_jh?
  end
end