Perplexica/src/db/schema.ts

29 lines
759 B
TypeScript
Raw Normal View History

2024-11-23 15:04:19 +05:30
import { sql } from 'drizzle-orm';
2024-06-29 11:08:11 +05:30
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
export const messages = sqliteTable('messages', {
id: integer('id').primaryKey(),
content: text('content').notNull(),
chatId: text('chatId').notNull(),
messageId: text('messageId').notNull(),
role: text('type', { enum: ['assistant', 'user'] }),
metadata: text('metadata', {
mode: 'json',
}),
});
2024-11-23 15:04:19 +05:30
interface File {
name: string;
fileId: string;
}
2024-06-29 11:08:11 +05:30
export const chats = sqliteTable('chats', {
id: text('id').primaryKey(),
title: text('title').notNull(),
createdAt: text('createdAt').notNull(),
focusMode: text('focusMode').notNull(),
2024-11-23 15:04:19 +05:30
files: text('files', { mode: 'json' })
.$type<File[]>()
.default(sql`'[]'`),
2024-06-29 11:08:11 +05:30
});