9d9b3359b0
개인 운영 로그 / 일정 / 할 일 / 회고용 1차 컨테이너 도메인 신설.
plan: ~/.claude/plans/beszel-tingly-sloth.md (라운드 12 v6).
Schema:
- enum 5종 (event_kind / event_status / event_source / event_actor / history_change_kind)
- events 테이블: kind(task|calendar_event|activity_log) + lifecycle 7-state status
- events_history: lifecycle op 자동 기록, FK RESTRICT (이력은 시점 사실)
- CHECK: calendar_event → start_at NOT NULL / activity_log → started_at|ended_at NOT NULL
- partial unique (source, source_ref) — 외부 source dedup (PR-4 활용)
- partial index (active status / activity_log timeline)
API:
- POST /api/events (kind=activity_log shortcut: status=done + ended_at=now() default)
- GET /api/events/{id} | /api/events?kind&status&from&to&project_tag&source
- PATCH /api/events/{id} (extra=forbid + 시간 필드 변경 시 reschedule history)
- POST /api/events/{id}/{complete,cancel,defer,reactivate} (history 자동)
- GET /api/events/today (Asia/Seoul default, deferred 는 defer_until<=now() 만)
- GET /api/events/inbox | /api/events/activity?from&to
제외 (PR-2~5 또는 백로그):
- DELETE (회고 데이터 → /cancel 일관화)
- log shortcut / upcoming endpoint (POST + GET ?from&to 로 흡수)
- /ingest (PR-4 MailPlus forward 시 정확한 요구로 추가)
- iCal export / ntfy 알림 / recurrence / 일반 edit history
16 lines
837 B
SQL
16 lines
837 B
SQL
-- events 도메인 PR-1 (10/11) — events_history 변경 이력 테이블
|
|
-- lifecycle op 자동 기록 (create / reschedule / defer / reactivate / complete / cancel).
|
|
-- 일반 PATCH (title/description 등) 의 history 는 v1 X (폭증 회피).
|
|
-- ON DELETE RESTRICT: 이력은 시점 사실 → 부모 events row 직접 삭제 차단
|
|
-- (feedback_history_table_fk_restrict.md). events 자체는 /cancel 로 soft-cancel.
|
|
|
|
CREATE TABLE IF NOT EXISTS events_history (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
event_id BIGINT NOT NULL REFERENCES events(id) ON DELETE RESTRICT,
|
|
changed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
changed_by event_actor NOT NULL,
|
|
change_kind history_change_kind NOT NULL,
|
|
before JSONB, -- create 시 NULL
|
|
after JSONB NOT NULL
|
|
);
|