Files
Perplexica/src/lib/db/schema.ts
2025-11-23 19:22:11 +05:30

34 lines
966 B
TypeScript

import { sql } from 'drizzle-orm';
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
import { Block } from '../types';
export const messages = sqliteTable('messages', {
id: integer('id').primaryKey(),
messageId: text('messageId').notNull(),
chatId: text('chatId').notNull(),
backendId: text('backendId').notNull(),
query: text('query').notNull(),
createdAt: text('createdAt').notNull(),
responseBlocks: text('responseBlocks', { mode: 'json' })
.$type<Block[]>()
.default(sql`'[]'`),
status: text({ enum: ['answering', 'completed', 'error'] }).default(
'answering',
),
});
interface DBFile {
name: string;
fileId: string;
}
export const chats = sqliteTable('chats', {
id: text('id').primaryKey(),
title: text('title').notNull(),
createdAt: text('createdAt').notNull(),
focusMode: text('focusMode').notNull(),
files: text('files', { mode: 'json' })
.$type<DBFile[]>()
.default(sql`'[]'`),
});