summaryrefslogtreecommitdiff
path: root/db/post_migrate/20210901044202_push_event_payloads_bigint_conversion_remove_triggers.rb
blob: e11f0d465635c14ca3d705e8c401574822bacf18 (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
# frozen_string_literal: true

class PushEventPayloadsBigintConversionRemoveTriggers < ActiveRecord::Migration[6.1]
  include Gitlab::Database::MigrationHelpers

  disable_ddl_transaction!

  TABLE_NAME = :push_event_payloads
  TRIGGER_NAME = 'trigger_07c94931164e'

  # rubocop:disable Migration/WithLockRetriesDisallowedMethod
  def up
    check_trigger_permissions!(TABLE_NAME)

    with_lock_retries do
      remove_rename_triggers(TABLE_NAME, TRIGGER_NAME)
    end
  end

  def down
    check_trigger_permissions!(TABLE_NAME)

    with_lock_retries do
      install_rename_triggers(TABLE_NAME, :event_id, :event_id_convert_to_bigint, trigger_name: TRIGGER_NAME)
    end
  end
  # rubocop:enable Migration/WithLockRetriesDisallowedMethod
end