chore: add server provisioning migrations
- 003_add_server_tables.sql: server_orders, server_instances tables - 003_server_sessions.sql: KV-based session tracking - 004_add_terminated_at.sql: track instance termination time Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
21
migrations/003_server_sessions_d1.sql
Normal file
21
migrations/003_server_sessions_d1.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Migration 003: Server Sessions to D1 Database
|
||||
-- Migrate server session management from KV Namespace to D1 Database
|
||||
-- Date: 2026-01-28
|
||||
|
||||
-- Create server_sessions table
|
||||
CREATE TABLE IF NOT EXISTS server_sessions (
|
||||
user_id TEXT PRIMARY KEY,
|
||||
status TEXT NOT NULL CHECK(status IN ('gathering', 'recommending', 'selecting', 'ordering', 'completed')),
|
||||
collected_info TEXT,
|
||||
last_recommendation TEXT,
|
||||
messages TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
expires_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- Create index for expiry cleanup
|
||||
CREATE INDEX IF NOT EXISTS idx_server_sessions_expires ON server_sessions(expires_at);
|
||||
|
||||
-- Note: Existing KV sessions will be automatically migrated on first access
|
||||
-- Old sessions in KV will expire naturally (1 hour TTL)
|
||||
Reference in New Issue
Block a user