-- Migration 006: Add domain and deposit agent session tables
-- Date: 2026-02-05
-- Description: Add domain_sessions and deposit_sessions tables for multi-turn agent conversations

-- Domain agent sessions table
CREATE TABLE IF NOT EXISTS domain_sessions (
  user_id TEXT PRIMARY KEY,
  status TEXT NOT NULL CHECK(status IN ('gathering', 'suggesting', 'confirming', 'setting_ns', 'completed')),
  collected_info TEXT,
  target_domain TEXT,
  messages TEXT,
  created_at INTEGER NOT NULL,
  updated_at INTEGER NOT NULL,
  expires_at INTEGER NOT NULL
);

-- Deposit agent sessions table
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,
  messages TEXT,
  created_at INTEGER NOT NULL,
  updated_at INTEGER NOT NULL,
  expires_at INTEGER NOT NULL
);

-- Create index for expiry cleanup (domain_sessions)
CREATE INDEX IF NOT EXISTS idx_domain_sessions_expires ON domain_sessions(expires_at);

-- Create index for expiry cleanup (deposit_sessions)
CREATE INDEX IF NOT EXISTS idx_deposit_sessions_expires ON deposit_sessions(expires_at);
