You need to sign in or sign up before continuing.
Clean up schema for table award_emoji
From https://gitlab.com/gitlab-com/infrastructure/issues/1709 (private to GitLab employees):
- Wrong data type: created_at should be timestamptz
- Wrong data type: updated_at should be timestamptz
- Missing constraint: created_at NOT NULL
- Missing constraint: updated_at NOT NULL
- Missing constraint: name NOT NULL
- Missing constraint: user_id NOT NULL
- Missing constraint: awardable_type NOT NULL
- Missing constraint: awardable_id NOT NULL
- Missing FK: user_id -> users (6 entries violate this rule)
- "Polymorphic" table prevents regular FKs, use triggers or change to independent columns or non-polymorphic tables
- Break this up into separate ID columns for every awardable_type
-
Index over (awardable_type, awardable_id) should really be switched to have awardable_id first- Using separate ID columns removes the need for this
- Lots of repeated values in the 'name' column- perhaps 'emojis' should be pulled out as its own table "thumbsup" takes 9 bytes itself, makes a 3 byte hole (meaning 12 bytes used), not a lot of space, but still wasted space
- Move this to a
emoji
table that just has an ID and name column - This table should be populated from our emoji JSON file (there's a Rake task somewhere that does something similar)
- We need code to insert newly available emoji in this table easily
- Once done we can change
name
toemoji_id
and have to adjust all queries that filter byname
to JOIN theemoji
table and filter byemoji.name
instead
- Move this to a
Edited by Yorick Peterse