@elizaos/plugin-sql 1.0.4 → 1.0.5

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.
package/dist/migrate.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  PostgresConnectionManager,
4
4
  __name,
5
5
  resolvePgliteDir
6
- } from "./chunk-QOV7MUNF.js";
6
+ } from "./chunk-74FVWTXP.js";
7
7
 
8
8
  // src/migrate.ts
9
9
  import { logger } from "@elizaos/core";
@@ -11,7 +11,7 @@ CREATE TABLE "agents" (
11
11
  "name" text NOT NULL,
12
12
  "username" text,
13
13
  "system" text DEFAULT '',
14
- "bio" jsonb DEFAULT '[]'::jsonb NOT NULL,
14
+ "bio" jsonb DEFAULT '[]'::jsonb,
15
15
  "message_examples" jsonb DEFAULT '[]'::jsonb NOT NULL,
16
16
  "post_examples" jsonb DEFAULT '[]'::jsonb NOT NULL,
17
17
  "topics" jsonb DEFAULT '[]'::jsonb NOT NULL,
@@ -33,6 +33,25 @@ CREATE TABLE "cache" (
33
33
  CONSTRAINT "cache_key_agent_unique" UNIQUE("key","agentId")
34
34
  );
35
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
36
55
  CREATE TABLE "components" (
37
56
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
38
57
  "entityId" uuid NOT NULL,
@@ -104,6 +123,30 @@ CREATE TABLE "memories" (
104
123
  )
105
124
  );
106
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
107
150
  CREATE TABLE "participants" (
108
151
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
109
152
  "createdAt" timestamptz DEFAULT now() NOT NULL,
@@ -137,6 +180,12 @@ CREATE TABLE "rooms" (
137
180
  "createdAt" timestamptz DEFAULT now() NOT NULL
138
181
  );
139
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
140
189
  CREATE TABLE "tasks" (
141
190
  "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
142
191
  "name" text NOT NULL,
@@ -161,6 +210,8 @@ CREATE TABLE "worlds" (
161
210
  );
162
211
  --> statement-breakpoint
163
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
164
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
165
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
166
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
@@ -179,6 +230,8 @@ ALTER TABLE "memories" ADD CONSTRAINT "memories_roomId_rooms_id_fk" FOREIGN KEY
179
230
  ALTER TABLE "memories" ADD CONSTRAINT "fk_room" FOREIGN KEY ("roomId") REFERENCES "public"."rooms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
180
231
  ALTER TABLE "memories" ADD CONSTRAINT "fk_user" FOREIGN KEY ("entityId") REFERENCES "public"."entities"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
181
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
182
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
183
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
184
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
@@ -190,6 +243,7 @@ ALTER TABLE "relationships" ADD CONSTRAINT "relationships_agentId_agents_id_fk"
190
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
191
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
192
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
193
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
194
248
  CREATE INDEX "idx_embedding_memory" ON "embeddings" USING btree ("memory_id");--> statement-breakpoint
195
249
  CREATE INDEX "idx_memories_type_room" ON "memories" USING btree ("type","roomId");--> statement-breakpoint