-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrizzle.config.ts
More file actions
39 lines (33 loc) · 1005 Bytes
/
drizzle.config.ts
File metadata and controls
39 lines (33 loc) · 1005 Bytes
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
import 'dotenv/config'
import { defineConfig } from 'drizzle-kit'
const dbDriver = process.env.TASKIQ_ADMIN_DB_DRIVER
if (!dbDriver) {
throw new Error('Environment variable TASKIQ_ADMIN_DB_DRIVER is required')
}
if (dbDriver !== 'sqlite' && dbDriver !== 'postgres') {
throw new Error(
'Environment variable TASKIQ_ADMIN_DB_DRIVER must be "sqlite" or "postgres"'
)
}
const dbUrl =
dbDriver === 'sqlite'
? process.env.TASKIQ_ADMIN_DB_FILE_PATH
: process.env.TASKIQ_ADMIN_DB_URL
if (!dbUrl) {
throw new Error(
dbDriver === 'sqlite'
? 'Environment variable TASKIQ_ADMIN_DB_FILE_PATH is required for sqlite driver'
: 'Environment variable TASKIQ_ADMIN_DB_URL is required for postgres driver'
)
}
export default defineConfig({
out: './drizzle',
schema:
dbDriver === 'sqlite'
? './shared/db/schema.sqlite.ts'
: './shared/db/schema.postgres.ts',
dialect: dbDriver === 'sqlite' ? 'sqlite' : 'postgresql',
dbCredentials: {
url: dbUrl
}
})