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

Added confirmation/support for automatically rolling back to previous version #773

Merged
merged 3 commits into from
Aug 8, 2018

Conversation

vikaspotluri123
Copy link
Member

@vikaspotluri123 vikaspotluri123 commented Aug 2, 2018

refs #759

The wording won't work because I want to rebase on #772 and #771 before finalizing how the function will work

rollbackFromFail(error, argv) {
const previousVersion = this.system.getInstance().cliConfig.get('previous-version');
this.ui.error(error);
const question = argv.version === '2.0.0' ?

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

}

return this.run({
rollback: true

This comment was marked as abuse.

This comment was marked as abuse.

@@ -179,6 +181,25 @@ class UpdateCommand extends Command {
});
}

rollbackFromFail(error, argv) {
const previousVersion = this.system.getInstance().cliConfig.get('previous-version');
this.ui.error(error);

This comment was marked as abuse.

This comment was marked as abuse.

@kirrg001 kirrg001 changed the title feat(update): add support for automatically rolling back failed updates [WIP] feat(update): add support for automatically rolling back failed updates Aug 3, 2018
@vikaspotluri123
Copy link
Member Author

@kirrg001 updated the error message, still not sure how we should handle the error

@kirrg001
Copy link
Contributor

kirrg001 commented Aug 6, 2018

@vikaspotluri123 I'll take a look at this PR tomorrow :) Will also look at the error handling.

@vikaspotluri123 vikaspotluri123 force-pushed the ghost2/rollback-on-fail branch 2 times, most recently from 35465d9 to 71d49f6 Compare August 7, 2018 03:15
@vikaspotluri123
Copy link
Member Author

Tests have been added!

@coveralls
Copy link

coveralls commented Aug 7, 2018

Coverage Status

Coverage increased (+0.001%) to 99.831% when pulling a4b68ca on vikaspotluri123:ghost2/rollback-on-fail into 2f3de69 on TryGhost:1.9.

@kirrg001
Copy link
Contributor

kirrg001 commented Aug 7, 2018

I have to test two cases:

A: You want to migrate and an error occurs during the migration.
B: You have successfully migrated, but want to rollback.

@kirrg001
Copy link
Contributor

kirrg001 commented Aug 7, 2018

@vikaspotluri123 I'll take a look at this PR tomorrow :) Will also look at the error handling.

Tomorrow! 👻

const question = `Unable to upgrade Ghost from v${oldVer} to v${newVer}. Would you like to revert back to v${oldVer}?`;
const promise = force ? Promise.resolve(true) : this.ui.confirm(question, true);

this.ui.error(error);

This comment was marked as abuse.

rollbackFromFail(error, newVer, force = false) {
const oldVer = this.system.getInstance().cliConfig.get('previous-version');
const question = `Unable to upgrade Ghost from v${oldVer} to v${newVer}. Would you like to revert back to v${oldVer}?`;
const promise = force ? Promise.resolve(true) : this.ui.confirm(question, true);

This comment was marked as abuse.

@@ -114,7 +114,9 @@ class UpdateCommand extends Command {
return;
}

return this.ui.listr(tasks, context);
return this.ui.listr(tasks, context).catch(error =>
this.rollbackFromFail(error, context.version, argv['auto-rollback'])

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

return Promise.resolve();
}

return this.run({

This comment was marked as abuse.

This comment was marked as abuse.

@@ -195,6 +197,24 @@ class UpdateCommand extends Command {
});
}

rollbackFromFail(error, newVer, force = false) {

This comment was marked as abuse.

This comment was marked as abuse.

@@ -114,7 +114,9 @@ class UpdateCommand extends Command {
return;
}

return this.ui.listr(tasks, context);

This comment was marked as abuse.

This comment was marked as abuse.

@kirrg001
Copy link
Contributor

kirrg001 commented Aug 8, 2018

I'll push changes in a bit.

@kirrg001 kirrg001 changed the title [WIP] feat(update): add support for automatically rolling back failed updates [WIP] Added support for automatically rolling back failed updates Aug 8, 2018
vikaspotluri123 and others added 3 commits August 8, 2018 12:51
refs TryGhost#759

- ask user if we wants to bring back previous version if
  - GhostError was thrown (migration failed)
  - if the user has not executed `ghost update --rollback`
- show error to user so he knows why the update failed
refs TryGhost#759

- return a proper GhostError when migration fails
- detect if knex-migrator can't find versions to rollback (resolve in this case)
@kirrg001 kirrg001 changed the title [WIP] Added support for automatically rolling back failed updates Added support for automatically rolling back failed updates Aug 8, 2018
@kirrg001
Copy link
Contributor

kirrg001 commented Aug 8, 2018

I am doing a final test, then i'll merge this into 1.9.

@kirrg001 kirrg001 changed the title Added support for automatically rolling back failed updates Added confirmation/support for automatically rolling back to previous version Aug 8, 2018
@kirrg001 kirrg001 merged commit 464d13a into TryGhost:1.9 Aug 8, 2018
@vikaspotluri123 vikaspotluri123 deleted the ghost2/rollback-on-fail branch August 16, 2018 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants