♻️ refactor: refactor agent slug schema (#10561)

* fix agent schema

* fix snapshot
This commit is contained in:
Arvin Xu
2025-12-02 23:23:42 +08:00
committed by GitHub
parent a057953480
commit 0d609d199a
8 changed files with 8446 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
table agents {
id text [pk, not null]
slug varchar(100) [unique]
slug varchar(100)
title varchar(255)
description varchar(1000)
tags jsonb [default: `[]`]
@@ -27,6 +27,7 @@ table agents {
indexes {
(client_id, user_id) [name: 'client_id_user_id_unique', unique]
(slug, user_id) [name: 'agents_slug_user_id_unique', unique]
title [name: 'agents_title_idx']
description [name: 'agents_description_idx']
}

View File

@@ -171,10 +171,10 @@
"@lobehub/chat-plugins-gateway": "^1.9.0",
"@lobehub/editor": "^1.23.1",
"@lobehub/icons": "^2.43.1",
"@lobehub/market-sdk": "^0.23.0",
"@lobehub/market-sdk": "^0.23.2",
"@lobehub/tts": "^2.0.1",
"@lobehub/ui": "^2.18.3",
"@modelcontextprotocol/sdk": "^1.23.0",
"@modelcontextprotocol/sdk": "^1.24.0",
"@neondatabase/serverless": "^1.0.2",
"@next/third-parties": "^16.0.5",
"@opentelemetry/exporter-jaeger": "^2.2.0",

View File

@@ -0,0 +1,2 @@
ALTER TABLE "agents" DROP CONSTRAINT "agents_slug_unique";--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "agents_slug_user_id_unique" ON "agents" USING btree ("slug","user_id");

File diff suppressed because it is too large Load Diff

View File

@@ -392,6 +392,13 @@
"when": 1764583392443,
"tag": "0055_rename_phone_number_to_phone",
"breakpoints": true
},
{
"idx": 56,
"version": "7",
"when": 1764685643024,
"tag": "0056_update_agent_slug_index",
"breakpoints": true
}
],
"version": "6"

View File

@@ -884,12 +884,12 @@
"\nCREATE INDEX IF NOT EXISTS \"account_userId_idx\" ON \"accounts\" USING btree (\"user_id\");\n",
"\nCREATE INDEX IF NOT EXISTS \"auth_session_userId_idx\" ON \"auth_sessions\" USING btree (\"user_id\");\n",
"\nCREATE INDEX IF NOT EXISTS \"verification_identifier_idx\" ON \"verifications\" USING btree (\"identifier\");\n",
"\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'users_email_unique') THEN\n UPDATE \"users\" SET \"email\" = NULL WHERE \"email\" = '';\n ALTER TABLE \"users\" ADD CONSTRAINT \"users_email_unique\" UNIQUE (\"email\");\n END IF;\nEND $$;\n",
"\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'users_email_unique') THEN\n -- Normalize empty emails so the unique constraint can be created safely\n UPDATE \"users\" SET \"email\" = NULL WHERE \"email\" = '';\n ALTER TABLE \"users\" ADD CONSTRAINT \"users_email_unique\" UNIQUE (\"email\");\n END IF;\nEND $$;\n",
"\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'users_phone_number_unique') THEN\n ALTER TABLE \"users\" ADD CONSTRAINT \"users_phone_number_unique\" UNIQUE (\"phone_number\");\n END IF;\nEND $$;\n"
],
"bps": true,
"folderMillis": 1764579351312,
"hash": "22fb7a65764b1f3e3c1ae2ce95d448685e6a01d1fb2f8c3f925c655f0824c161"
"hash": "1d2536a9471bb87686b35053f98ba7762259a07c819dc4489bb4f3c7f27a4d8d"
},
{
"sql": [
@@ -901,5 +901,14 @@
"bps": true,
"folderMillis": 1764583392443,
"hash": "6a43d90ee1d2e1e008d1b8206f227aa05b9a2e2a8fc8c31ec608a3716c716a6c"
},
{
"sql": [
"ALTER TABLE \"agents\" DROP CONSTRAINT \"agents_slug_unique\";",
"\nCREATE UNIQUE INDEX IF NOT EXISTS \"agents_slug_user_id_unique\" ON \"agents\" USING btree (\"slug\",\"user_id\");\n"
],
"bps": true,
"folderMillis": 1764685643024,
"hash": "6e7ac7f964eb03efa3cb0d2fd35ded23e25c3abf955c4c2a51418f8daef54af9"
}
]

View File

@@ -28,9 +28,7 @@ export const agents = pgTable(
.primaryKey()
.$defaultFn(() => idGenerator('agents'))
.notNull(),
slug: varchar('slug', { length: 100 })
.$defaultFn(() => randomSlug(4))
.unique(),
slug: varchar('slug', { length: 100 }).$defaultFn(() => randomSlug(3)),
title: varchar('title', { length: 255 }),
description: varchar('description', { length: 1000 }),
tags: jsonb('tags').$type<string[]>().default([]),
@@ -65,6 +63,7 @@ export const agents = pgTable(
},
(t) => [
uniqueIndex('client_id_user_id_unique').on(t.clientId, t.userId),
uniqueIndex('agents_slug_user_id_unique').on(t.slug, t.userId),
index('agents_title_idx').on(t.title),
index('agents_description_idx').on(t.description),
],

View File

@@ -4,6 +4,9 @@ exports[`MCPClient > Stdio Transport > should list tools via stdio 1`] = `
[
{
"description": "Echoes back a message with 'Hello' prefix",
"execution": {
"taskSupport": "forbidden",
},
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
@@ -22,6 +25,9 @@ exports[`MCPClient > Stdio Transport > should list tools via stdio 1`] = `
},
{
"description": "Lists all available tools and methods",
"execution": {
"taskSupport": "forbidden",
},
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {},
@@ -31,6 +37,9 @@ exports[`MCPClient > Stdio Transport > should list tools via stdio 1`] = `
},
{
"description": "Adds two numbers",
"execution": {
"taskSupport": "forbidden",
},
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,