-
Notifications
You must be signed in to change notification settings - Fork 0
/
knexfile.ts
49 lines (43 loc) · 1.09 KB
/
knexfile.ts
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
45
46
47
48
49
import * as dotenv from 'dotenv';
import type { Knex } from "knex";
import { knexSnakeCaseMappers } from 'objection';
dotenv.config(); // Load environment variables from .env file
const config: Knex.Config = {
client: "postgresql",
connection: {
database: process.env.POSTGRES_DB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
host: process.env.POSTGRES_HOST,
port: Number(process.env.POSTGRES_PORT)
},
migrations: {
directory: 'database/migrations',
tableName: 'knex_migrations',
stub: 'database/migration.stub'
},
seeds: {
directory: 'database/seeds',
stub: 'database/seed.stub',
timestampFilenamePrefix: true
},
...knexSnakeCaseMappers()
}
const connectionPool = {
pool: {
min: Number(process.env.MIN_CONNECTION_POSTGRES) || 2 ,
max: Number(process.env.MAX_CONNECTION_POSTGRES) || 10
}
}
const envConfig: { [key: string]: Knex.Config } = {
development: config,
staging: {
...config,
...connectionPool,
},
production: {
...config,
...connectionPool,
},
};
module.exports = envConfig;