forked from SmartDropLabs/smartdrop-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknexfile.js
More file actions
49 lines (41 loc) · 1.19 KB
/
Copy pathknexfile.js
File metadata and controls
49 lines (41 loc) · 1.19 KB
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
'use strict';
/**
* Knex configuration (issue #252).
*
* Migration files already existed under src/db/migrations, but there was no
* knexfile and knex was not a dependency, so nothing could actually run
* them. This wires them up and points knex at the same DATABASE_URL the
* rest of the service uses.
*
* `migrations.tableName` is left at knex's default (`knex_migrations`);
* the dedicated status tracking the issue asks for lives in a separate
* table written by src/db/migrationSafety.js, so knex's own bookkeeping
* stays untouched and recoverable.
*/
require('dotenv').config();
const path = require('path');
const migrations = {
directory: path.join(__dirname, 'src', 'db', 'migrations'),
extension: 'js',
};
function connectionFor(fallback) {
return process.env.DATABASE_URL || fallback;
}
module.exports = {
development: {
client: 'pg',
connection: connectionFor('postgres://localhost/smartdrop'),
migrations,
},
test: {
client: 'pg',
connection: connectionFor('postgres://localhost/smartdrop_test'),
migrations,
},
production: {
client: 'pg',
connection: connectionFor(undefined),
pool: { min: 2, max: 10 },
migrations,
},
};