핵심 개체와 관계를 표시한 다이어그램입니다. 전체 필드는 supabase/migrations/의 SQL이 원본입니다.
erDiagram
TESTERS {
uuid id PK
string name
string phone UK
boolean active
}
DIARIES {
uuid id PK
uuid tester_id FK "nullable"
string photo_type_id FK "nullable, 분석 후 채워짐"
string style_id FK
string caption
string original_image_path
string result_image_path "nullable"
string status "pending, done, rejected, failed"
string error_code "nullable"
string error_message "nullable"
int analysis_prompt_version
int photo_type_prompt_version
int style_prompt_version
int common_prompt_version
}
DIARY_FEEDBACK {
uuid id PK
uuid diary_id FK
int rating "1-5"
string comment "nullable"
}
PHOTO_TYPES {
string id PK "person, landscape, object, animal, composite"
string label
}
STYLES {
string id PK "pastel_crayon, pencil_sketch, watercolor, ink"
string label
boolean active
}
ANALYSIS_PROMPTS {
uuid id PK
int version UK
string prompt
boolean active "조합당 1개만 true"
}
PROMPT_COMMON {
uuid id PK
int version
string prompt
boolean active
}
PROMPT_PHOTO_TYPE {
uuid id PK
string photo_type_id FK
int version
string prompt
boolean active
}
PROMPT_STYLE {
uuid id PK
string style_id FK
int version
string prompt
boolean active
}
PROMPT_NEGATIVE {
uuid id PK
int version
string prompt
boolean active
}
API_KEY_REFS {
uuid id PK
string provider UK
string stage "analysis, image_gen, other"
uuid vault_secret_id FK "vault.secrets"
}
STYLE_TEST_RUNS {
uuid id PK
string original_image_path
string result_image_path "nullable"
string status "done, failed"
string error_code "nullable"
json style_versions "nullable, 스타일별 사용 버전"
string grid_prompt "nullable, 실제 전송된 프롬프트"
}
TESTERS ||--o{ DIARIES : "작성"
DIARIES ||--o{ DIARY_FEEDBACK : "평가"
PHOTO_TYPES |o--o{ DIARIES : "사진유형(분석 후)"
STYLES ||--o{ DIARIES : "스타일 선택"
PHOTO_TYPES ||--o{ PROMPT_PHOTO_TYPE : "버전 관리"
STYLES ||--o{ PROMPT_STYLE : "버전 관리"
테이블 요약
- diaries — 소비자 생성 기록의 중심 테이블. status로 파이프라인 진행 상태를 추적하고, 실패 시 error_code(세분화된 원인)·error_message(원문)를 함께 저장
- analysis_prompts / prompt_common / prompt_photo_type / prompt_style / prompt_negative — 프롬프트를 조각 단위로 버전 관리. 실행 시점에 photo_type + style + common을 이어붙이고, negative는 별도 전달
- api_key_refs — 원문 키는 절대 저장하지 않고
vault.secrets를 가리키는 참조만 보관, SECURITY DEFINER 함수로만 읽기 - style_test_runs — 관리자 4스타일 비교 도구의 실행 이력. diaries와 분리해 실사용자 데이터를 오염시키지 않으면서도 테스트 히스토리를 남김