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-cli
contentful-migrations
- A Contentful account
- A Node.js Typescript project
- Copy the
migrations
folder 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_ID
to your.env.local
file- If you are using a different named
.env
file, you'll need to edit the.sh
files
- If you are using a different named
- For extra pizzaz, add to your
package.json
scripts
:
"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:migrate
to 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.