mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 14:43:06 +08:00
9fb16bc842
* WIP * AI module - init * WIP * sync * WIP * refactor naming * new columns * sync * sync * fix search bug * stream response * WIP * feat embeddings sync * refine * Add workspaceId to page events * refine * WIP * add translation string * sync * reset ai answer on query change * hide AI search in cloud * capture streaming error * sync
23 lines
660 B
TypeScript
23 lines
660 B
TypeScript
import { sql } from 'kysely';
|
|
import { KyselyDB } from '@docmost/db/types/kysely.types';
|
|
|
|
export async function isPageEmbeddingsTableExists(db: KyselyDB) {
|
|
return tableExists({ db, tableName: 'page_embeddings' });
|
|
}
|
|
|
|
export async function tableExists(opts: {
|
|
db: KyselyDB;
|
|
tableName: string;
|
|
}): Promise<boolean> {
|
|
const { db, tableName } = opts;
|
|
const result = await sql<{ exists: boolean }>`
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM information_schema.tables
|
|
WHERE table_schema = COALESCE(current_schema(), 'public')
|
|
AND table_name = ${tableName}
|
|
) as exists
|
|
`.execute(db);
|
|
|
|
return result.rows[0]?.exists ?? false;
|
|
}
|