You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
1.5 KiB

import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
// ============ AgentDocumentType ENUM ============
export const AgentDocumentTypes = ["memory", "document"] as const;
export type AgentDocumentType = (typeof AgentDocumentTypes)[number];
// ============ AgentDocument(Agent 文档表)============
export const agentDocuments = sqliteTable(
"agent_documents",
{
id: integer("id").primaryKey({ autoIncrement: true }),
userId: integer("user_id").notNull(),
agentId: integer("agent_id"),
sessionId: text("session_id"),
type: text("type", { length: 20 }).notNull().default("document"),
title: text("title", { length: 255 }).notNull(),
content: text("content").notNull(),
summary: text("summary"),
tags: text("tags"),
disabled: integer("disabled", { mode: "boolean" }).notNull().default(false),
createdAt: integer("created_at", { mode: "timestamp_ms" })
.defaultNow()
.notNull(),
updatedAt: integer("updated_at", { mode: "timestamp_ms" })
.defaultNow()
.$onUpdate(() => new Date())
.notNull(),
},
(table) => [
index("idx_agent_documents_user_id").on(table.userId),
index("idx_agent_documents_user_type").on(table.userId, table.type),
index("idx_agent_documents_user_session").on(table.userId, table.sessionId),
index("idx_agent_documents_user_agent").on(table.userId, table.agentId),
],
);
export type AgentDocument = typeof agentDocuments.$inferSelect;
export type NewAgentDocument = typeof agentDocuments.$inferInsert;