Clean up schema for table approvers
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 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
- Missing constraint: created_at NOT NULL
- Missing constraint: updated_at NOT NULL
- Missing constraint: target_type NOT NULL
The columns target_type
and target_id
should be replaced by individual columns called project_id
and merge_request_id
, both with a foreign key. We also need to add a Rails validation to enforce only one of the two being set.
Edited by Yorick Peterse