migrate
Apply all pending migrations
Section titled “Apply all pending migrations”ctkit migrateRuns 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.
Target a specific migration
Section titled “Target a specific migration”ctkit migrate --target 20250702T143021_crystal_lion_hammerApplies all pending migrations up to but not including the specified migration. This is useful when you want to partially catch up without applying everything.
Preview changes
Section titled “Preview changes”ctkit migrate --dry-runShows which migrations would be applied and what changes they contain, without actually executing anything. Nothing is written to Contentful.
Re-run migrations
Section titled “Re-run migrations”ctkit migrate --forceExecutes 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.
Skip confirmation
Section titled “Skip confirmation”ctkit migrate --yesSkips the interactive confirmation prompt and applies migrations immediately. Useful in CI/CD pipelines where there is no terminal to confirm.
# Typical CI usagectkit migrate --yes| Flag | Description |
|---|---|
--target <id> | Apply migrations up to (but not including) the given migration ID. |
--dry-run | Preview which migrations would run without executing them. |
--force | Re-run migrations that have already been executed. |
--yes | Skip the confirmation prompt. |
Migration tracking
Section titled “Migration tracking”ctkit stores migration state directly in your Contentful space. Each executed migration is recorded with:
- Migration ID — the filename without extension
- Status —
successorfailed - 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.