-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate.sql
More file actions
51 lines (43 loc) · 1.68 KB
/
migrate.sql
File metadata and controls
51 lines (43 loc) · 1.68 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
48
49
50
51
-- SyncMind: Shared Persistent Memory for AI Agents
-- Run this in your Neon SQL Editor
-- Enable trigram similarity for smart dedup
CREATE EXTENSION IF NOT EXISTS pg_trgm;
-- Drop old tables if migrating from v1
DROP TABLE IF EXISTS approvals CASCADE;
DROP TABLE IF EXISTS activity_log CASCADE;
DROP TABLE IF EXISTS memories CASCADE;
DROP TABLE IF EXISTS tasks CASCADE;
DROP TABLE IF EXISTS agents CASCADE;
-- Core table: shared memory entries
CREATE TABLE memories (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
content TEXT NOT NULL,
memory_type TEXT DEFAULT 'learning',
source TEXT NOT NULL DEFAULT 'unknown',
project TEXT DEFAULT 'default',
tags TEXT DEFAULT '',
created_at TIMESTAMPTZ DEFAULT now(),
used_count INTEGER DEFAULT 0,
last_accessed TIMESTAMPTZ,
confidence TEXT DEFAULT 'speculative',
scope TEXT DEFAULT 'project',
version TEXT DEFAULT ''
);
CREATE INDEX idx_memories_source ON memories(source);
CREATE INDEX idx_memories_project ON memories(project);
CREATE INDEX idx_memories_type ON memories(memory_type);
CREATE INDEX idx_memories_created ON memories(created_at DESC);
CREATE INDEX idx_memories_scope ON memories(scope);
-- Full-text search on memory content
CREATE INDEX idx_memories_content_search ON memories USING gin(to_tsvector('english', content));
-- Trigram similarity index for smart dedup
CREATE INDEX idx_memories_content_trgm ON memories USING gin(content gin_trgm_ops);
-- Activity log for tracking reads/writes
CREATE TABLE activity_log (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
source TEXT,
action TEXT NOT NULL,
details TEXT,
created_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX idx_activity_created ON activity_log(created_at DESC);