Files
dbx-main/scripts/sql/project_db_012_comment_replies_reactions.sql
T
king 4fb8b37d9c feat(project): 실시간 저장·댓글 답글/반응·완료 이력·수신함 오른쪽 작업 창·화면 배율 토글
- 작업 창 저장 버튼 제거 → 칸별 실시간 저장(새 작업은 제목 입력 시 생성)
- 댓글 답글·이모티콘 반응(마이그레이션 012), @태그 아이콘+이름 칩, 이모티콘 선택기
- 작업 완료 시 댓글 사이에 "OO 님이 이 작업을 완료했습니다" 이력 표시
- 수신함 "확인" → 페이지 이동 없이 오른쪽 패널(iframe embed)에 작업 창
- 프로젝트 제목 클릭 수정, 긴 작업 제목 자동 줄바꿈
- 상단 바 화면 배율 토글(2880x1620·200%용, .erp-app zoom .75)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:11:34 +09:00

51 lines
2.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =====================================================================
-- project_db 마이그레이션 012 — 댓글 답글 + 이모티콘 반응(아사나식)
-- =====================================================================
-- 멱등(idempotent). DROP/TRUNCATE 없음.
--
-- task_comments.parent_id 답글이면 원 댓글 id(한 단계만 — 답글의 답글도 원 댓글에 붙는다).
-- 원 댓글을 지우면 답글도 CASCADE 로 같이 지워진다.
-- task_comment_reactions 댓글 1개 × 사람 1명 × 이모티콘 1개 = 1행(누르면 추가, 다시 누르면 삭제).
-- task_id 는 휴지통 스냅샷(TRASH_CHILD_TABLES)이 task_id 로 묶기 때문.
--
-- 미적용이어도 앱은 동작한다 — 답글/반응 버튼만 숨겨지고, 누르면 "마이그레이션 012 필요" 안내.
--
-- 적용 (1회, 여러 번 돌려도 안전):
-- docker exec -i postgres-db psql -U postgres -d project_db \
-- < scripts/sql/project_db_012_comment_replies_reactions.sql
-- =====================================================================
\set ON_ERROR_STOP on
\connect project_db
ALTER TABLE task_comments
ADD COLUMN IF NOT EXISTS parent_id BIGINT REFERENCES task_comments(id) ON DELETE CASCADE;
CREATE INDEX IF NOT EXISTS idx_task_comments_parent ON task_comments (parent_id);
COMMENT ON COLUMN task_comments.parent_id IS '답글이면 원 댓글 id (한 단계). NULL = 일반 댓글';
CREATE TABLE IF NOT EXISTS task_comment_reactions (
comment_id BIGINT NOT NULL REFERENCES task_comments(id) ON DELETE CASCADE,
task_id BIGINT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
user_email TEXT NOT NULL,
emoji TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (comment_id, user_email, emoji)
);
CREATE INDEX IF NOT EXISTS idx_task_comment_reactions_task ON task_comment_reactions (task_id);
-- 실시간 반영(007) — 반응도 다른 사람 화면에 바로 보이게 버전 카운터를 올린다.
DO $$
BEGIN
IF to_regproc('project_bump_live_version') IS NOT NULL THEN
EXECUTE 'DROP TRIGGER IF EXISTS trg_task_comment_reactions_live_version ON task_comment_reactions';
EXECUTE 'CREATE TRIGGER trg_task_comment_reactions_live_version '
'AFTER INSERT OR UPDATE OR DELETE ON task_comment_reactions '
'FOR EACH STATEMENT EXECUTE FUNCTION project_bump_live_version()';
END IF;
END $$;
GRANT SELECT, INSERT, UPDATE, DELETE ON task_comment_reactions TO project_app;
SELECT 'project_db 012 comment replies/reactions ready' AS status;