Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ use knex-migrator #57

Merged
merged 4 commits into from Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/commands/start.js
Expand Up @@ -45,6 +45,30 @@ module.exports = BaseCommand.extend({
// TODO: rethink this
return this.runCommand('config', 'paths.contentPath', path.join(process.cwd(), 'content'), {environment: environment})
.then(function () {
var KnexMigrator = require('knex-migrator'),
knexMigrator;
/**
* If we require any JS file from Ghost source code (for example the config), then it's always env-less!
*
* 1. Ghost-CLI requires knex-migrator
* 2. knex-migrator loads the .knex-migrator config file from the current Ghost version
* 3. this is env-less
*
* Alternative solution is: passing the env into knex-migrator, but that feels not right?
* @TODO: rethink
*/
process.env.NODE_ENV = environment;

// @TODO: where to get this path from?
knexMigrator = new KnexMigrator({
knexMigratorFilePath: process.cwd() + '/current'
});

return knexMigrator.isDatabaseOK()
.catch(function () {
return knexMigrator.init();
});
}).then(function () {
return self.ui.run(
Promise.resolve(pm.start(process.cwd(), environment)),
'Starting Ghost instance'
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -47,6 +47,7 @@
"inquirer": "1.2.2",
"lodash": "4.16.4",
"log-symbols": "1.0.2",
"knex-migrator": "0.0.6",
"npm": "2.15.11",
"semver": "5.3.0",
"symlink-or-copy": "1.1.6",
Expand Down