Files
lobehub/drizzle.config.ts
Arvin Xu 4743bfd3e5 ♻️ refactor: refactor server db schema for better code organize (#3410)
* refactor schema

* fix lint

* fix

* update drizzle-kit

* clean code
2024-08-06 13:10:40 +08:00

30 lines
749 B
TypeScript

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',
strict: true,
} satisfies Config;