-- Migration: Add DDoS Defense Sessions Table
-- Created: 2026-02-05
-- Description: Stores DDoS defense consultation sessions

CREATE TABLE IF NOT EXISTS ddos_sessions (
  user_id TEXT PRIMARY KEY,
  status TEXT NOT NULL CHECK(status IN ('gathering', 'analyzing', 'recommending', 'completed')),
  collected_info TEXT, -- JSON: { attack_type?: string, target?: string, symptoms?: string[], traffic_volume?: 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_ddos_sessions_expires_at ON ddos_sessions(expires_at);

-- Index for status queries (optional, for analytics)
CREATE INDEX IF NOT EXISTS idx_ddos_sessions_status ON ddos_sessions(status);
