-- Migration: Add deposit_sessions table for session-based deposit requests
-- Date: 2026-02-05
-- Description: 입금 신고 세션 관리 (collecting_amount → collecting_name → confirming → completed)

CREATE TABLE IF NOT EXISTS deposit_sessions (
  user_id TEXT PRIMARY KEY,
  status TEXT NOT NULL CHECK(status IN ('collecting_amount', 'collecting_name', 'confirming', 'completed')),
  collected_info TEXT, -- JSON: { amount?: number, depositor_name?: string }
  messages TEXT, -- JSON: [{ role: 'user' | 'assistant', content: string }]
  created_at INTEGER NOT NULL,
  updated_at INTEGER NOT NULL,
  expires_at INTEGER NOT NULL
);

-- Index for cleanup queries (expired sessions)
CREATE INDEX IF NOT EXISTS idx_deposit_sessions_expires_at ON deposit_sessions(expires_at);
