-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknexfile.ts
More file actions
32 lines (29 loc) · 841 Bytes
/
knexfile.ts
File metadata and controls
32 lines (29 loc) · 841 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
import dotenv from 'dotenv'
import fs from 'node:fs'
if (fs.existsSync('.env.local')) {
dotenv.config({ path: '.env.local' })
} else {
dotenv.config({ path: '.env' })
}
const client = process.env.DB_CLIENT
const knexConfig = {
client,
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 3305,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
ssl: process.env.DB_SSL ? { rejectUnauthorized: false } : false,
},
pool: { min: 0, max: process.env.DB_POOL ? parseInt(process.env.DB_POOL) : 2 },
migrations: {
directory:
client === 'pg'
? './migrations/knex/postgres'
: client === 'mysql'
? './migrations/knex/mysql'
: './migrations',
},
}
export default knexConfig