mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
* ✨ feat: add files and knowledge base Update edge.ts Update test.yml 🎨 chore: fix locale Update index.tsx 测试 pgvector workflow * 💄 style: improve upload detail * ✨ feat: support delete s3 file when delete files * 💄 style: improve chunks in message * ♻️ refactor: refactor the auth method * ✨ feat: support use user client api key * 💄 style: fix image list in mobile * ✨ feat: support file upload on mobile * ✅ test: fix test * fix vercel build * docs: update docs * 👷 build: improve docker * update i18n
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import * as dotenv from 'dotenv';
|
|
import * as migrator from 'drizzle-orm/neon-serverless/migrator';
|
|
import { join } from 'node:path';
|
|
|
|
import { serverDB } from '../../src/database/server/core/db';
|
|
import { PGVECTOR_HINT } from './errorHint';
|
|
|
|
// Read the `.env` file if it exists, or a file specified by the
|
|
// dotenv_config_path parameter that's passed to Node.js
|
|
dotenv.config();
|
|
|
|
const runMigrations = async () => {
|
|
await migrator.migrate(serverDB, {
|
|
migrationsFolder: join(__dirname, '../../src/database/server/migrations'),
|
|
});
|
|
console.log('✅ database migration pass.');
|
|
// eslint-disable-next-line unicorn/no-process-exit
|
|
process.exit(0);
|
|
};
|
|
|
|
let connectionString = process.env.DATABASE_URL;
|
|
|
|
// only migrate database if the connection string is available
|
|
if (connectionString) {
|
|
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
runMigrations().catch((err) => {
|
|
console.error('❌ Database migrate failed:', err);
|
|
|
|
if ((err.message as string).includes('extension "vector" is not available')) {
|
|
console.info(PGVECTOR_HINT);
|
|
}
|
|
|
|
// eslint-disable-next-line unicorn/no-process-exit
|
|
process.exit(1);
|
|
});
|
|
} else {
|
|
console.log('🟢 not find database env, migration skipped');
|
|
}
|