mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
✨ feat: support server db mode with Postgres / Drizzle ORM / tRPC (#2556)
This commit is contained in:
29
drizzle.config.ts
Normal file
29
drizzle.config.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import type { Config } from 'drizzle-kit';
|
||||
|
||||
// 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();
|
||||
|
||||
let connectionString = process.env.DATABASE_URL;
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
console.log('current ENV:', process.env.NODE_ENV);
|
||||
connectionString = process.env.DATABASE_TEST_URL;
|
||||
}
|
||||
|
||||
if (!connectionString)
|
||||
throw new Error('`DATABASE_URL` or `DATABASE_TEST_URL` not found in environment');
|
||||
|
||||
export default {
|
||||
dbCredentials: {
|
||||
url: connectionString,
|
||||
},
|
||||
dialect: 'postgresql',
|
||||
out: './src/database/server/migrations',
|
||||
|
||||
schema: './src/database/server/schemas/lobechat.ts',
|
||||
strict: true,
|
||||
} satisfies Config;
|
||||
Reference in New Issue
Block a user