generate
Generate a migration
Section titled “Generate a migration”ctkit generateConnects to your Contentful space, compares your local schema definitions against the remote content model, and produces a timestamped migration file containing the diff.
The generated file lands in your migrations/ directory:
migrations/20250702T143021_crystal_lion_hammer.jsFile names combine a UTC timestamp with a randomly generated human-readable slug so they sort chronologically and are easy to reference in conversation.
Custom migration name
Section titled “Custom migration name”ctkit generate --name add-author-bioReplaces the random slug with your chosen name:
migrations/20250702T143021_add-author-bio.jsEmpty migration (custom template)
Section titled “Empty migration (custom template)”ctkit generate --customCreates a migration file with an empty scaffold instead of auto-generated steps. Use this when you need to write migration logic by hand — for example, transforming existing entry data or running a content backfill.
export default { up(migration) { // Write your migration steps here },};Generate a schema file
Section titled “Generate a schema file”ctkit generate schema blogPostScaffolds a new schema file in your schemas/ directory with the boilerplate already filled in:
import { contentType, fields } from '@ctkit/core';
export const blogPost = contentType('blogPost', { name: 'Blog Post', fields: {},});This is a convenience shortcut — you can always create schema files manually.
| Flag | Description |
|---|---|
--name <name> | Set a custom name for the migration file instead of a random slug. |
--custom | Generate an empty migration template instead of auto-diffing schemas. |
How it works
Section titled “How it works”- ctkit loads all schema definitions from your
schemas/directory. - It fetches the current content model from Contentful via the Content Management API.
- It diffs the two and produces a migration file with the minimal set of changes needed to bring the remote model in line with your local schemas.
- The migration file is written to
migrations/but not executed — runctkit migrateto apply it.
If there are no differences between local and remote, ctkit will tell you everything is already in sync and skip file creation.