summaryrefslogtreecommitdiff
path: root/db/post_migrate/20230322151635_cleanup_bigint_conversion_for_merge_request_metrics.rb
blob: d3ff224dbd7db4da66818234cf0557456a436212 (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
# frozen_string_literal: true

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

  disable_ddl_transaction!

  TABLE = :merge_request_metrics

  def up
    return unless should_run?

    # 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 unless should_run?

    restore_conversion_of_integer_to_bigint(TABLE, :id)
  end

  def should_run?
    com_or_dev_or_test_but_not_jh?
  end
end