Clean up schema for table notification_settings

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

  • Close this issue

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 (17 entries violate this rule)
  • "Polymorphic" table prevents regular FKs, use triggers or change to independent columns or non-polymorphic tables
  • Duplicate data: source_type could be enum or 4-byte integer, save 20 MB
  • Missing trigger for FK check: source_type = 'Namespace', source_id -> namespaces.id
  • Missing trigger for FK check: source_type = 'Project', source_id -> projects.id (3 entries violate this rule)
  • Missing constraint: CHECK (source_type IN ('Namespace','Project'))
  • Duplicate index: index_notification_settings_on_user_id - notification_settings (user_id), already indexed
  • Duplicate data: events column is structured data (JSON?) stored as text, lots of repeated data, avg tuple width is ~250 bytes, 200+ from events column
Edited Sep 13, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading