forked from YannickRe/Ghost-Azure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
25 lines (23 loc) · 706 Bytes
/
db.js
File metadata and controls
25 lines (23 loc) · 706 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
var KnexMigrator = require('knex-migrator');
var knexMigrator = new KnexMigrator({
knexMigratorFilePath: __dirname
});
// check your database health
knexMigrator.isDatabaseOK()
.then(function () {
console.log("database is ok");
process.exit(0);
})
.catch(function (err) {
console.log("db error: " + err.code);
if (err.code === 'DB_NOT_INITIALISED') {
knexMigrator.init().then(function () {
process.exit(0);
});
}
if (err.code === 'DB_NEEDS_MIGRATION') {
knexMigrator.migrate().then(function () {
process.exit(0);
});
}
});