fix(sync): bind sync engine to its user DB, scope instructions/templates per account, harden navigation

This commit is contained in:
Yun Chan 2026-09-28 00:53:42 +09:00
parent 1b8fe445f3
commit 9aa7302944
30 changed files with 2614 additions and 386 deletions

View file

@ -0,0 +1,33 @@
-- 20260928010000_sync_server_stamped_updated_at.sql
-- 동기화 커서는 서버 시각(updated_at)에 기대는데, 기존 moddatetime 트리거는 BEFORE UPDATE 뿐이라
-- INSERT 때는 클라이언트가 보낸 updated_at(오프라인 편집 시각·느린 시계·backfill된 옛 행)이 그대로 남았다.
-- 그러면 이미 동기화된 다른 기기의 keyset 커서(updated_at > cursor - 60s) 뒤로 들어가 영영 내려받히지 않는다.
-- 데스크톱은 이제 updated_at 을 보내지 않지만, 옛 클라이언트·다른 경로도 막기 위해 INSERT 에도 서버 시각을 찍는다.
--
-- public.moddatetime() 은 이 프로젝트의 plpgsql 함수(NEW.updated_at = now())라 INSERT 에도 쓸 수 있다.
-- 적용 전 검토 필요: 운영 DB에 직접 적용하지 말 것(릴리스 절차로 배포).
DROP TRIGGER IF EXISTS set_updated_at_on_insert_history ON public.history;
CREATE TRIGGER set_updated_at_on_insert_history
BEFORE INSERT ON public.history
FOR EACH ROW EXECUTE FUNCTION public.moddatetime();
DROP TRIGGER IF EXISTS set_updated_at_on_insert_dictionary ON public.dictionary;
CREATE TRIGGER set_updated_at_on_insert_dictionary
BEFORE INSERT ON public.dictionary
FOR EACH ROW EXECUTE FUNCTION public.moddatetime();
DROP TRIGGER IF EXISTS set_updated_at_on_insert_meetings ON public.meetings;
CREATE TRIGGER set_updated_at_on_insert_meetings
BEFORE INSERT ON public.meetings
FOR EACH ROW EXECUTE FUNCTION public.moddatetime();
DROP TRIGGER IF EXISTS set_updated_at_on_insert_meeting_memos ON public.meeting_memos;
CREATE TRIGGER set_updated_at_on_insert_meeting_memos
BEFORE INSERT ON public.meeting_memos
FOR EACH ROW EXECUTE FUNCTION public.moddatetime();
DROP TRIGGER IF EXISTS set_updated_at_on_insert_meeting_documents ON public.meeting_documents;
CREATE TRIGGER set_updated_at_on_insert_meeting_documents
BEFORE INSERT ON public.meeting_documents
FOR EACH ROW EXECUTE FUNCTION public.moddatetime();