feat(notifications): 알림 종 + 공지 기능 추가
- 헤더 프로필 왼쪽 알림 종: 드롭다운·안읽음 배지·60초 폴링(최초 폴링 도입) - 내 프로젝트 좋아요/즐겨찾기/댓글 시 소유자에게 알림(본인 제외·재토글 도배 방지) - 관리자 공지: /announcements 목록 + 작성/수정/삭제, 등록 시 전 직원에게 fan-out 알림 - notifications/announcements 테이블(멱등) + requireAdmin 가드 + bell/megaphone 아이콘 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
28
schema.sql
28
schema.sql
@@ -64,3 +64,31 @@ CREATE TABLE IF NOT EXISTS stars (
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (project_id, sabun)
|
||||
);
|
||||
|
||||
-- 공지 (관리자가 작성해 전 직원에게 알림으로 전달. 별도 모아보기 페이지 /announcements)
|
||||
CREATE TABLE IF NOT EXISTS announcements (
|
||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
author_sabun text NOT NULL REFERENCES users(sabun),
|
||||
title text NOT NULL,
|
||||
body text NOT NULL DEFAULT '',
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_announcements_created ON announcements(created_at DESC);
|
||||
|
||||
-- 알림 (통합 인박스) — 반응(❤️/⭐)·댓글·공지를 한 테이블로.
|
||||
-- recipient_sabun: 받는 사람 / actor_sabun: 행위자(공지는 작성 관리자, 시스템성이면 NULL 가능)
|
||||
-- kind: 'heart' | 'star' | 'comment' | 'announcement'
|
||||
-- project_id / announcement_id: 알림이 가리키는 대상(각각 삭제 시 CASCADE 로 정리)
|
||||
CREATE TABLE IF NOT EXISTS notifications (
|
||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
recipient_sabun text NOT NULL REFERENCES users(sabun),
|
||||
actor_sabun text REFERENCES users(sabun),
|
||||
kind text NOT NULL,
|
||||
project_id bigint REFERENCES projects(id) ON DELETE CASCADE,
|
||||
announcement_id bigint REFERENCES announcements(id) ON DELETE CASCADE,
|
||||
is_read boolean NOT NULL DEFAULT false,
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
-- 종 드롭다운/배지 조회: 받는 사람별 최신순.
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_recipient ON notifications(recipient_sabun, created_at DESC);
|
||||
|
||||
Reference in New Issue
Block a user