Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Migration scripts run order independent of content type #215

Open
gigaSproule opened this issue Jul 26, 2021 · 2 comments
Open

Migration scripts run order independent of content type #215

gigaSproule opened this issue Jul 26, 2021 · 2 comments

Comments

@gigaSproule
Copy link

Expected Behavior

Run all scripts in date order, regardless of content type.

Actual Behavior

Scripts run in order of content type alphabetical, then by date, causing the migration to fail.

Possible Solution

Instead of going through each folder one by one, get all files under the matching directories and run in order by date.

Steps to Reproduce

  1. Create content model A
  2. Create content model B
  3. Create first file under content model A create some fields
  4. Create first file under content model B create some fields
  5. Create second file under content model B to create a new field and populate it with data from a field in A in a field in B
  6. Create second file under content model A delete field that is now in content model B

Context

We have some spaces that are far behind (or newly created), so need to run through our migration scripts. We have 1 that relies on some field being present in another content type, but another script that deletes that field.

Environment

  • Node Version: 14.17.3
  • Package Manager Version: yarn 1.18.0
  • Operating System: Mac OSX 11.4
  • Package Version: v4.0.10
@deluan
Copy link
Owner

deluan commented Sep 8, 2021

Sorry for the long delay in replying to this. This folder per content-model structure is a legacy for the original use-case of this tool. There was even work to try to implement a way for it to handle single-folder migrations in the branch https://github.com/deluan/contentful-migrate/tree/single-folder, but this still incomplete.

You don't need to create one folder per content-model. In fact the content-models are not tied to any folder. You can simply have all migrations in one folder by using -t single if you want. This would create a "content-model" folder named single and all your migrations would be in the same folder, independent of what content model they change. This would allow you to run migrations always in sequence, the same behaviour as we have with traditional DB schema migration tools.

Let me know if this solves the issue for you

@gigaSproule
Copy link
Author

That's the sort of approach that I have started to migrate to. It would be nice to still have the separate folder structure, so it's easier to go through previous scripts, but at least this works.

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

No branches or pull requests

2 participants