From 4fafa3b9ac606024098001fd5e47be50da1c4377 Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Tue, 19 Nov 2024 14:50:21 -0500 Subject: [PATCH] Update adapters.md psql schema I found I needed these schemas (ported from the supabase migration) in order to successfully run an agent with the discord client --- docs/docs/packages/adapters.md | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/docs/packages/adapters.md b/docs/docs/packages/adapters.md index 1ad639f23b..374dc1d17b 100644 --- a/docs/docs/packages/adapters.md +++ b/docs/docs/packages/adapters.md @@ -425,9 +425,42 @@ async searchMemories(params: { ### PostgreSQL Schema ```sql --- migrations/20240318103238_remote_schema.sql CREATE EXTENSION IF NOT EXISTS vector; +CREATE TABLE IF NOT EXISTS accounts ( + id UUID PRIMARY KEY, + "createdAt" DEFAULT CURRENT_TIMESTAMP, + "name" TEXT, + "username" TEXT, + "email" TEXT NOT NULL, + "avatarUrl" TEXT, + "details" JSONB DEFAULT '{}'::"jsonb", + "is_agent" BOOLEAN DEFAULT false NOT NULL, + "location" TEXT, + "profile_line" TEXT, + "signed_tos" BOOLEAN DEFAULT false NOT NULL +); + +ALTER TABLE ONLY accounts ADD CONSTRAINT users_email_key UNIQUE (email); + +CREATE TABLE IF NOT EXISTS participants ( + "id" UUID PRIMARY KEY, + "createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL, + "userId" UUID REFERENCES accounts(id), + "roomId" UUID REFERENCES rooms(id), + "userState" TEXT, -- For MUTED, NULL, or FOLLOWED states + "last_message_read" UUID +); + +ALTER TABLE ONLY participants ADD CONSTRAINT participants_id_key UNIQUE (id); +ALTER TABLE ONLY participants ADD CONSTRAINT participants_roomId_fkey FOREIGN KEY ("roomId") REFERENCES rooms(id); +ALTER TABLE ONLY participants ADD CONSTRAINT participants_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id); + +CREATE TABLE rooms ( + id UUID PRIMARY KEY, + "createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + CREATE TABLE memories ( id UUID PRIMARY KEY, type TEXT NOT NULL, @@ -440,6 +473,9 @@ CREATE TABLE memories ( "createdAt" TIMESTAMP NOT NULL ); +ALTER TABLE ONLY memories ADD CONSTRAINT memories_roomId_fkey FOREIGN KEY ("roomId") REFERENCES rooms(id); +ALTER TABLE ONLY memories ADD CONSTRAINT memories_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id); + CREATE INDEX memory_embedding_idx ON memories USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100); @@ -452,6 +488,11 @@ CREATE TABLE relationships ( "createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); +ALTER TABLE ONLY relationships ADD CONSTRAINT friendships_id_key UNIQUE (id); +ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userA_fkey FOREIGN KEY ("userA") REFERENCES accounts(id); +ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userB_fkey FOREIGN KEY ("userB") REFERENCES accounts(id); +ALTER TABLE ONLY relationships ADD CONSTRAINT relationships_userId_fkey FOREIGN KEY ("userId") REFERENCES accounts(id); + CREATE TABLE goals ( id UUID PRIMARY KEY, "roomId" UUID NOT NULL,