diff --git a/Dockerfile.database b/Dockerfile.database index 5d7303c0bb58..9b44b3d18a0d 100644 --- a/Dockerfile.database +++ b/Dockerfile.database @@ -116,7 +116,7 @@ COPY --from=builder /deps/node_modules/pg /app/node_modules/pg COPY --from=builder /deps/node_modules/drizzle-orm /app/node_modules/drizzle-orm # Copy database migrations -COPY --from=builder /app/src/database/server/migrations /app/migrations +COPY --from=builder /app/src/database/migrations /app/migrations COPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs COPY --from=builder /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js diff --git a/drizzle.config.ts b/drizzle.config.ts index 2f6460d0c92f..3d71493a53a8 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -22,8 +22,8 @@ export default { url: connectionString, }, dialect: 'postgresql', - out: './src/database/server/migrations', + out: './src/database/migrations', - schema: './src/database/server/schemas/lobechat', + schema: './src/database/schemas', strict: true, } satisfies Config; diff --git a/scripts/migrateServerDB/index.ts b/scripts/migrateServerDB/index.ts index 4858f966c41c..ccc7ed562866 100644 --- a/scripts/migrateServerDB/index.ts +++ b/scripts/migrateServerDB/index.ts @@ -11,7 +11,7 @@ dotenv.config(); const runMigrations = async () => { await migrator.migrate(serverDB, { - migrationsFolder: join(__dirname, '../../src/database/server/migrations'), + migrationsFolder: join(__dirname, '../../src/database/migrations'), }); console.log('✅ database migration pass.'); // eslint-disable-next-line unicorn/no-process-exit diff --git a/src/database/server/migrations/0000_init.sql b/src/database/migrations/0000_init.sql similarity index 100% rename from src/database/server/migrations/0000_init.sql rename to src/database/migrations/0000_init.sql diff --git a/src/database/server/migrations/0001_add_client_id.sql b/src/database/migrations/0001_add_client_id.sql similarity index 100% rename from src/database/server/migrations/0001_add_client_id.sql rename to src/database/migrations/0001_add_client_id.sql diff --git a/src/database/server/migrations/0002_amusing_puma.sql b/src/database/migrations/0002_amusing_puma.sql similarity index 100% rename from src/database/server/migrations/0002_amusing_puma.sql rename to src/database/migrations/0002_amusing_puma.sql diff --git a/src/database/server/migrations/0003_naive_echo.sql b/src/database/migrations/0003_naive_echo.sql similarity index 100% rename from src/database/server/migrations/0003_naive_echo.sql rename to src/database/migrations/0003_naive_echo.sql diff --git a/src/database/server/migrations/0004_add_next_auth.sql b/src/database/migrations/0004_add_next_auth.sql similarity index 100% rename from src/database/server/migrations/0004_add_next_auth.sql rename to src/database/migrations/0004_add_next_auth.sql diff --git a/src/database/server/migrations/0005_pgvector.sql b/src/database/migrations/0005_pgvector.sql similarity index 100% rename from src/database/server/migrations/0005_pgvector.sql rename to src/database/migrations/0005_pgvector.sql diff --git a/src/database/server/migrations/0006_add_knowledge_base.sql b/src/database/migrations/0006_add_knowledge_base.sql similarity index 100% rename from src/database/server/migrations/0006_add_knowledge_base.sql rename to src/database/migrations/0006_add_knowledge_base.sql diff --git a/src/database/server/migrations/0007_fix_embedding_table.sql b/src/database/migrations/0007_fix_embedding_table.sql similarity index 100% rename from src/database/server/migrations/0007_fix_embedding_table.sql rename to src/database/migrations/0007_fix_embedding_table.sql diff --git a/src/database/server/migrations/0008_add_rag_evals.sql b/src/database/migrations/0008_add_rag_evals.sql similarity index 100% rename from src/database/server/migrations/0008_add_rag_evals.sql rename to src/database/migrations/0008_add_rag_evals.sql diff --git a/src/database/server/migrations/0009_remove_unused_user_tables.sql b/src/database/migrations/0009_remove_unused_user_tables.sql similarity index 100% rename from src/database/server/migrations/0009_remove_unused_user_tables.sql rename to src/database/migrations/0009_remove_unused_user_tables.sql diff --git a/src/database/server/migrations/0010_add_accessed_at_and_clean_tables.sql b/src/database/migrations/0010_add_accessed_at_and_clean_tables.sql similarity index 100% rename from src/database/server/migrations/0010_add_accessed_at_and_clean_tables.sql rename to src/database/migrations/0010_add_accessed_at_and_clean_tables.sql diff --git a/src/database/server/migrations/0011_add_topic_history_summary.sql b/src/database/migrations/0011_add_topic_history_summary.sql similarity index 100% rename from src/database/server/migrations/0011_add_topic_history_summary.sql rename to src/database/migrations/0011_add_topic_history_summary.sql diff --git a/src/database/server/migrations/0012_add_thread.sql b/src/database/migrations/0012_add_thread.sql similarity index 100% rename from src/database/server/migrations/0012_add_thread.sql rename to src/database/migrations/0012_add_thread.sql diff --git a/src/database/server/migrations/meta/0000_snapshot.json b/src/database/migrations/meta/0000_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0000_snapshot.json rename to src/database/migrations/meta/0000_snapshot.json diff --git a/src/database/server/migrations/meta/0001_snapshot.json b/src/database/migrations/meta/0001_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0001_snapshot.json rename to src/database/migrations/meta/0001_snapshot.json diff --git a/src/database/server/migrations/meta/0002_snapshot.json b/src/database/migrations/meta/0002_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0002_snapshot.json rename to src/database/migrations/meta/0002_snapshot.json diff --git a/src/database/server/migrations/meta/0003_snapshot.json b/src/database/migrations/meta/0003_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0003_snapshot.json rename to src/database/migrations/meta/0003_snapshot.json diff --git a/src/database/server/migrations/meta/0004_snapshot.json b/src/database/migrations/meta/0004_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0004_snapshot.json rename to src/database/migrations/meta/0004_snapshot.json diff --git a/src/database/server/migrations/meta/0005_snapshot.json b/src/database/migrations/meta/0005_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0005_snapshot.json rename to src/database/migrations/meta/0005_snapshot.json diff --git a/src/database/server/migrations/meta/0006_snapshot.json b/src/database/migrations/meta/0006_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0006_snapshot.json rename to src/database/migrations/meta/0006_snapshot.json diff --git a/src/database/server/migrations/meta/0007_snapshot.json b/src/database/migrations/meta/0007_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0007_snapshot.json rename to src/database/migrations/meta/0007_snapshot.json diff --git a/src/database/server/migrations/meta/0008_snapshot.json b/src/database/migrations/meta/0008_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0008_snapshot.json rename to src/database/migrations/meta/0008_snapshot.json diff --git a/src/database/server/migrations/meta/0009_snapshot.json b/src/database/migrations/meta/0009_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0009_snapshot.json rename to src/database/migrations/meta/0009_snapshot.json diff --git a/src/database/server/migrations/meta/0010_snapshot.json b/src/database/migrations/meta/0010_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0010_snapshot.json rename to src/database/migrations/meta/0010_snapshot.json diff --git a/src/database/server/migrations/meta/0011_snapshot.json b/src/database/migrations/meta/0011_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0011_snapshot.json rename to src/database/migrations/meta/0011_snapshot.json diff --git a/src/database/server/migrations/meta/0012_snapshot.json b/src/database/migrations/meta/0012_snapshot.json similarity index 100% rename from src/database/server/migrations/meta/0012_snapshot.json rename to src/database/migrations/meta/0012_snapshot.json diff --git a/src/database/server/migrations/meta/_journal.json b/src/database/migrations/meta/_journal.json similarity index 100% rename from src/database/server/migrations/meta/_journal.json rename to src/database/migrations/meta/_journal.json diff --git a/src/database/server/schemas/lobechat/_helpers.ts b/src/database/schemas/_helpers.ts similarity index 100% rename from src/database/server/schemas/lobechat/_helpers.ts rename to src/database/schemas/_helpers.ts diff --git a/src/database/server/schemas/lobechat/agent.ts b/src/database/schemas/agent.ts similarity index 97% rename from src/database/server/schemas/lobechat/agent.ts rename to src/database/schemas/agent.ts index ca0715408064..c26869d97e17 100644 --- a/src/database/server/schemas/lobechat/agent.ts +++ b/src/database/schemas/agent.ts @@ -4,7 +4,7 @@ import { createInsertSchema } from 'drizzle-zod'; import { LobeAgentChatConfig, LobeAgentTTSConfig } from '@/types/agent'; -import { idGenerator, randomSlug } from '../../utils/idGenerator'; +import { idGenerator, randomSlug } from '@/database/utils/idGenerator'; import { timestamps } from './_helpers'; import { files, knowledgeBases } from './file'; import { users } from './user'; diff --git a/src/database/server/schemas/lobechat/asyncTask.ts b/src/database/schemas/asyncTask.ts similarity index 100% rename from src/database/server/schemas/lobechat/asyncTask.ts rename to src/database/schemas/asyncTask.ts diff --git a/src/database/server/schemas/lobechat/file.ts b/src/database/schemas/file.ts similarity index 98% rename from src/database/server/schemas/lobechat/file.ts rename to src/database/schemas/file.ts index e046d3ba0af2..d3180c5dbe50 100644 --- a/src/database/server/schemas/lobechat/file.ts +++ b/src/database/schemas/file.ts @@ -11,7 +11,7 @@ import { } from 'drizzle-orm/pg-core'; import { createInsertSchema } from 'drizzle-zod'; -import { idGenerator } from '../../utils/idGenerator'; +import { idGenerator } from '@/database/utils/idGenerator'; import { accessedAt, createdAt, timestamps } from './_helpers'; import { asyncTasks } from './asyncTask'; import { chunks } from './rag'; diff --git a/src/database/server/schemas/lobechat/index.ts b/src/database/schemas/index.ts similarity index 100% rename from src/database/server/schemas/lobechat/index.ts rename to src/database/schemas/index.ts diff --git a/src/database/server/schemas/lobechat/message.ts b/src/database/schemas/message.ts similarity index 98% rename from src/database/server/schemas/lobechat/message.ts rename to src/database/schemas/message.ts index 1bd4ed952b84..c399199ec3cb 100644 --- a/src/database/server/schemas/lobechat/message.ts +++ b/src/database/schemas/message.ts @@ -12,7 +12,7 @@ import { } from 'drizzle-orm/pg-core'; import { createSelectSchema } from 'drizzle-zod'; -import { idGenerator } from '../../utils/idGenerator'; +import { idGenerator } from '@/database/utils/idGenerator'; import { timestamps } from './_helpers'; import { agents } from './agent'; import { files } from './file'; diff --git a/src/database/server/schemas/lobechat/nextauth.ts b/src/database/schemas/nextauth.ts similarity index 100% rename from src/database/server/schemas/lobechat/nextauth.ts rename to src/database/schemas/nextauth.ts diff --git a/src/database/server/schemas/lobechat/rag.ts b/src/database/schemas/rag.ts similarity index 100% rename from src/database/server/schemas/lobechat/rag.ts rename to src/database/schemas/rag.ts diff --git a/src/database/server/schemas/lobechat/ragEvals.ts b/src/database/schemas/ragEvals.ts similarity index 100% rename from src/database/server/schemas/lobechat/ragEvals.ts rename to src/database/schemas/ragEvals.ts diff --git a/src/database/server/schemas/lobechat/relations.ts b/src/database/schemas/relations.ts similarity index 100% rename from src/database/server/schemas/lobechat/relations.ts rename to src/database/schemas/relations.ts diff --git a/src/database/server/schemas/lobechat/session.ts b/src/database/schemas/session.ts similarity index 96% rename from src/database/server/schemas/lobechat/session.ts rename to src/database/schemas/session.ts index 36dd98f1a0eb..91f9f18d5bb3 100644 --- a/src/database/server/schemas/lobechat/session.ts +++ b/src/database/schemas/session.ts @@ -2,7 +2,7 @@ import { boolean, integer, pgTable, text, unique, uniqueIndex, varchar } from 'drizzle-orm/pg-core'; import { createInsertSchema } from 'drizzle-zod'; -import { idGenerator, randomSlug } from '../../utils/idGenerator'; +import { idGenerator, randomSlug } from '@/database/utils/idGenerator'; import { timestamps } from './_helpers'; import { users } from './user'; diff --git a/src/database/server/schemas/lobechat/topic.ts b/src/database/schemas/topic.ts similarity index 97% rename from src/database/server/schemas/lobechat/topic.ts rename to src/database/schemas/topic.ts index a000828e6bc9..705682fcf99b 100644 --- a/src/database/server/schemas/lobechat/topic.ts +++ b/src/database/schemas/topic.ts @@ -2,7 +2,7 @@ import { boolean, jsonb, pgTable, text, unique } from 'drizzle-orm/pg-core'; import { createInsertSchema } from 'drizzle-zod'; -import { idGenerator } from '../../utils/idGenerator'; +import { idGenerator } from '@/database/utils/idGenerator'; import { timestamps, timestamptz } from './_helpers'; import { sessions } from './session'; import { users } from './user'; diff --git a/src/database/server/schemas/lobechat/user.ts b/src/database/schemas/user.ts similarity index 100% rename from src/database/server/schemas/lobechat/user.ts rename to src/database/schemas/user.ts diff --git a/src/database/server/core/db.ts b/src/database/server/core/db.ts index c0eb1f69b064..a48ffda3da02 100644 --- a/src/database/server/core/db.ts +++ b/src/database/server/core/db.ts @@ -7,7 +7,7 @@ import ws from 'ws'; import { serverDBEnv } from '@/config/db'; import { isServerMode } from '@/const/version'; -import * as schema from '../schemas/lobechat'; +import * as schema from '../../schemas'; export const getDBInstance = (): NeonDatabase => { if (!isServerMode) return {} as any; diff --git a/src/database/server/core/dbForTest.ts b/src/database/server/core/dbForTest.ts index 55528c84a3cc..c4194f24edeb 100644 --- a/src/database/server/core/dbForTest.ts +++ b/src/database/server/core/dbForTest.ts @@ -9,7 +9,7 @@ import ws from 'ws'; import { serverDBEnv } from '@/config/db'; -import * as schema from '../schemas/lobechat'; +import * as schema from '../../schemas'; export const getTestDBInstance = async () => { let connectionString = serverDBEnv.DATABASE_TEST_URL; @@ -24,7 +24,7 @@ export const getTestDBInstance = async () => { const db = nodeDrizzle(client, { schema }); await nodeMigrator.migrate(db, { - migrationsFolder: join(__dirname, '../migrations'), + migrationsFolder: join(__dirname, '../../migrations'), }); return db; diff --git a/src/database/server/models/__tests__/_test_template.ts b/src/database/server/models/__tests__/_test_template.ts index 3a368d6f8cbe..ee43feaa9907 100644 --- a/src/database/server/models/__tests__/_test_template.ts +++ b/src/database/server/models/__tests__/_test_template.ts @@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { getTestDBInstance } from '@/database/server/core/dbForTest'; -import { sessionGroups, users } from '../../schemas/lobechat'; +import { sessionGroups, users } from '../../../schemas'; import { SessionGroupModel } from '../sessionGroup'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/agent.test.ts b/src/database/server/models/__tests__/agent.test.ts index f683106749c1..3312e8087ef9 100644 --- a/src/database/server/models/__tests__/agent.test.ts +++ b/src/database/server/models/__tests__/agent.test.ts @@ -13,7 +13,7 @@ import { knowledgeBases, sessions, users, -} from '../../schemas/lobechat'; +} from '../../../schemas'; import { AgentModel } from '../agent'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/asyncTask.test.ts b/src/database/server/models/__tests__/asyncTask.test.ts index 3d587af9c8b4..8c51f5dc3c49 100644 --- a/src/database/server/models/__tests__/asyncTask.test.ts +++ b/src/database/server/models/__tests__/asyncTask.test.ts @@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { getTestDBInstance } from '@/database/server/core/dbForTest'; import { AsyncTaskStatus, AsyncTaskType } from '@/types/asyncTask'; -import { asyncTasks, users } from '../../schemas/lobechat'; +import { asyncTasks, users } from '../../../schemas'; import { ASYNC_TASK_TIMEOUT, AsyncTaskModel } from '../asyncTask'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/chunk.test.ts b/src/database/server/models/__tests__/chunk.test.ts index 4e94c35a55a2..3cf20b1bae89 100644 --- a/src/database/server/models/__tests__/chunk.test.ts +++ b/src/database/server/models/__tests__/chunk.test.ts @@ -11,7 +11,7 @@ import { files, unstructuredChunks, users, -} from '../../schemas/lobechat'; +} from '../../../schemas'; import { ChunkModel } from '../chunk'; import { codeEmbedding, designThinkingQuery, designThinkingQuery2 } from './fixtures/embedding'; diff --git a/src/database/server/models/__tests__/file.test.ts b/src/database/server/models/__tests__/file.test.ts index b02a89bd4ebb..4fcea38cd482 100644 --- a/src/database/server/models/__tests__/file.test.ts +++ b/src/database/server/models/__tests__/file.test.ts @@ -12,7 +12,7 @@ import { knowledgeBaseFiles, knowledgeBases, users, -} from '../../schemas/lobechat'; +} from '../../../schemas'; import { FileModel } from '../file'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/knowledgeBase.test.ts b/src/database/server/models/__tests__/knowledgeBase.test.ts index 53fa49eeec0d..38bea2345a62 100644 --- a/src/database/server/models/__tests__/knowledgeBase.test.ts +++ b/src/database/server/models/__tests__/knowledgeBase.test.ts @@ -12,7 +12,7 @@ import { knowledgeBaseFiles, knowledgeBases, users, -} from '../../schemas/lobechat'; +} from '../../../schemas'; import { KnowledgeBaseModel } from '../knowledgeBase'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/message.test.ts b/src/database/server/models/__tests__/message.test.ts index 9079f8bb6a2a..262082d3320d 100644 --- a/src/database/server/models/__tests__/message.test.ts +++ b/src/database/server/models/__tests__/message.test.ts @@ -13,7 +13,7 @@ import { sessions, topics, users, -} from '../../schemas/lobechat'; +} from '../../../schemas'; import { MessageModel } from '../message'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/nextauth.test.ts b/src/database/server/models/__tests__/nextauth.test.ts index dcb84c8eb9b0..6038f11f1c73 100644 --- a/src/database/server/models/__tests__/nextauth.test.ts +++ b/src/database/server/models/__tests__/nextauth.test.ts @@ -15,7 +15,7 @@ import { nextauthSessions, nextauthVerificationTokens, users, -} from '@/database/server/schemas/lobechat'; +} from '@/database/schemas'; import { LobeNextAuthDbAdapter } from '@/libs/next-auth/adapter'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/plugin.test.ts b/src/database/server/models/__tests__/plugin.test.ts index 821864238533..449cac8cd73b 100644 --- a/src/database/server/models/__tests__/plugin.test.ts +++ b/src/database/server/models/__tests__/plugin.test.ts @@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { getTestDBInstance } from '@/database/server/core/dbForTest'; -import { NewInstalledPlugin, installedPlugins, users } from '../../schemas/lobechat'; +import { NewInstalledPlugin, installedPlugins, users } from '../../../schemas'; import { PluginModel } from '../plugin'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/session.test.ts b/src/database/server/models/__tests__/session.test.ts index 0a91adb6f7f8..bccea65f9277 100644 --- a/src/database/server/models/__tests__/session.test.ts +++ b/src/database/server/models/__tests__/session.test.ts @@ -13,8 +13,8 @@ import { sessions, topics, users, -} from '../../schemas/lobechat'; -import { idGenerator } from '../../utils/idGenerator'; +} from '../../../schemas'; +import { idGenerator } from '@/database/utils/idGenerator'; import { SessionModel } from '../session'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/sessionGroup.test.ts b/src/database/server/models/__tests__/sessionGroup.test.ts index 2dd58c2c755e..a94be4447526 100644 --- a/src/database/server/models/__tests__/sessionGroup.test.ts +++ b/src/database/server/models/__tests__/sessionGroup.test.ts @@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { getTestDBInstance } from '@/database/server/core/dbForTest'; -import { sessionGroups, users } from '../../schemas/lobechat'; +import { sessionGroups, users } from '../../../schemas'; import { SessionGroupModel } from '../sessionGroup'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/topic.test.ts b/src/database/server/models/__tests__/topic.test.ts index ee2de927930b..ef205f117986 100644 --- a/src/database/server/models/__tests__/topic.test.ts +++ b/src/database/server/models/__tests__/topic.test.ts @@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { getTestDBInstance } from '@/database/server/core/dbForTest'; -import { messages, sessions, topics, users } from '../../schemas/lobechat'; +import { messages, sessions, topics, users } from '../../../schemas'; import { CreateTopicParams, TopicModel } from '../topic'; let serverDB = await getTestDBInstance(); diff --git a/src/database/server/models/__tests__/user.test.ts b/src/database/server/models/__tests__/user.test.ts index 60c945d9fe20..1004e5590cc1 100644 --- a/src/database/server/models/__tests__/user.test.ts +++ b/src/database/server/models/__tests__/user.test.ts @@ -7,7 +7,7 @@ import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt'; import { UserGuide, UserPreference } from '@/types/user'; import { UserSettings } from '@/types/user/settings'; -import { userSettings, users } from '../../schemas/lobechat'; +import { userSettings, users } from '../../../schemas'; import { SessionModel } from '../session'; import { UserModel } from '../user'; diff --git a/src/database/server/models/_template.ts b/src/database/server/models/_template.ts index 3699bf87a346..82c0efa3da2d 100644 --- a/src/database/server/models/_template.ts +++ b/src/database/server/models/_template.ts @@ -3,7 +3,7 @@ import { and, desc } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server'; -import { NewSessionGroup, SessionGroupItem, sessionGroups } from '../schemas/lobechat'; +import { NewSessionGroup, SessionGroupItem, sessionGroups } from '../../schemas'; export class TemplateModel { private userId: string; diff --git a/src/database/server/models/agent.ts b/src/database/server/models/agent.ts index a65eb21cdfb8..34c627016c0b 100644 --- a/src/database/server/models/agent.ts +++ b/src/database/server/models/agent.ts @@ -9,7 +9,7 @@ import { agentsToSessions, files, knowledgeBases, -} from '@/database/server/schemas/lobechat'; +} from '@/database/schemas'; export class AgentModel { private userId: string; diff --git a/src/database/server/models/asyncTask.ts b/src/database/server/models/asyncTask.ts index 94235505b3cb..48ed6b210909 100644 --- a/src/database/server/models/asyncTask.ts +++ b/src/database/server/models/asyncTask.ts @@ -9,7 +9,7 @@ import { AsyncTaskType, } from '@/types/asyncTask'; -import { AsyncTaskSelectItem, NewAsyncTaskItem, asyncTasks } from '../schemas/lobechat'; +import { AsyncTaskSelectItem, NewAsyncTaskItem, asyncTasks } from '../../schemas'; // set timeout to about 5 minutes, and give 2s padding time export const ASYNC_TASK_TIMEOUT = 298 * 1000; diff --git a/src/database/server/models/chunk.ts b/src/database/server/models/chunk.ts index 9c4dc7000def..a00c434b4b2a 100644 --- a/src/database/server/models/chunk.ts +++ b/src/database/server/models/chunk.ts @@ -13,7 +13,7 @@ import { fileChunks, files, unstructuredChunks, -} from '../schemas/lobechat'; +} from '../../schemas'; export class ChunkModel { private userId: string; diff --git a/src/database/server/models/embedding.ts b/src/database/server/models/embedding.ts index ffe36ba6a4ef..45f5980ebf88 100644 --- a/src/database/server/models/embedding.ts +++ b/src/database/server/models/embedding.ts @@ -3,7 +3,7 @@ import { and } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server'; -import { NewEmbeddingsItem, embeddings } from '../schemas/lobechat'; +import { NewEmbeddingsItem, embeddings } from '../../schemas'; export class EmbeddingModel { private userId: string; diff --git a/src/database/server/models/file.ts b/src/database/server/models/file.ts index 189065490174..8a01bfe71400 100644 --- a/src/database/server/models/file.ts +++ b/src/database/server/models/file.ts @@ -16,7 +16,7 @@ import { files, globalFiles, knowledgeBaseFiles, -} from '../schemas/lobechat'; +} from '../../schemas'; export class FileModel { private readonly userId: string; diff --git a/src/database/server/models/knowledgeBase.ts b/src/database/server/models/knowledgeBase.ts index 1dd852f70f1e..844558667a5b 100644 --- a/src/database/server/models/knowledgeBase.ts +++ b/src/database/server/models/knowledgeBase.ts @@ -4,7 +4,7 @@ import { and, desc } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server'; import { KnowledgeBaseItem } from '@/types/knowledgeBase'; -import { NewKnowledgeBase, knowledgeBaseFiles, knowledgeBases } from '../schemas/lobechat'; +import { NewKnowledgeBase, knowledgeBaseFiles, knowledgeBases } from '../../schemas'; export class KnowledgeBaseModel { private userId: string; diff --git a/src/database/server/models/message.ts b/src/database/server/models/message.ts index 24670a680e9d..e4e43e3b01a3 100644 --- a/src/database/server/models/message.ts +++ b/src/database/server/models/message.ts @@ -2,7 +2,7 @@ import { count } from 'drizzle-orm'; import { and, asc, desc, eq, gte, inArray, isNull, like, lt } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server/core/db'; -import { idGenerator } from '@/database/server/utils/idGenerator'; +import { idGenerator } from '@/database/utils/idGenerator'; import { getFullFileUrl } from '@/server/utils/files'; import { ChatFileItem, @@ -28,7 +28,7 @@ import { messageTranslates, messages, messagesFiles, -} from '../schemas/lobechat'; +} from '../../schemas'; export interface QueryMessageParams { current?: number; diff --git a/src/database/server/models/plugin.ts b/src/database/server/models/plugin.ts index 99089827c0cf..7b07c9a8a873 100644 --- a/src/database/server/models/plugin.ts +++ b/src/database/server/models/plugin.ts @@ -2,7 +2,7 @@ import { and, desc, eq } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server'; -import { InstalledPluginItem, NewInstalledPlugin, installedPlugins } from '../schemas/lobechat'; +import { InstalledPluginItem, NewInstalledPlugin, installedPlugins } from '../../schemas'; export class PluginModel { private userId: string; diff --git a/src/database/server/models/ragEval/dataset.ts b/src/database/server/models/ragEval/dataset.ts index 2c506fea1845..18c9a7ca7deb 100644 --- a/src/database/server/models/ragEval/dataset.ts +++ b/src/database/server/models/ragEval/dataset.ts @@ -1,7 +1,7 @@ import { and, desc, eq } from 'drizzle-orm'; import { serverDB } from '@/database/server'; -import { NewEvalDatasetsItem, evalDatasets } from '@/database/server/schemas/lobechat'; +import { NewEvalDatasetsItem, evalDatasets } from '@/database/schemas'; import { RAGEvalDataSetItem } from '@/types/eval'; export class EvalDatasetModel { diff --git a/src/database/server/models/ragEval/datasetRecord.ts b/src/database/server/models/ragEval/datasetRecord.ts index dfd2c3c1189e..6b61fa75f974 100644 --- a/src/database/server/models/ragEval/datasetRecord.ts +++ b/src/database/server/models/ragEval/datasetRecord.ts @@ -5,7 +5,7 @@ import { NewEvalDatasetRecordsItem, evalDatasetRecords, files, -} from '@/database/server/schemas/lobechat'; +} from '@/database/schemas'; import { EvalDatasetRecordRefFile } from '@/types/eval'; export class EvalDatasetRecordModel { diff --git a/src/database/server/models/ragEval/evaluation.ts b/src/database/server/models/ragEval/evaluation.ts index a543aaa5a200..73f5264c95cf 100644 --- a/src/database/server/models/ragEval/evaluation.ts +++ b/src/database/server/models/ragEval/evaluation.ts @@ -6,7 +6,7 @@ import { evalDatasets, evalEvaluation, evaluationRecords, -} from '@/database/server/schemas/lobechat'; +} from '@/database/schemas'; import { EvalEvaluationStatus, RAGEvalEvaluationItem } from '@/types/eval'; export class EvalEvaluationModel { diff --git a/src/database/server/models/ragEval/evaluationRecord.ts b/src/database/server/models/ragEval/evaluationRecord.ts index b8a7374697a1..8edfa0b193a5 100644 --- a/src/database/server/models/ragEval/evaluationRecord.ts +++ b/src/database/server/models/ragEval/evaluationRecord.ts @@ -1,7 +1,7 @@ import { and, eq } from 'drizzle-orm'; import { serverDB } from '@/database/server'; -import { NewEvaluationRecordsItem, evaluationRecords } from '@/database/server/schemas/lobechat'; +import { NewEvaluationRecordsItem, evaluationRecords } from '@/database/schemas'; export class EvaluationRecordModel { private userId: string; diff --git a/src/database/server/models/session.ts b/src/database/server/models/session.ts index 01d4bb287d86..a41b78f89ca7 100644 --- a/src/database/server/models/session.ts +++ b/src/database/server/models/session.ts @@ -18,8 +18,8 @@ import { agentsToSessions, sessionGroups, sessions, -} from '../schemas/lobechat'; -import { idGenerator } from '../utils/idGenerator'; +} from '../../schemas'; +import { idGenerator } from '@/database/utils/idGenerator'; export class SessionModel { private userId: string; diff --git a/src/database/server/models/sessionGroup.ts b/src/database/server/models/sessionGroup.ts index ab257184a946..16df2a2fab37 100644 --- a/src/database/server/models/sessionGroup.ts +++ b/src/database/server/models/sessionGroup.ts @@ -2,9 +2,9 @@ import { eq } from 'drizzle-orm'; import { and, asc, desc } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server'; -import { idGenerator } from '@/database/server/utils/idGenerator'; +import { idGenerator } from '@/database/utils/idGenerator'; -import { SessionGroupItem, sessionGroups } from '../schemas/lobechat'; +import { SessionGroupItem, sessionGroups } from '../../schemas'; export class SessionGroupModel { private userId: string; diff --git a/src/database/server/models/thread.ts b/src/database/server/models/thread.ts index c8bc4542cb52..791510470e17 100644 --- a/src/database/server/models/thread.ts +++ b/src/database/server/models/thread.ts @@ -4,7 +4,7 @@ import { and, desc } from 'drizzle-orm/expressions'; import { serverDB } from '@/database/server'; import { CreateThreadParams, ThreadStatus } from '@/types/topic'; -import { ThreadItem, threads } from '../schemas/lobechat'; +import { ThreadItem, threads } from '../../schemas'; const queryColumns = { createdAt: threads.createdAt, diff --git a/src/database/server/models/topic.ts b/src/database/server/models/topic.ts index 128bd2d801aa..0e09973d5727 100644 --- a/src/database/server/models/topic.ts +++ b/src/database/server/models/topic.ts @@ -3,8 +3,8 @@ import { and, desc, eq, exists, isNull, like, or } from 'drizzle-orm/expressions import { serverDB } from '@/database/server/core/db'; -import { NewMessage, TopicItem, messages, topics } from '../schemas/lobechat'; -import { idGenerator } from '../utils/idGenerator'; +import { NewMessage, TopicItem, messages, topics } from '../../schemas'; +import { idGenerator } from '@/database/utils/idGenerator'; export interface CreateTopicParams { favorite?: boolean; diff --git a/src/database/server/models/user.ts b/src/database/server/models/user.ts index 86008a8fc896..2fc92d1f1d2a 100644 --- a/src/database/server/models/user.ts +++ b/src/database/server/models/user.ts @@ -8,7 +8,7 @@ import { UserGuide, UserPreference } from '@/types/user'; import { UserKeyVaults, UserSettings } from '@/types/user/settings'; import { merge } from '@/utils/merge'; -import { NewUser, UserItem, userSettings, users } from '../schemas/lobechat'; +import { NewUser, UserItem, userSettings, users } from '../../schemas'; import { SessionModel } from './session'; export class UserNotFoundError extends TRPCError { diff --git a/src/database/server/utils/idGenerator.test.ts b/src/database/utils/idGenerator.test.ts similarity index 100% rename from src/database/server/utils/idGenerator.test.ts rename to src/database/utils/idGenerator.test.ts diff --git a/src/database/server/utils/idGenerator.ts b/src/database/utils/idGenerator.ts similarity index 100% rename from src/database/server/utils/idGenerator.ts rename to src/database/utils/idGenerator.ts diff --git a/src/libs/next-auth/adapter/index.ts b/src/libs/next-auth/adapter/index.ts index 129da498f185..5eeb5e4ab824 100644 --- a/src/libs/next-auth/adapter/index.ts +++ b/src/libs/next-auth/adapter/index.ts @@ -9,7 +9,7 @@ import type { NeonDatabase } from 'drizzle-orm/neon-serverless'; import { Adapter, AdapterAccount } from 'next-auth/adapters'; import { UserModel } from '@/database/server/models/user'; -import * as schema from '@/database/server/schemas/lobechat'; +import * as schema from '@/database/schemas'; import { merge } from '@/utils/merge'; import { diff --git a/src/libs/next-auth/adapter/utils.ts b/src/libs/next-auth/adapter/utils.ts index 936a8ddb079e..b28bfff27210 100644 --- a/src/libs/next-auth/adapter/utils.ts +++ b/src/libs/next-auth/adapter/utils.ts @@ -1,6 +1,6 @@ import { AdapterAuthenticator, AdapterUser } from 'next-auth/adapters'; -import { NewUser } from '@/database/server/schemas/lobechat'; +import { NewUser } from '@/database/schemas'; export const mapAdapterUserToLobeUser = (adapterUser: AdapterUser): NewUser => { const { id, email, name, image, emailVerified } = adapterUser; diff --git a/src/server/modules/ContentChunk/index.ts b/src/server/modules/ContentChunk/index.ts index e87a1f10351e..ce61616968cb 100644 --- a/src/server/modules/ContentChunk/index.ts +++ b/src/server/modules/ContentChunk/index.ts @@ -1,7 +1,7 @@ import { ChunkingLoader } from 'src/libs/langchain'; import { Strategy } from 'unstructured-client/sdk/models/shared'; -import { NewChunkItem, NewUnstructuredChunkItem } from '@/database/server/schemas/lobechat'; +import { NewChunkItem, NewUnstructuredChunkItem } from '@/database/schemas'; import { ChunkingStrategy, Unstructured } from '@/libs/unstructured'; export interface ChunkContentParams { diff --git a/src/server/routers/async/file.ts b/src/server/routers/async/file.ts index bce5cd784b75..c9071564245c 100644 --- a/src/server/routers/async/file.ts +++ b/src/server/routers/async/file.ts @@ -9,7 +9,7 @@ import { ASYNC_TASK_TIMEOUT, AsyncTaskModel } from '@/database/server/models/asy import { ChunkModel } from '@/database/server/models/chunk'; import { EmbeddingModel } from '@/database/server/models/embedding'; import { FileModel } from '@/database/server/models/file'; -import { NewChunkItem, NewEmbeddingsItem } from '@/database/server/schemas/lobechat'; +import { NewChunkItem, NewEmbeddingsItem } from '@/database/schemas'; import { ModelProvider } from '@/libs/agent-runtime'; import { asyncAuthedProcedure, asyncRouter as router } from '@/libs/trpc/async'; import { initAgentRuntimeWithUserPayload } from '@/server/modules/AgentRuntime'; diff --git a/src/server/routers/lambda/_template.ts b/src/server/routers/lambda/_template.ts index e7dace3277ec..10d5fae784dd 100644 --- a/src/server/routers/lambda/_template.ts +++ b/src/server/routers/lambda/_template.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { SessionGroupModel } from '@/database/server/models/sessionGroup'; -import { insertSessionGroupSchema } from '@/database/server/schemas/lobechat'; +import { insertSessionGroupSchema } from '@/database/schemas'; import { authedProcedure, router } from '@/libs/trpc'; import { SessionGroupItem } from '@/types/session'; diff --git a/src/server/routers/lambda/chunk.ts b/src/server/routers/lambda/chunk.ts index aa8947e1e0da..d9818febe52b 100644 --- a/src/server/routers/lambda/chunk.ts +++ b/src/server/routers/lambda/chunk.ts @@ -8,7 +8,7 @@ import { ChunkModel } from '@/database/server/models/chunk'; import { EmbeddingModel } from '@/database/server/models/embedding'; import { FileModel } from '@/database/server/models/file'; import { MessageModel } from '@/database/server/models/message'; -import { knowledgeBaseFiles } from '@/database/server/schemas/lobechat'; +import { knowledgeBaseFiles } from '@/database/schemas'; import { ModelProvider } from '@/libs/agent-runtime'; import { authedProcedure, router } from '@/libs/trpc'; import { keyVaults } from '@/libs/trpc/middleware/keyVaults'; diff --git a/src/server/routers/lambda/knowledgeBase.ts b/src/server/routers/lambda/knowledgeBase.ts index 140eb7c1f00d..9ccfc01ebfd2 100644 --- a/src/server/routers/lambda/knowledgeBase.ts +++ b/src/server/routers/lambda/knowledgeBase.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { KnowledgeBaseModel } from '@/database/server/models/knowledgeBase'; -import { insertKnowledgeBasesSchema } from '@/database/server/schemas/lobechat'; +import { insertKnowledgeBasesSchema } from '@/database/schemas'; import { authedProcedure, router } from '@/libs/trpc'; import { KnowledgeBaseItem } from '@/types/knowledgeBase'; diff --git a/src/server/routers/lambda/message.ts b/src/server/routers/lambda/message.ts index ffcb9390ca60..fb95768d3035 100644 --- a/src/server/routers/lambda/message.ts +++ b/src/server/routers/lambda/message.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { MessageModel } from '@/database/server/models/message'; -import { updateMessagePluginSchema } from '@/database/server/schemas/lobechat'; +import { updateMessagePluginSchema } from '@/database/schemas'; import { authedProcedure, publicProcedure, router } from '@/libs/trpc'; import { ChatMessage } from '@/types/message'; import { BatchTaskResult } from '@/types/service'; diff --git a/src/server/routers/lambda/session.ts b/src/server/routers/lambda/session.ts index a2099efba215..af98cd197b53 100644 --- a/src/server/routers/lambda/session.ts +++ b/src/server/routers/lambda/session.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { SessionModel } from '@/database/server/models/session'; import { SessionGroupModel } from '@/database/server/models/sessionGroup'; -import { insertAgentSchema, insertSessionSchema } from '@/database/server/schemas/lobechat'; +import { insertAgentSchema, insertSessionSchema } from '@/database/schemas'; import { authedProcedure, publicProcedure, router } from '@/libs/trpc'; import { AgentChatConfigSchema } from '@/types/agent'; import { LobeMetaDataSchema } from '@/types/meta'; diff --git a/src/server/routers/lambda/sessionGroup.ts b/src/server/routers/lambda/sessionGroup.ts index e7dace3277ec..10d5fae784dd 100644 --- a/src/server/routers/lambda/sessionGroup.ts +++ b/src/server/routers/lambda/sessionGroup.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { SessionGroupModel } from '@/database/server/models/sessionGroup'; -import { insertSessionGroupSchema } from '@/database/server/schemas/lobechat'; +import { insertSessionGroupSchema } from '@/database/schemas'; import { authedProcedure, router } from '@/libs/trpc'; import { SessionGroupItem } from '@/types/session'; diff --git a/src/server/routers/lambda/thread.ts b/src/server/routers/lambda/thread.ts index 91a8f71ca0f9..32e5a5452fec 100644 --- a/src/server/routers/lambda/thread.ts +++ b/src/server/routers/lambda/thread.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { MessageModel } from '@/database/server/models/message'; import { ThreadModel } from '@/database/server/models/thread'; -import { insertThreadSchema } from '@/database/server/schemas/lobechat'; +import { insertThreadSchema } from '@/database/schemas'; import { authedProcedure, router } from '@/libs/trpc'; import { ThreadItem, createThreadSchema } from '@/types/topic/thread'; diff --git a/src/server/services/dataImporter/__tests__/index.test.ts b/src/server/services/dataImporter/__tests__/index.test.ts index 989402c57670..11835d6b712b 100644 --- a/src/server/services/dataImporter/__tests__/index.test.ts +++ b/src/server/services/dataImporter/__tests__/index.test.ts @@ -11,7 +11,7 @@ import { sessions, topics, users, -} from '@/database/server/schemas/lobechat'; +} from '@/database/schemas'; import { CURRENT_CONFIG_VERSION } from '@/migrations'; import { ImportResult } from '@/services/config'; import { ImporterEntryData } from '@/types/importer'; diff --git a/src/server/services/dataImporter/index.ts b/src/server/services/dataImporter/index.ts index e89f8a3b0745..cb7a5aab1c08 100644 --- a/src/server/services/dataImporter/index.ts +++ b/src/server/services/dataImporter/index.ts @@ -11,7 +11,7 @@ import { sessionGroups, sessions, topics, -} from '@/database/server/schemas/lobechat'; +} from '@/database/schemas'; import { ImportResult } from '@/services/config'; import { ImporterEntryData } from '@/types/importer'; diff --git a/src/server/services/nextAuthUser/index.ts b/src/server/services/nextAuthUser/index.ts index ac17b0de0a46..e832a6d04aa1 100644 --- a/src/server/services/nextAuthUser/index.ts +++ b/src/server/services/nextAuthUser/index.ts @@ -2,7 +2,7 @@ import { NextResponse } from 'next/server'; import { serverDB } from '@/database/server'; import { UserModel } from '@/database/server/models/user'; -import { UserItem } from '@/database/server/schemas/lobechat'; +import { UserItem } from '@/database/schemas'; import { pino } from '@/libs/logger'; import { LobeNextAuthDbAdapter } from '@/libs/next-auth/adapter';