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

Analyse and create a "dry run" command in the if feasible #45

Open
marquesVF opened this issue May 27, 2021 · 3 comments
Open

Analyse and create a "dry run" command in the if feasible #45

marquesVF opened this issue May 27, 2021 · 3 comments
Labels
feature A feature is desirable

Comments

@marquesVF
Copy link
Member

marquesVF commented May 27, 2021

It’s desired to be able to validate a migration plan before we actually execute it. With that we could:

Make sure that the migration will do what is expected.

@marquesVF marquesVF added the feature A feature is desirable label May 27, 2021
@code-shambles
Copy link
Member

I have an idea/question:
Would it be possible to freeze a current state of content? When doing a dry-run, the result may be okay. But in the meantime, until the real migration is triggered, a change could happen (i. e. by another dev) and the result would be different from what the dry-run had promised. Just thinking... 😉

@n4bb12
Copy link
Contributor

n4bb12 commented Jun 2, 2021

Usually, changes outside a migration are expected. Not just developers who might be working on a separate migration in parallel, but also content managers continuously working on the main branch. You don't want some of that content to do a time leap because someone ran a migration with dry run.

@pmbanugo
Copy link
Contributor

I checked to see if there's a way to implement this but the contentful-migrations doesn't expose many internal functions that we could probably re-use to implement something like this. There's an open issue from 4 years ago asking for a similar thing. I think we could implement this if some functions used internally are also exposed by the library. From what I checked, only the runMigrations function is exposed as a public API.

For code context, here’s the part of the file that renders the description of changes to the content model: https://github.com/contentful/contentful-migration/blob/a90a8329af0c87a046feae07d78ced1835e69eb0/src/bin/cli.ts#L141

And this is used when the --yes flag is applied: https://github.com/contentful/contentful-migration/blob/a90a8329af0c87a046feae07d78ced1835e69eb0/src/bin/cli.ts#L197 . It would either run the migrations without a prompt if true, or prompt the user if they want the migration to be applied.

If we decide to fork and extend the library or send a PR, we could add another dry-run option and used that to render a description of the planned migration.

@marquesVF marquesVF self-assigned this Dec 30, 2021
@marquesVF marquesVF removed their assignment Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature is desirable
Projects
None yet
Development

No branches or pull requests

4 participants