Skip to content

Commit

Permalink
Merge pull request #645 from DataRelic/main
Browse files Browse the repository at this point in the history
updates postgres setup instructions in docs
  • Loading branch information
lalalune authored Nov 28, 2024
2 parents c9468d3 + a6c60c8 commit 25d4ddf
Showing 1 changed file with 20 additions and 9 deletions.
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

0 comments on commit 25d4ddf

Please sign in to comment.