summaryrefslogtreecommitdiff
path: root/db/migrate/20210219100137_add_creator_foreign_key_to_custom_emoji.rb
blob: a954ba5ba3be2895cc3a7ae5f5c32be41d3ee8e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

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

  DOWNTIME = false
  FK_NAME = 'fk_custom_emoji_creator_id'

  disable_ddl_transaction!

  def up
    add_concurrent_foreign_key :custom_emoji, :users,
                               on_delete: :cascade,
                               column: :creator_id,
                               name: FK_NAME
  end

  def down
    with_lock_retries do
      remove_foreign_key :custom_emoji, name: FK_NAME
    end
  end
end