mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE "agents" ADD COLUMN IF NOT EXISTS "session_group_id" text;--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'agents_session_group_id_session_groups_id_fk') THEN
|
||||
ALTER TABLE "agents" ADD CONSTRAINT "agents_session_group_id_session_groups_id_fk" FOREIGN KEY ("session_group_id") REFERENCES "public"."session_groups"("id") ON DELETE set null ON UPDATE no action;
|
||||
END IF;
|
||||
END $$;--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "agents_session_group_id_idx" ON "agents" USING btree ("session_group_id");
|
||||
9143
packages/database/migrations/meta/0064_snapshot.json
Normal file
9143
packages/database/migrations/meta/0064_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -448,6 +448,13 @@
|
||||
"when": 1766157362540,
|
||||
"tag": "0063_add_columns_for_several_tables",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 64,
|
||||
"version": "7",
|
||||
"when": 1766297832021,
|
||||
"tag": "0064_add_agents_session_group_id",
|
||||
"breakpoints": true
|
||||
}
|
||||
],
|
||||
"version": "6"
|
||||
|
||||
@@ -1023,5 +1023,15 @@
|
||||
"bps": true,
|
||||
"folderMillis": 1766157362540,
|
||||
"hash": "7a8ee107778222390e676951173baa81bfa09dd47216a8467575fca54915172c"
|
||||
},
|
||||
{
|
||||
"sql": [
|
||||
"ALTER TABLE \"agents\" ADD COLUMN IF NOT EXISTS \"session_group_id\" text;",
|
||||
"\nDO $$ BEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'agents_session_group_id_session_groups_id_fk') THEN\n ALTER TABLE \"agents\" ADD CONSTRAINT \"agents_session_group_id_session_groups_id_fk\" FOREIGN KEY (\"session_group_id\") REFERENCES \"public\".\"session_groups\"(\"id\") ON DELETE set null ON UPDATE no action;\n END IF;\nEND $$;",
|
||||
"\nCREATE INDEX IF NOT EXISTS \"agents_session_group_id_idx\" ON \"agents\" USING btree (\"session_group_id\");\n"
|
||||
],
|
||||
"bps": true,
|
||||
"folderMillis": 1766297832021,
|
||||
"hash": "431a620396060130c46d6174d4bef3a517a0872aff8d19f3044bd9e7dec78ba5"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -15,6 +15,7 @@ import { createInsertSchema } from 'drizzle-zod';
|
||||
import { idGenerator, randomSlug } from '../utils/idGenerator';
|
||||
import { timestamps } from './_helpers';
|
||||
import { files, knowledgeBases } from './file';
|
||||
import { sessionGroups } from './session';
|
||||
import { users } from './user';
|
||||
|
||||
// Agent table is the main table for storing agents
|
||||
@@ -60,6 +61,10 @@ export const agents = pgTable(
|
||||
openingMessage: text('opening_message'),
|
||||
openingQuestions: text('opening_questions').array().default([]),
|
||||
|
||||
sessionGroupId: text('session_group_id').references(() => sessionGroups.id, {
|
||||
onDelete: 'set null',
|
||||
}),
|
||||
|
||||
...timestamps,
|
||||
},
|
||||
(t) => [
|
||||
@@ -68,6 +73,7 @@ export const agents = pgTable(
|
||||
index('agents_user_id_idx').on(t.userId),
|
||||
index('agents_title_idx').on(t.title),
|
||||
index('agents_description_idx').on(t.description),
|
||||
index('agents_session_group_id_idx').on(t.sessionGroupId),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user