Skip to content

Commit

Permalink
✨ use knex-migrator
Browse files Browse the repository at this point in the history
- check database health before starting Ghost
- run knex-migrator init if database was never initialised
  • Loading branch information
kirrg001 committed Oct 13, 2016
1 parent d01852e commit e1b8f5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/commands/start.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var KnexMigrator = require('knex-migrator');
var BaseCommand = require('./base');

module.exports = BaseCommand.extend({
Expand Down Expand Up @@ -28,7 +29,7 @@ module.exports = BaseCommand.extend({
Promise = require('bluebird'),
path = require('path'),
self = this,
environment, config, pm, cliConfig;
environment, config, pm, cliConfig, knexMigrator;

options = options || {};
environment = (options.production || !options.development) ? 'production' : 'development';
Expand All @@ -44,6 +45,13 @@ module.exports = BaseCommand.extend({

// TODO: rethink this
return this.runCommand('config', 'paths.contentPath', path.join(process.cwd(), 'content'), {environment: environment})
.then(function () {
knexMigrator = new KnexMigrator();
return knexMigrator.isDatabaseOK()
.catch(function () {
return knexMigrator.init();
});
})
.then(function () {
return self.ui.run(
Promise.resolve(pm.start(process.cwd(), environment)),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"inquirer": "1.2.2",
"lodash": "4.16.4",
"log-symbols": "1.0.2",
"knex-migrator": "https://github.com/TryGhost/knex-migrator/tarball/master",
"npm": "2.15.11",
"semver": "5.3.0",
"symlink-or-copy": "1.1.6",
Expand Down

0 comments on commit e1b8f5d

Please sign in to comment.