-- Troubleshoot Agent Sessions (D1)
-- 기존 KV 세션을 D1로 마이그레이션

CREATE TABLE IF NOT EXISTS troubleshoot_sessions (
  user_id TEXT PRIMARY KEY,
  status TEXT NOT NULL CHECK(status IN ('gathering', 'diagnosing', 'suggesting', 'completed')),
  collected_info TEXT,
  messages TEXT,
  created_at INTEGER NOT NULL,
  updated_at INTEGER NOT NULL,
  expires_at INTEGER NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_troubleshoot_sessions_expires ON troubleshoot_sessions(expires_at);
