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

Terminate with an error when a migration is aborted #858

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rouanw
Copy link
Contributor

@rouanw rouanw commented Aug 27, 2021

Summary

Description

This Pull Request changes the behaviour when you select N (No) when the script prompts you whether you want to apply a migration.

Previous behaviour:

  • Log warning
  • Exit with 0 exit code

New behaviour:

  • Log warning
  • Exit with a non-zero exit code / throw error, depending on how terminate has been configured.

I'll leave it to your discretion, but this is likely a breaking change and would require releasing a new major semver version.

Motivation and Context

I'm plugging contentful-migration into our CLI-based migration tooling (using umzug), so it's nice if aborting the migration prevents subsequent commands from running. The current behaviour is particularly problematic when using an external migration tool, because it will interpret the run as a success and will therefore consider the migration as applied, even though it hasn't been.

A workaround would be to force the script not to prompt, using the yes option. I quite like the nice feedback the contentful-migration library gives you before applying a change, though, so it would be a shame to lose that. (Especially when testing migrations locally against a test environment.)

Screenshots:

Before:

131104157-4554efea-0fb0-4536-b77e-d861ebe51d4a

After:

131104809-2769fffb-79a8-4184-acbd-9ca1dbb21ba3

@rouanw
Copy link
Contributor Author

rouanw commented Sep 9, 2021

@marcolink @TimBeyer what do you think of this change?

@draconteus
Copy link

Is there any suggestion here? It would be great to handle migration abort somehow. With throwing an error or just resolving a simple { aborted: true } response.

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.

2 participants