multica/server/migrations/016_backfill_subscribers.up.sql
Naiyuan Qing 5b9241b74f fix(notifications): address code review feedback
- Add comment explaining subscriber→notification listener registration order in main.go
- Add issue_status field to notifySubscribers and notifyDirect (fixes missing StatusIcon in inbox)
- Backfill existing commenters as subscribers in migration 016
- Add TODO comment for @mention duplicate notification prevention (deferred until @mention feature is enabled)
- Add context.Background() usage note for future bus-level timeout improvements
- Add toast error feedback on subscribe/unsubscribe failure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 20:24:07 +08:00

18 lines
651 B
SQL

-- Backfill creators as subscribers
INSERT INTO issue_subscriber (issue_id, user_type, user_id, reason)
SELECT id, creator_type, creator_id, 'creator'
FROM issue
ON CONFLICT DO NOTHING;
-- Backfill assignees as subscribers
INSERT INTO issue_subscriber (issue_id, user_type, user_id, reason)
SELECT id, assignee_type, assignee_id, 'assignee'
FROM issue
WHERE assignee_type IS NOT NULL AND assignee_id IS NOT NULL
ON CONFLICT DO NOTHING;
-- Backfill commenters as subscribers
INSERT INTO issue_subscriber (issue_id, user_type, user_id, reason)
SELECT DISTINCT c.issue_id, c.author_type, c.author_id, 'commenter'
FROM comment c
ON CONFLICT DO NOTHING;