- kstDayStartISO: KST 자정을 UTC ISO로 변환 - getTodayUsage, recordUsage: AI 사용량 조회·기록 - DB: tarot_readings, ai_usage_log 테이블 생성 - saju service_settings 삭제 (숨김 해제) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AAtcmKKtqDUe4NyVgy1aLQ
28 lines
1.1 KiB
SQL
28 lines
1.1 KiB
SQL
-- Phase 2 (2026-07-02): 타로 저장·AI 사용량 로그 + 사주 숨김 해제
|
|
-- 적용: 클라우드 Supabase + NAS self-host 양쪽
|
|
|
|
CREATE TABLE IF NOT EXISTS tarot_readings (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
spread_type text NOT NULL DEFAULT 'three_card',
|
|
category text,
|
|
question text,
|
|
cards jsonb NOT NULL,
|
|
interpretation jsonb NOT NULL,
|
|
summary text,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
ALTER TABLE tarot_readings ENABLE ROW LEVEL SECURITY;
|
|
CREATE POLICY tarot_select_own ON tarot_readings FOR SELECT USING (auth.uid() = user_id);
|
|
|
|
CREATE TABLE IF NOT EXISTS ai_usage_log (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id uuid NOT NULL,
|
|
service text NOT NULL CHECK (service IN ('saju','tarot')),
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
ALTER TABLE ai_usage_log ENABLE ROW LEVEL SECURITY;
|
|
CREATE INDEX IF NOT EXISTS idx_ai_usage_user_day ON ai_usage_log (user_id, service, created_at);
|
|
|
|
DELETE FROM service_settings WHERE id = 'saju';
|