slexn_homework
Tables (9)
CONVERSATIONS (Untitled3)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (team_id) — nullable, teams.id, 생성 후 불변 — Foreign key → TEAMS.uuid
- uuid (owner_user_id) — NOT NULL, users.id — Foreign key → USERS.uuid — NOT NULL
- text (title) — NOT NULL, 기본값 새 대화
- text (visibility) — PRIVATE|TEAM, 기본값 PRIVATE
- text (acl_scope) — 생성 컬럼, user:UUID 또는 team:UUID
- timestamptz (created_at) — NOT NULL, 기본값 now
- timestamptz (updated_at) — NOT NULL, 기본값 now
- timestamptz (deleted_at) — nullable, RLS조건
DOCUMENTS (Untitled6)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (team_id) — nullable, teams.id, 생성 후 불변 — Foreign key → TEAMS.uuid
- uuid (owner_user_id) — NOT NULL, users.id — Foreign key → USERS.uuid — NOT NULL
- text (filename) — NOT NULL
- text (mime_type) — NOT NULL, md|txt만 허용
- text (visibility) — PRIVATE|TEAM, 기본값 PRIVATE
- text (acl_scope) — 생성 컬럼, user:UUID 또는 team:UUID
- text (status) — PENDING|INDEXING|INDEXED|FAILED
- text (error_message) — nullable, status=FAILED일 때만
- timestamptz (created_at) — NOT NULL, 기본값 now
- timestamptz (deleted_at) — nullable, RLS조건
DOCUMENT_CHUNKS (Untitled7)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (document_id) — NOT NULL, ON DELETE CASCADE — Foreign key → DOCUMENTS.uuid — NOT NULL
- int (chunk_index) — NOT NULL, 문서 내 UNIQUE
- text (content) — NOT NULL
- int (token_count) — nullable
- vector (embedding) — NOT NULL, 1536차원 cosine
- text (embedding_model) — NOT NULL, 기본값 text-embedding-3-small
- text (acl_scope) — NOT NULL, 부모 문서에서 트리거로 상속
- timestamptz (deleted_at) — nullable, RLS 조건
LLM_CALL_LOGS (Untitled5)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (user_id) — nullable, users.id — Foreign key → USERS.uuid — NOT NULL
- uuid (message_id) — nullable, ON DELETE SET NULL — Foreign key → MESSAGES.uuid — NOT NULL
- text (trace_id) — NOT NULL
- text (purpose) — CLASSIFY_L1|CLASSIFY_L2|GENERATE|VERIFY|EMBED
- text (model) — NOT NULL
- text (alm_stage) — nullable, AlmStage 도메인
- text (task_type) — nullable, TaskType 도메인
- int (tokens_in) — nullable
- int (tokens_out) — nullable
- int (latency_ms) — nullable
- numeric (cost_usd) — nullable, 정밀도 10 소수 6
- text (status) — OK|ERROR|TIMEOUT
- timestamptz (created_at) — NOT NULL, 기본값 now
MESSAGES (Untitled4)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (conversation_id) — NOT NULL, ON DELETE CASCADE — Foreign key → CONVERSATIONS.uuid — NOT NULL
- int (seq) — NOT NULL, 대화 내 UNIQUE
- text (role) — USER|ASSISTANT|SYSTEM|TOOL
- text (content) — NOT NULL
- text (alm_stage) — nullable, AlmStage 도메인
- text (task_type) — nullable, TaskType 도메인
- real (route_confidence) — nullable, 0.0 ~ 1.0, 0.6미만은 fallback
- timestamptz (created_at) — NOT NULL, 기본값 now
SHARE_GRANTS (Untitled9)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (grantee_user_id) — NOT NULL, ON DELETE CASCADE — Foreign key → USERS.uuid — NOT NULL
- uuid (granted_by) — NOT NULL, users.id — Foreign key → USERS.uuid — NOT NULL
- text (resource_type) — CONVERSATION|DOCUMENT
- uuid (resource_id) — NOT NULL, 다형 참조라 FK 없음
- text (permission) — READ|WRITE, 기본값 READ
- timestamptz (revoked_at) — nullable, soft회수
- timestamptz (created_at) — NOT NULL, 기본값 now
TEAMS (Untitled)
- uuid (id) — 기본값 gen_random_uuid — Primary key
- text (name) — NOT NULL, 전역 UNIQUE
- timestamptz (created_at) — NOT NULL, 기본값 now
TEAM_MEMBERS (Untitled2)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- uuid (team_id) — NOT NULL, CASCADE, user_id와 함께 — Foreign key → TEAMS.uuid
- uuid (user_id) — NOT NULL, CASCADE, team_id와 함께 — Foreign key → USERS.uuid — NOT NULL
- text (role) — OWNER|MEMBER, 기본값 MEMBER
- timestamptz (joined_at) — NOT NULL, 기본값 now
USERS (Untitled8)
- uuid (id) — 기본값 gen_random_uuid — Primary key — NOT NULL
- citext (email) — UK, NOT NULL, 대소문자 무시 비교
- text (password_hash) — NOT NULL
- text (display_name) — NOT NULL
- timestamptz (created_at) — NOT NULL, 기본값 now
- timestamptz (deleted_at) — nullable, 탈퇴 시각