优化用户查找逻辑,新增根据微信 UnionId 查找用户的方法,简化数据库查询
This commit is contained in:
@@ -3,19 +3,8 @@ import { sql, sum } from "drizzle-orm"
|
||||
|
||||
export const enumCfRouterCodeType = pgEnum("enum_cf_router_code_type", ['route', 'middleware'])
|
||||
|
||||
|
||||
export const testPromptTools = pgTable("TestPromptTools", {
|
||||
id: serial().primaryKey().notNull(),
|
||||
template: text().notNull(),
|
||||
args: jsonb().notNull(),
|
||||
process: jsonb().notNull(),
|
||||
type: varchar({ length: 255 }).notNull(),
|
||||
createdAt: timestamp({ withTimezone: true, mode: 'string' }).notNull().defaultNow(),
|
||||
updatedAt: timestamp({ withTimezone: true, mode: 'string' }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const aiAgent = pgTable("ai_agent", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
type: varchar({ length: 255 }).notNull(),
|
||||
baseUrl: varchar({ length: 255 }).notNull(),
|
||||
apiKey: varchar({ length: 255 }).notNull(),
|
||||
@@ -35,7 +24,7 @@ export const aiAgent = pgTable("ai_agent", {
|
||||
]);
|
||||
|
||||
export const appsTrades = pgTable("apps_trades", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
outTradeNo: varchar("out_trade_no", { length: 255 }).notNull(),
|
||||
money: integer().notNull(),
|
||||
subject: text().notNull(),
|
||||
@@ -63,7 +52,7 @@ export const cfOrgs = pgTable("cf_orgs", {
|
||||
]);
|
||||
|
||||
export const cfRouterCode = pgTable("cf_router_code", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
path: varchar({ length: 255 }).notNull(),
|
||||
key: varchar({ length: 255 }).notNull(),
|
||||
active: boolean().default(false),
|
||||
@@ -116,7 +105,7 @@ export const cfUserSecrets = pgTable("cf_user_secrets", {
|
||||
});
|
||||
|
||||
export const chatHistories = pgTable("chat_histories", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
data: json(),
|
||||
chatId: uuid(),
|
||||
chatPromptId: uuid(),
|
||||
@@ -129,7 +118,7 @@ export const chatHistories = pgTable("chat_histories", {
|
||||
});
|
||||
|
||||
export const chatPrompts = pgTable("chat_prompts", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: varchar({ length: 255 }).notNull(),
|
||||
description: text(),
|
||||
data: json(),
|
||||
@@ -141,7 +130,7 @@ export const chatPrompts = pgTable("chat_prompts", {
|
||||
});
|
||||
|
||||
export const chatSessions = pgTable("chat_sessions", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
data: json().default({}),
|
||||
chatPromptId: uuid(),
|
||||
type: varchar({ length: 255 }).default('production'),
|
||||
@@ -153,7 +142,7 @@ export const chatSessions = pgTable("chat_sessions", {
|
||||
});
|
||||
|
||||
export const fileSync = pgTable("file_sync", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
name: varchar({ length: 255 }),
|
||||
hash: varchar({ length: 255 }),
|
||||
stat: jsonb().default({}),
|
||||
@@ -166,7 +155,7 @@ export const fileSync = pgTable("file_sync", {
|
||||
]);
|
||||
|
||||
export const kvAiChatHistory = pgTable("kv_ai_chat_history", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
username: varchar({ length: 255 }).default('').notNull(),
|
||||
model: varchar({ length: 255 }).default('').notNull(),
|
||||
group: varchar({ length: 255 }).default('').notNull(),
|
||||
@@ -184,7 +173,7 @@ export const kvAiChatHistory = pgTable("kv_ai_chat_history", {
|
||||
});
|
||||
|
||||
export const kvApp = pgTable("kv_app", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
data: jsonb().default({}),
|
||||
version: varchar({ length: 255 }).default(''),
|
||||
key: varchar({ length: 255 }),
|
||||
@@ -204,7 +193,7 @@ export const kvApp = pgTable("kv_app", {
|
||||
]);
|
||||
|
||||
export const kvAppDomain = pgTable("kv_app_domain", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
domain: varchar({ length: 255 }).notNull(),
|
||||
appId: varchar({ length: 255 }),
|
||||
uid: varchar({ length: 255 }),
|
||||
@@ -218,7 +207,7 @@ export const kvAppDomain = pgTable("kv_app_domain", {
|
||||
]);
|
||||
|
||||
export const kvAppList = pgTable("kv_app_list", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
data: json().default({}),
|
||||
version: varchar({ length: 255 }).default(''),
|
||||
uid: uuid(),
|
||||
@@ -230,7 +219,7 @@ export const kvAppList = pgTable("kv_app_list", {
|
||||
});
|
||||
|
||||
export const kvConfig = pgTable("kv_config", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: text().default(''),
|
||||
key: text().default(''),
|
||||
description: text().default(''),
|
||||
@@ -268,7 +257,7 @@ export const kvGithub = pgTable("kv_github", {
|
||||
});
|
||||
|
||||
export const kvPackages = pgTable("kv_packages", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: text().default(''),
|
||||
description: text().default(''),
|
||||
tags: jsonb().default([]),
|
||||
@@ -282,7 +271,7 @@ export const kvPackages = pgTable("kv_packages", {
|
||||
});
|
||||
|
||||
export const kvPage = pgTable("kv_page", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
description: text().default(''),
|
||||
type: varchar({ length: 255 }).default(''),
|
||||
@@ -295,7 +284,7 @@ export const kvPage = pgTable("kv_page", {
|
||||
});
|
||||
|
||||
export const kvResource = pgTable("kv_resource", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
name: varchar({ length: 255 }).default(''),
|
||||
description: text().default(''),
|
||||
source: varchar({ length: 255 }).default(''),
|
||||
@@ -309,7 +298,7 @@ export const kvResource = pgTable("kv_resource", {
|
||||
});
|
||||
|
||||
export const kvVip = pgTable("kv_vip", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
userId: uuid().notNull(),
|
||||
level: varchar({ length: 255 }).default('free'),
|
||||
category: varchar({ length: 255 }).notNull(),
|
||||
@@ -324,7 +313,7 @@ export const kvVip = pgTable("kv_vip", {
|
||||
});
|
||||
|
||||
export const microAppsUpload = pgTable("micro_apps_upload", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: varchar({ length: 255 }).default(''),
|
||||
description: varchar({ length: 255 }).default(''),
|
||||
tags: jsonb().default([]),
|
||||
@@ -339,7 +328,7 @@ export const microAppsUpload = pgTable("micro_apps_upload", {
|
||||
});
|
||||
|
||||
export const microMark = pgTable("micro_mark", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: text().default(''),
|
||||
description: text().default(''),
|
||||
tags: jsonb().default([]),
|
||||
@@ -362,7 +351,7 @@ export const microMark = pgTable("micro_mark", {
|
||||
});
|
||||
|
||||
export const workShareMark = pgTable("work_share_mark", {
|
||||
id: uuid().primaryKey().notNull(),
|
||||
id: uuid().primaryKey().defaultRandom(),
|
||||
title: text().default(''),
|
||||
key: text().default(''),
|
||||
markType: text().default('md'),
|
||||
|
||||
Reference in New Issue
Block a user