mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2026-01-17 11:25:45 +00:00
feat(db): migrate schema
This commit is contained in:
@@ -1,26 +1,22 @@
|
|||||||
import { sql } from 'drizzle-orm';
|
import { sql } from 'drizzle-orm';
|
||||||
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
|
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';
|
||||||
import { Document } from '@langchain/core/documents';
|
|
||||||
|
|
||||||
export const messages = sqliteTable('messages', {
|
export const messages = sqliteTable('messages', {
|
||||||
id: integer('id').primaryKey(),
|
id: integer('id').primaryKey(),
|
||||||
role: text('type', { enum: ['assistant', 'user', 'source'] }).notNull(),
|
|
||||||
chatId: text('chatId').notNull(),
|
|
||||||
createdAt: text('createdAt')
|
|
||||||
.notNull()
|
|
||||||
.default(sql`CURRENT_TIMESTAMP`),
|
|
||||||
messageId: text('messageId').notNull(),
|
messageId: text('messageId').notNull(),
|
||||||
|
chatId: text('chatId').notNull(),
|
||||||
content: text('content'),
|
backendId: text('backendId').notNull(),
|
||||||
|
query: text('query').notNull(),
|
||||||
sources: text('sources', {
|
createdAt: text('createdAt').notNull(),
|
||||||
mode: 'json',
|
responseBlocks: text('responseBlocks', { mode: 'json' })
|
||||||
})
|
.$type<Block[]>()
|
||||||
.$type<Document[]>()
|
|
||||||
.default(sql`'[]'`),
|
.default(sql`'[]'`),
|
||||||
|
status: text({ enum: ['answering', 'completed', 'error'] }).default(
|
||||||
|
'answering',
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
interface File {
|
interface DBFile {
|
||||||
name: string;
|
name: string;
|
||||||
fileId: string;
|
fileId: string;
|
||||||
}
|
}
|
||||||
@@ -31,6 +27,6 @@ export const chats = sqliteTable('chats', {
|
|||||||
createdAt: text('createdAt').notNull(),
|
createdAt: text('createdAt').notNull(),
|
||||||
focusMode: text('focusMode').notNull(),
|
focusMode: text('focusMode').notNull(),
|
||||||
files: text('files', { mode: 'json' })
|
files: text('files', { mode: 'json' })
|
||||||
.$type<File[]>()
|
.$type<DBFile[]>()
|
||||||
.default(sql`'[]'`),
|
.default(sql`'[]'`),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user