-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.js
executable file
·36 lines (32 loc) · 1.03 KB
/
index.js
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
#!/usr/bin/env node
var DbDiff = exports.DbDiff = require('./dbdiff')
exports.describeDatabase = require('./dialects').describeDatabase
if (module.id === require.main.id) {
var yargs = require('yargs')
var argv = yargs
.usage('Usage: $0 conn_string1 conn_string2')
.example('$0 postgres://user:pass@host[:port]/dbname1 postgres://user:pass@host[:port]/dbname2',
'compares the scheme of two databases and prints the SQL commands to modify the first one in order to match the second one')
.demand(2)
.wrap(yargs.terminalWidth())
.help('h')
.alias('h', 'help')
.option('level', {
alias: 'l',
describe: 'chooses the safety of the sql',
choices: ['safe', 'warn', 'drop']
})
.argv
var conn1 = argv._[0]
var conn2 = argv._[1]
var dbdiff = new DbDiff()
dbdiff.compare(conn1, conn2)
.then(() => {
console.log(dbdiff.commands(argv.level))
process.exit(0)
})
.catch((err) => {
console.error(err.stack)
process.exit(1)
})
}