mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-12-02 17:58:14 +00:00
34 lines
966 B
TypeScript
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`'[]'`),
|
|
});
|