This is a tiny step-by-step helper to manage Contentful Migration Scripts using Contentful CLI and Bash scripts.
- No installation, just copy and paste.
- Tracks which migrations ran without any new Content Model (using a good and old text file!)
- Need to make changes? Just write them! It's easy 🎉
contentful-clicontentful-migrations- A Contentful account
- A Node.js Typescript project
- Copy the
migrationsfolder to your project's root. - Allow the scripts to run by running
chmod 777 ./migrations/generate-migration.sh ./migrations/migrate.sh. - Add your
CONTENTFUL_SPACE_IDto your.env.localfile- If you are using a different named
.envfile, you'll need to edit the.shfiles
- If you are using a different named
- For extra pizzaz, add to your
package.jsonscripts:
"cf:new": "./migrations/scripts/generate-migration.sh",
"cf:migrate": "./migrations/scripts/migrate.sh"(change pnpm to yarn or npm or whatever)
- Run
pnpm cf:new <filename>to generate an empty migration file. - Edit your migration file
- run
pnpm cf:migrateto run the migration and log it in your registry.
- This is setup to work with Typescript. Javascript has an easier setup but I already did the heavy lifting for you.
- This is a very personal way of dealing with this "migration registry" issue and I'd love to get suggestions.