@elizaos/plugin-sql 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,256 +0,0 @@
1
- CREATE EXTENSION IF NOT EXISTS vector;
2
- --> statement-breakpoint
3
- CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
4
- --> statement-breakpoint
5
-
6
- CREATE TABLE "agents" (
7
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
8
- "enabled" boolean DEFAULT true NOT NULL,
9
- "createdAt" timestamptz DEFAULT now() NOT NULL,
10
- "updatedAt" timestamptz DEFAULT now() NOT NULL,
11
- "name" text NOT NULL,
12
- "username" text,
13
- "system" text DEFAULT '',
14
- "bio" jsonb DEFAULT '[]'::jsonb,
15
- "message_examples" jsonb DEFAULT '[]'::jsonb NOT NULL,
16
- "post_examples" jsonb DEFAULT '[]'::jsonb NOT NULL,
17
- "topics" jsonb DEFAULT '[]'::jsonb NOT NULL,
18
- "adjectives" jsonb DEFAULT '[]'::jsonb NOT NULL,
19
- "knowledge" jsonb DEFAULT '[]'::jsonb NOT NULL,
20
- "plugins" jsonb DEFAULT '[]'::jsonb NOT NULL,
21
- "settings" jsonb DEFAULT '{}'::jsonb NOT NULL,
22
- "style" jsonb DEFAULT '{}'::jsonb NOT NULL,
23
- CONSTRAINT "name_unique" UNIQUE("name")
24
- );
25
- --> statement-breakpoint
26
- CREATE TABLE "cache" (
27
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
28
- "key" text NOT NULL,
29
- "agentId" uuid NOT NULL,
30
- "value" jsonb NOT NULL,
31
- "createdAt" timestamptz DEFAULT now() NOT NULL,
32
- "expiresAt" timestamptz,
33
- CONSTRAINT "cache_key_agent_unique" UNIQUE("key","agentId")
34
- );
35
- --> statement-breakpoint
36
- CREATE TABLE "channel_participants" (
37
- "channel_id" text NOT NULL,
38
- "user_id" text NOT NULL,
39
- CONSTRAINT "channel_participants_channel_id_user_id_pk" PRIMARY KEY("channel_id","user_id")
40
- );
41
- --> statement-breakpoint
42
- CREATE TABLE "channels" (
43
- "id" text PRIMARY KEY NOT NULL,
44
- "server_id" text NOT NULL,
45
- "name" text NOT NULL,
46
- "type" text NOT NULL,
47
- "source_type" text,
48
- "source_id" text,
49
- "topic" text,
50
- "metadata" jsonb,
51
- "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
52
- "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
53
- );
54
- --> statement-breakpoint
55
- CREATE TABLE "components" (
56
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
57
- "entityId" uuid NOT NULL,
58
- "agentId" uuid NOT NULL,
59
- "roomId" uuid NOT NULL,
60
- "worldId" uuid,
61
- "sourceEntityId" uuid,
62
- "type" text NOT NULL,
63
- "data" jsonb DEFAULT '{}'::jsonb,
64
- "createdAt" timestamptz DEFAULT now() NOT NULL
65
- );
66
- --> statement-breakpoint
67
- CREATE TABLE "embeddings" (
68
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
69
- "memory_id" uuid,
70
- "created_at" timestamptz DEFAULT now() NOT NULL,
71
- "dim_384" vector(384),
72
- "dim_512" vector(512),
73
- "dim_768" vector(768),
74
- "dim_1024" vector(1024),
75
- "dim_1536" vector(1536),
76
- "dim_3072" vector(3072),
77
- CONSTRAINT "embedding_source_check" CHECK ("memory_id" IS NOT NULL)
78
- );
79
- --> statement-breakpoint
80
- CREATE TABLE "entities" (
81
- "id" uuid PRIMARY KEY NOT NULL,
82
- "agentId" uuid NOT NULL,
83
- "createdAt" timestamptz DEFAULT now() NOT NULL,
84
- "names" text[] DEFAULT '{}'::text[] NOT NULL,
85
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
86
- CONSTRAINT "id_agent_id_unique" UNIQUE("id","agentId")
87
- );
88
- --> statement-breakpoint
89
- CREATE TABLE "logs" (
90
- "id" uuid DEFAULT gen_random_uuid() NOT NULL,
91
- "createdAt" timestamptz DEFAULT now() NOT NULL,
92
- "entityId" uuid NOT NULL,
93
- "body" jsonb NOT NULL,
94
- "type" text NOT NULL,
95
- "roomId" uuid NOT NULL
96
- );
97
- --> statement-breakpoint
98
- CREATE TABLE "memories" (
99
- "id" uuid PRIMARY KEY NOT NULL,
100
- "type" text NOT NULL,
101
- "createdAt" timestamptz DEFAULT now() NOT NULL,
102
- "content" jsonb NOT NULL,
103
- "entityId" uuid,
104
- "agentId" uuid NOT NULL,
105
- "roomId" uuid,
106
- "worldId" uuid,
107
- "unique" boolean DEFAULT true NOT NULL,
108
- "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
109
- CONSTRAINT "fragment_metadata_check" CHECK (
110
- CASE
111
- WHEN metadata->>'type' = 'fragment' THEN
112
- metadata ? 'documentId' AND
113
- metadata ? 'position'
114
- ELSE true
115
- END
116
- ),
117
- CONSTRAINT "document_metadata_check" CHECK (
118
- CASE
119
- WHEN metadata->>'type' = 'document' THEN
120
- metadata ? 'timestamp'
121
- ELSE true
122
- END
123
- )
124
- );
125
- --> statement-breakpoint
126
- CREATE TABLE "message_servers" (
127
- "id" text PRIMARY KEY NOT NULL,
128
- "name" text NOT NULL,
129
- "source_type" text NOT NULL,
130
- "source_id" text,
131
- "metadata" jsonb,
132
- "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
133
- "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
134
- );
135
- --> statement-breakpoint
136
- CREATE TABLE "central_messages" (
137
- "id" text PRIMARY KEY NOT NULL,
138
- "channel_id" text NOT NULL,
139
- "author_id" text NOT NULL,
140
- "content" text NOT NULL,
141
- "raw_message" jsonb,
142
- "in_reply_to_root_message_id" text,
143
- "source_type" text,
144
- "source_id" text,
145
- "metadata" jsonb,
146
- "created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
147
- "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
148
- );
149
- --> statement-breakpoint
150
- CREATE TABLE "participants" (
151
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
152
- "createdAt" timestamptz DEFAULT now() NOT NULL,
153
- "entityId" uuid,
154
- "roomId" uuid,
155
- "agentId" uuid,
156
- "roomState" text
157
- );
158
- --> statement-breakpoint
159
- CREATE TABLE "relationships" (
160
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
161
- "createdAt" timestamptz DEFAULT now() NOT NULL,
162
- "sourceEntityId" uuid NOT NULL,
163
- "targetEntityId" uuid NOT NULL,
164
- "agentId" uuid NOT NULL,
165
- "tags" text[],
166
- "metadata" jsonb,
167
- CONSTRAINT "unique_relationship" UNIQUE("sourceEntityId","targetEntityId","agentId")
168
- );
169
- --> statement-breakpoint
170
- CREATE TABLE "rooms" (
171
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
172
- "agentId" uuid,
173
- "source" text NOT NULL,
174
- "type" text NOT NULL,
175
- "serverId" text,
176
- "worldId" uuid,
177
- "name" text,
178
- "metadata" jsonb,
179
- "channelId" text,
180
- "createdAt" timestamptz DEFAULT now() NOT NULL
181
- );
182
- --> statement-breakpoint
183
- CREATE TABLE "server_agents" (
184
- "server_id" text NOT NULL,
185
- "agent_id" text NOT NULL,
186
- CONSTRAINT "server_agents_server_id_agent_id_pk" PRIMARY KEY("server_id","agent_id")
187
- );
188
- --> statement-breakpoint
189
- CREATE TABLE "tasks" (
190
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
191
- "name" text NOT NULL,
192
- "description" text,
193
- "roomId" uuid,
194
- "worldId" uuid,
195
- "entityId" uuid,
196
- "agent_id" uuid NOT NULL,
197
- "tags" text[] DEFAULT '{}'::text[],
198
- "metadata" jsonb DEFAULT '{}'::jsonb,
199
- "created_at" timestamp with time zone DEFAULT now(),
200
- "updated_at" timestamp with time zone DEFAULT now()
201
- );
202
- --> statement-breakpoint
203
- CREATE TABLE "worlds" (
204
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
205
- "agentId" uuid NOT NULL,
206
- "name" text NOT NULL,
207
- "metadata" jsonb,
208
- "serverId" text NOT NULL,
209
- "createdAt" timestamptz DEFAULT now() NOT NULL
210
- );
211
- --> statement-breakpoint
212
- ALTER TABLE "cache" ADD CONSTRAINT "cache_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
213
- ALTER TABLE "channel_participants" ADD CONSTRAINT "channel_participants_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
214
- ALTER TABLE "channels" ADD CONSTRAINT "channels_server_id_message_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."message_servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
215
- ALTER TABLE "components" ADD CONSTRAINT "components_entityId_entities_id_fk" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
216
- ALTER TABLE "components" ADD CONSTRAINT "components_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
217
- ALTER TABLE "components" ADD CONSTRAINT "components_roomId_rooms_id_fk" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
218
- ALTER TABLE "components" ADD CONSTRAINT "components_worldId_worlds_id_fk" FOREIGN KEY ("worldId") REFERENCES "public"."worlds"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
219
- ALTER TABLE "components" ADD CONSTRAINT "components_sourceEntityId_entities_id_fk" FOREIGN KEY ("sourceEntityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
220
- ALTER TABLE "embeddings" ADD CONSTRAINT "embeddings_memory_id_memories_id_fk" FOREIGN KEY ("memory_id") REFERENCES "public"."memories"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
221
- ALTER TABLE "embeddings" ADD CONSTRAINT "fk_embedding_memory" FOREIGN KEY ("memory_id") REFERENCES "public"."memories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
222
- ALTER TABLE "entities" ADD CONSTRAINT "entities_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
223
- ALTER TABLE "logs" ADD CONSTRAINT "logs_entityId_entities_id_fk" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
224
- ALTER TABLE "logs" ADD CONSTRAINT "logs_roomId_rooms_id_fk" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
225
- ALTER TABLE "logs" ADD CONSTRAINT "fk_room" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
226
- ALTER TABLE "logs" ADD CONSTRAINT "fk_user" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
227
- ALTER TABLE "memories" ADD CONSTRAINT "memories_entityId_entities_id_fk" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
228
- ALTER TABLE "memories" ADD CONSTRAINT "memories_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
229
- ALTER TABLE "memories" ADD CONSTRAINT "memories_roomId_rooms_id_fk" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
230
- ALTER TABLE "memories" ADD CONSTRAINT "fk_room" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
231
- ALTER TABLE "memories" ADD CONSTRAINT "fk_user" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
232
- ALTER TABLE "memories" ADD CONSTRAINT "fk_agent" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
233
- ALTER TABLE "central_messages" ADD CONSTRAINT "central_messages_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
234
- ALTER TABLE "central_messages" ADD CONSTRAINT "central_messages_in_reply_to_root_message_id_central_messages_id_fk" FOREIGN KEY ("in_reply_to_root_message_id") REFERENCES "public"."central_messages"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
235
- ALTER TABLE "participants" ADD CONSTRAINT "participants_entityId_entities_id_fk" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
236
- ALTER TABLE "participants" ADD CONSTRAINT "participants_roomId_rooms_id_fk" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
237
- ALTER TABLE "participants" ADD CONSTRAINT "participants_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
238
- ALTER TABLE "participants" ADD CONSTRAINT "fk_room" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
239
- ALTER TABLE "participants" ADD CONSTRAINT "fk_user" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
240
- ALTER TABLE "relationships" ADD CONSTRAINT "relationships_sourceEntityId_entities_id_fk" FOREIGN KEY ("sourceEntityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
241
- ALTER TABLE "relationships" ADD CONSTRAINT "relationships_targetEntityId_entities_id_fk" FOREIGN KEY ("targetEntityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
242
- ALTER TABLE "relationships" ADD CONSTRAINT "relationships_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
243
- ALTER TABLE "relationships" ADD CONSTRAINT "fk_user_a" FOREIGN KEY ("sourceEntityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
244
- ALTER TABLE "relationships" ADD CONSTRAINT "fk_user_b" FOREIGN KEY ("targetEntityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
245
- ALTER TABLE "rooms" ADD CONSTRAINT "rooms_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
246
- ALTER TABLE "server_agents" ADD CONSTRAINT "server_agents_server_id_message_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."message_servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
247
- ALTER TABLE "worlds" ADD CONSTRAINT "worlds_agentId_agents_id_fk" FOREIGN KEY ("agentId") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
248
- CREATE INDEX "idx_embedding_memory" ON "embeddings" USING btree ("memory_id");--> statement-breakpoint
249
- CREATE INDEX "idx_memories_type_room" ON "memories" USING btree ("type","roomId");--> statement-breakpoint
250
- CREATE INDEX "idx_memories_world_id" ON "memories" USING btree ("worldId");--> statement-breakpoint
251
- CREATE INDEX "idx_memories_metadata_type" ON "memories" USING btree (((metadata->>'type')));--> statement-breakpoint
252
- CREATE INDEX "idx_memories_document_id" ON "memories" USING btree (((metadata->>'documentId')));--> statement-breakpoint
253
- CREATE INDEX "idx_fragments_order" ON "memories" USING btree (((metadata->>'documentId')),((metadata->>'position')));--> statement-breakpoint
254
- CREATE INDEX "idx_participants_user" ON "participants" USING btree ("entityId");--> statement-breakpoint
255
- CREATE INDEX "idx_participants_room" ON "participants" USING btree ("roomId");--> statement-breakpoint
256
- CREATE INDEX "idx_relationships_users" ON "relationships" USING btree ("sourceEntityId","targetEntityId");