feat: 로또 번호 히스토리 저장 + 마이페이지 구독정보/히스토리 표시
- POST /api/lotto/history: 생성 번호 저장 API - GET /api/lotto/history: 히스토리 조회 API - 번호 생성 시 자동 히스토리 저장 (NAS/클라이언트 출처 구분) - 합계 표시 복원 - 마이페이지: 활성 구독 카드 (D-day, 만료일 표시) - 마이페이지: 로또 기록 탭 추가 (번호볼 + 출처 + 플랜 표시) - Supabase 마이그레이션: lotto_history 테이블 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
supabase/migrations/003_lotto_history.sql
Normal file
21
supabase/migrations/003_lotto_history.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- ─── 로또 번호 히스토리 테이블 ──────────────────────────────────────────────
|
||||
CREATE TABLE IF NOT EXISTS lotto_history (
|
||||
id bigserial PRIMARY KEY,
|
||||
user_id uuid NOT NULL REFERENCES profiles(id) ON DELETE CASCADE,
|
||||
numbers integer[] NOT NULL,
|
||||
source text NOT NULL DEFAULT 'client', -- 'nas' | 'client'
|
||||
plan_id text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- RLS
|
||||
ALTER TABLE lotto_history ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY "lotto_history_select_own" ON lotto_history
|
||||
FOR SELECT USING (auth.uid() = user_id);
|
||||
|
||||
CREATE POLICY "lotto_history_insert_own" ON lotto_history
|
||||
FOR INSERT WITH CHECK (auth.uid() = user_id);
|
||||
|
||||
-- 인덱스
|
||||
CREATE INDEX IF NOT EXISTS lotto_history_user_created ON lotto_history (user_id, created_at DESC);
|
||||
Reference in New Issue
Block a user