Skip to content

migrate

Terminal window
ctkit migrate

Runs every migration that hasn’t been executed yet, in chronological order. Before applying, ctkit displays a summary of pending migrations and asks for confirmation.

Pending migrations:
1. 20250702T143021_crystal_lion_hammer.js
2. 20250703T091500_add-author-bio.js
Apply 2 migrations? (y/N)

Each migration is tracked in your Contentful space. After execution, ctkit records the migration ID, timestamp, and result (success or failed) so it knows which migrations have already run.

Terminal window
ctkit migrate --target 20250702T143021_crystal_lion_hammer

Applies all pending migrations up to but not including the specified migration. This is useful when you want to partially catch up without applying everything.

Terminal window
ctkit migrate --dry-run

Shows which migrations would be applied and what changes they contain, without actually executing anything. Nothing is written to Contentful.

Terminal window
ctkit migrate --force

Executes migrations even if they have already been marked as executed. Use this to retry a failed migration after fixing the underlying issue, or to re-apply a migration in a fresh environment.

Terminal window
ctkit migrate --yes

Skips the interactive confirmation prompt and applies migrations immediately. Useful in CI/CD pipelines where there is no terminal to confirm.

Terminal window
# Typical CI usage
ctkit migrate --yes
FlagDescription
--target <id>Apply migrations up to (but not including) the given migration ID.
--dry-runPreview which migrations would run without executing them.
--forceRe-run migrations that have already been executed.
--yesSkip the confirmation prompt.

ctkit stores migration state directly in your Contentful space. Each executed migration is recorded with:

  • Migration ID — the filename without extension
  • Statussuccess or failed
  • Executed at — UTC timestamp of when it ran

This means migration history follows the environment. If you clone a Contentful environment, the migration history comes with it.

Use ctkit status to see a summary of migration state, or ctkit history for the full execution log.