-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_tables.sql
More file actions
47 lines (42 loc) · 1.42 KB
/
create_tables.sql
File metadata and controls
47 lines (42 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- LangGraph Checkpointer Tables for Supabase
-- Run this in Supabase SQL Editor to create required tables
-- This only needs to be done ONCE
-- Table 1: Main checkpoints storage
CREATE TABLE IF NOT EXISTS checkpoints (
thread_id TEXT NOT NULL,
checkpoint_ns TEXT NOT NULL DEFAULT '',
checkpoint_id TEXT NOT NULL,
parent_checkpoint_id TEXT,
type TEXT,
checkpoint JSONB NOT NULL,
metadata JSONB NOT NULL DEFAULT '{}',
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
);
-- Table 2: Checkpoint writes/operations
CREATE TABLE IF NOT EXISTS checkpoint_writes (
thread_id TEXT NOT NULL,
checkpoint_ns TEXT NOT NULL DEFAULT '',
checkpoint_id TEXT NOT NULL,
task_id TEXT NOT NULL,
idx INTEGER NOT NULL,
channel TEXT NOT NULL,
type TEXT,
value JSONB,
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
);
-- Table 3: Migration tracking
CREATE TABLE IF NOT EXISTS checkpoint_migrations (
v INTEGER NOT NULL PRIMARY KEY,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert migration version
INSERT INTO checkpoint_migrations (v)
VALUES (1)
ON CONFLICT (v) DO NOTHING;
-- Verify tables created
SELECT
table_name,
(SELECT COUNT(*) FROM information_schema.columns WHERE table_name = t.table_name) as column_count
FROM information_schema.tables t
WHERE table_name IN ('checkpoints', 'checkpoint_writes', 'checkpoint_migrations')
ORDER BY table_name;