summaryrefslogtreecommitdiff
path: root/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb')
-rw-r--r--db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb b/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb
new file mode 100644
index 00000000000..c01335767a8
--- /dev/null
+++ b/db/migrate/20210205134213_add_creator_id_to_custom_emoji.rb
@@ -0,0 +1,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