Skip to main content

Automated Migrations

Contentful migrations are tied into the GitLab CI pipeline and models should not be created or edit from the GUI. A project will contain a number of migration files that will all be run when a new environment is created so do not delete or alter any old ones.

A migration from the CI file will be created with the name of the branch it has been pushed against.


Important

Do not use / in your branch names. Using this in conjunction with Contentful API call incorrect URLs. For example, instead of feature/new-feature use feature-new-feature.


When adding or updating a content model the proposed workflow should be:

  1. Create a MR with a new migration file starting with an incremental number. Make sure the content model contains all attributes and fields now as any populated content later on will be deleted. Environments that are found to have the same name are re-written instead of duplicated.
  2. Push to git origin and create a new MR. This will trigger the migration scripts and build a new environment in Contentful.
  3. Update your .env. in the relevant places with the Contentful environment name (name of your branch).
  4. Start UI development
  5. Push work to git remote
  6. MR is approved and ready for merging with a rebase from master.
  7. MR is merged into master. Migration script runs and updates Contentful alias to point master to latest feature environment.