forked from helium/network-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknexfile.ts
43 lines (37 loc) · 848 Bytes
/
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
import type { Knex } from "knex"
require("dotenv").config()
// used for preview / if DATABASE_URL not set
const SQLITE_CONFIG: Knex.Config = {
client: "better-sqlite3",
connection: {
filename: "./db.sqlite3",
},
}
const PG_CONFIG_PROD: Knex.Config = {
client: "postgresql",
connection: {
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false,
},
},
migrations: {
extension: "ts",
},
}
const PG_CONFIG_LOCAL: Knex.Config = {
client: "postgresql",
connection: {
connectionString: process.env.DATABASE_URL,
},
migrations: {
extension: "ts",
},
}
const getConfig = () => {
if (!process.env.DATABASE_URL) return SQLITE_CONFIG
if (process.env.LOCAL) return PG_CONFIG_LOCAL
return PG_CONFIG_PROD
}
const config: Knex.Config = getConfig()
export default config