forked from qthibeault/fly-south
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
78 lines (71 loc) · 2.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const create = require('./lib/create');
const migrate = require('./lib/migrate');
const remove = require('./lib/remove');
const show = require('./lib/show');
const list = require('./lib/list');
function createMigration (name) {
return create(name)
.then(() => {
console.log(`Created migration configuration ${name} successfully`);
process.exit(0);
})
.catch(function(err) {
console.error(`Could not create migration configuration ${name}`);
console.error(err);
process.exit(-1);
});
}
function runMigration (name) {
return migrate(name)
.then(() => {
console.log(`Migration ${name} successfully started`);
process.exit(0);
})
.catch(function(err) {
console.error(`Could not start migration ${name}`);
console.error(err);
process.exit(-1);
});
}
function listMigrations () {
return list()
.then(function () {
process.exit(0);
})
.catch(function (err) {
console.error(`Could not list migration configurations`);
console.error(err);
process.exit(-1);
});
}
function removeMigration (name) {
return remove(name)
.then(function () {
console.log(`Successfully removed migration configuration ${name}`);
process.exit(0);
})
.catch(function (err) {
console.error(`Could not remove migration configuration ${name}`);
console.error(err);
process.exit(-1);
})
}
function showMigration (name) {
return show(name)
.then(function () {
process.exit(0);
})
.catch(function (err) {
console.error(`Could not retrieve migration configuration ${name}`);
console.error(err);
process.exit(-1);
});
}
module.exports = {
createMigration,
runMigration,
listMigrations,
removeMigration,
showMigration
};