Clean up schema for table taggings

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Per https://gitlab.com/gitlab-com/infrastructure/issues/1709 (private to GitLab employees):

  • Unused field: tagger_type is always NULL
  • Unused field: tagger_id is always NULL
  • Missing FK: tag_id -> tags
  • Duplicate data: context could be enum or 4-byte integer
  • Duplicate data: taggable_type could be enum or 4-byte integer
  • "Polymorphic" table prevents regular FKs, use triggers or change to independent columns or non-polymorphic tables
  • Missing trigger for FK check: taggable_type = 'Project', taggable_id -> projects.id
  • Missing trigger for FK check: taggable_type = 'MergeRequest', taggable_id -> merge_requests.id
  • Missing trigger for FK check: taggable_type = 'Issue', taggable_id -> issues.id
  • Missing trigger for FK check: taggable_type = 'Ci::Runner', taggable_id -> ci_runners.id
  • Missing trigger for FK check: taggable_type = 'Ci::Job', taggable_id -> ci_builds.id (?)
Edited by 🤖 GitLab Bot 🤖