-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·30 lines (24 loc) · 731 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·30 lines (24 loc) · 731 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
#!/usr/bin/env node
const pg = require('pg');
const pgConnectionString = require('pg-connection-string');
const migrate = require('./migrate');
const databaseUrl = process.env.DATABASE_URL;
const isSync = process.argv[2] === '--sync';
if (!databaseUrl) {
// eslint-disable-next-line no-console
console.log('No DATABASE_URL found in environment.');
process.exit(1);
}
const config = pgConnectionString.parse(databaseUrl);
const pool = new pg.Pool(config);
migrate('schema', pool, isSync)
.then((result) => {
// eslint-disable-next-line no-console
console.log(result);
return pool.end();
})
.catch((err) => {
// eslint-disable-next-line no-console
console.error(err);
process.exit(1);
});