Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates postgres setup instructions in docs #645

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions docs/docs/advanced/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,45 @@ The database schema includes several key tables:
```sql
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS pgcrypto;
```

2. **Initialize Core Tables**

```sql
-- Create base tables
CREATE TABLE accounts (
"id" UUID PRIMARY KEY,
"createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"name" TEXT,
"username" TEXT,
"email" TEXT NOT NULL,
"username" TEXT UNIQUE,
"email" TEXT NOT NULL UNIQUE,
"avatarUrl" TEXT,
"details" JSONB DEFAULT '{}'::jsonb
);

CREATE TABLE rooms (
"id" UUID PRIMARY KEY,
"createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE memories (
"id" UUID PRIMARY KEY,
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"type" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"content" JSONB NOT NULL,
"embedding" vector(1536),
"userId" UUID REFERENCES accounts("id"),
"agentId" UUID REFERENCES accounts("id"),
"roomId" UUID REFERENCES rooms("id"),
"unique" BOOLEAN DEFAULT true NOT NULL
"isUnique" BOOLEAN DEFAULT true NOT NULL
);

CREATE TABLE participants (
"id" UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"userId" UUID REFERENCES accounts("id"),
"roomId" UUID REFERENCES rooms("id"),
"joinedAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
```

Expand All @@ -80,9 +88,12 @@ CREATE TABLE memories (
```sql
CREATE INDEX idx_memories_embedding ON memories
USING hnsw ("embedding" vector_cosine_ops);

CREATE INDEX idx_memories_type_room ON memories("type", "roomId");

CREATE INDEX idx_participants_user ON participants("userId");
CREATE INDEX idx_participants_room ON participants("roomId");

```

### Connection Configuration
Expand Down