summaryrefslogtreecommitdiff
path: root/db/migrate/20200811055018_remove_not_null_constraint_on_type_from_audit_events.rb
blob: 25c3ef716556b3b21cd3c836217d8e42b31fcea7 (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
# frozen_string_literal: true

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

  DOWNTIME = false

  disable_ddl_transaction!

  # To avoid deadlock on audit_event and audit_event_part... since there is a trigger to insert record from audit_events
  # to audit_events_part..., we need to ensure each ALTER TABLE command run in its own transaction.
  def up
    with_lock_retries do
      change_column_null :audit_events_part_5fc467ac26, :type, true
    end

    with_lock_retries do
      change_column_null :audit_events, :type, true
    end
  end

  def down
    # no-op -- null values might be added after this constraint is removed.
  end
end