Clean up schema for table labels
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: type NOT NULL
- Missing constraint: !(project_id IS NULL AND group_id IS NULL)
- Since we don't really have a nice way of duplicating validations between the DB and models we should just implement this as a Rails validation
- Missing FK: project_id -> projects (35 entries violate this rule)
- Wrong data type: color should be int, save 6 MB
- Duplicate data: type could be enum/int, save 12 MB
- Index on (type, project_id) likely could be removed, type is not very selective
- With the introduction of group labels this may no longer be the case
Edited by Yorick Peterse