summaryrefslogtreecommitdiff
path: root/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb
blob: c01335767a8b659e98135a96aa79493515b6e2f8 (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 AddCreatorIdToCustomEmoji < ActiveRecord::Migration[6.0]
  DOWNTIME = false

  def up
    # Custom Emoji is at the moment behind a default-disabled feature flag. It
    # will be unlikely there are any records in this table, but to able to
    # ensure a not-null constraint delete any existing rows.
    # Roll-out issue: https://gitlab.com/gitlab-org/gitlab/-/issues/231317
    execute 'DELETE FROM custom_emoji'

    add_reference :custom_emoji, # rubocop:disable Migration/AddReference
                  :creator,
                  index: true,
                  null: false, # rubocop:disable Rails/NotNullColumn
                  foreign_key: false # FK is added in 20210219100137
  end

  def down
    remove_reference :custom_emoji, :creator
  end
end