-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrizzle.config.js
44 lines (41 loc) · 1 KB
/
drizzle.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { defineConfig } from 'drizzle-kit';
import nuxtConfig from './nuxt.config.js';
const dialect = 'postgresql';
const schema = './server/db/schema';
const out = './server/db/migrations';
/** @type {import('drizzle-kit').Config} */
let config;
if (process.env.DATABASE_URL) {
const postgresUrl = new URL(process.env.DATABASE_URL);
config = {
dialect,
schema,
out,
dbCredentials: {
host: postgresUrl.hostname,
port: parseInt(postgresUrl.port),
user: postgresUrl.username,
password: postgresUrl.password,
database: postgresUrl.pathname.slice(1),
ssl: {
rejectUnauthorized: false,
ca: process.env.DATABASE_CA_CERT,
},
},
};
} else {
const url = nuxtConfig?.runtimeConfig?.pgliteDataDir;
if (!url) {
throw new Error('Missing runtimeConfig.pgliteDataDir in nuxt.config.js');
}
config = {
dialect,
schema,
out,
driver: 'pglite',
dbCredentials: {
url,
},
};
}
export default defineConfig(config);