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

Expects a migration to only be able to run once #1068

Open
henninghall opened this issue Apr 27, 2022 · 5 comments
Open

Expects a migration to only be able to run once #1068

henninghall opened this issue Apr 27, 2022 · 5 comments

Comments

@henninghall
Copy link

Expected Behavior

When I run the same migration multiple times I expect it to throw an error saying that this migration has already been run.

Actual Behavior

It does try to run the migration multiple times. It usually doesn't succeed but because of other reasons, for instance that the field already exists.

Possible Solution

This other less popular library contentful-migrate is handling this, I think by creating a migration entry in contentful itself for each migration that has been run.

Does a solution already exist for this?

Steps to Reproduce

  1. Run any migration
  2. Run the same migration again

Environment

  • Package Version: 4.8.1
@torressam333
Copy link

I agree with this @henninghall , there should also be a way to rollback the migration to undo the changes that just took place.

@MosesG10
Copy link

MosesG10 commented Jul 5, 2022

This a problem for me as well. Not having this functionality does not give me confidence in being able to rollback effectively

@nteague22
Copy link

I put in place a manual setup for this, added a fingerprint function that I run on each migration, made a single content-type with one entry (but could be diff for diff usage) called migration-tracking, then have every migration .js file do a migration.transformEntriesForLocale that adds the name of the migration to the list on the entry. But it throws an error if the name is in the list, so by throwing within a sync call -- it will auto hook into the migrations cli dry-run verification

@nteague22
Copy link

so the entity is just a symbol list and a name, I did make from the mgmt api, so I could make the tracker name able to be an easy lookup -- but I was modelling it after the efcore migrations Microsoft does, would be nice to spawn an up/down system though -- to allow for rolling them back

@sbonami
Copy link

sbonami commented Nov 9, 2023

🧟

I've had success in other projects using https://github.com/sequelize/umzug, which provides a generic, agnostic framework for running migrations. I can't imagine it would be too much work to build a Contentful-specific store or for users to BYOD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants