Create Database Migration

VerifiedSafe

Create database migrations for Ghost's MySQL database: add tables, columns, settings, or modify schema. Use whenever a task requires a migration file in ghost/core.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude CodeCursorCodex
#database-migrations#ghost-cms#knex#schema#mysql

Recommended for

Automated summary

Walks through creating a Ghost database migration, from generating the empty migration file through schema.js updates, rollback testing and the required test suites.

Strengths

  • Requires generating the file with `pnpm migrate:create` instead of hand-writing it, and flags the core/admin RC version bump.
  • Covers the whole loop: migrate forward, test `down()` via rollback, then the integration test that also checks idempotency.
  • Reminds you of easy-to-miss companion files (schema.js, the exporter's table-lists.js) and their focused tests.
  • Explicitly demands the migration passes against both MySQL and SQLite.

Limitations

  • Tightly coupled to the Ghost monorepo layout (ghost/core paths, knex-migrator, pnpm scripts); not reusable outside it.
  • Defers code patterns and rules to docs/practices/database-migrations.md, rules.md and examples.md, which are not included here.
  • Gives no guidance on backfill performance or safety on large tables.
When to use it

Use it whenever a Ghost change alters the schema — new table, column, index, setting or data update — and a migration file under ghost/core is required.

When not to use it

Don't use it for non-Ghost projects, or for changes that don't touch the database schema, such as API or theme work.

Security analysis

Safe
Quality score85/100

This is a documentation/checklist skill for creating Ghost CMS database migrations. All commands are standard repo-local tooling (pnpm migrate:create, knex-migrator, tests) with no network exfiltration, destructive filesystem operations, obfuscated payloads, or safety-disabling instructions. No allowed-tools are declared and referenced files are relative in-repo docs.

No concerns found

How this analysis is made

Examples

Add a column to posts
Add a nullable `featured_at` datetime column to the Ghost posts table and update schema.js to match.
Add a new setting
Add a new `members_anniversary_enabled` setting to Ghost — it needs a database migration.
Data backfill migration
Write a migration that backfills the `visibility` column on the posts table for existing rows, and test the rollback.

name: Create database migration description: Create a database migration to add a table, add columns to an existing table, add a setting, or otherwise change the schema of Ghost's MySQL database. Use this skill whenever the task involves modifying Ghost's database schema — including adding, removing, or renaming columns or tables, adding new settings, creating indexes, updating data, or any change that requires a migration file in ghost/core. Also use when the user references schema.js, knex-migrator, the migrations directory, or asks to "add a field" or "add a column" to any Ghost model/table. Even if the user frames it as a feature or Linear issue, if the implementation requires a schema change, this skill applies.

Create Database Migration

Read the canonical human guidance in docs/practices/database-migrations.md before making a migration. This skill is the executable checklist that accompanies it.

Instructions

  1. Create a new, empty migration file: cd ghost/core && pnpm migrate:create <kebab-case-slug>. IMPORTANT: do not create the migration file manually; always use this script to create the initial empty migration file. The slug must be kebab-case (e.g. add-column-to-posts).
  2. The above command will create a new directory in ghost/core/core/server/data/migrations/versions if needed, create the empty migration file with the appropriate name, and bump the core and admin package versions to RC if this is the first migration after a release.
  3. Update the migration file with the changes you want to make in the database, following the existing patterns in the codebase. Where appropriate, prefer to use the utility functions in ghost/core/core/server/data/migrations/utils/*.
  4. Update the schema definition file in ghost/core/core/server/data/schema/schema.js, and make sure it aligns with the latest changes from the migration.
  5. Test the migration manually: cd ghost/core && pnpm knex-migrator migrate --v {version directory} --force
  6. Roll the migration back to test down(): cd ghost/core && pnpm knex-migrator rollback --v {previous version} --force, then migrate forward again.
  7. Run the migration integration test, which covers initialization, rollback, forward migration, and idempotency: cd ghost/core && pnpm test:single test/integration/migrations/migration.test.js. Migrations must pass the database-backed suites against both MySQL and SQLite.
  8. If adding or dropping a table, update ghost/core/core/server/data/exporter/table-lists.js as appropriate. The consistency assertion in ghost/core/test/unit/server/data/exporter/index.test.js checks that every schema table is classified in the exporter lists.
  9. Run the focused exporter unit test when the table lists change: cd ghost/core && pnpm test:single test/unit/server/data/exporter/index.test.js.
  10. Run the schema integrity test, and update the hash: cd ghost/core && pnpm test:single test/unit/server/data/schema/integrity.test.js
  11. Run unit tests in Ghost core, and iterate until they pass: cd ghost/core && pnpm test:unit

Examples

See examples.md for example migrations.

Rules

See rules.md for rules that should always be followed when creating database migrations.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/create-database-migration-mte1livc/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/create-database-migration-mte1livc' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/create-database-migration-mte1livc/download' --output '.skill-downloads/create-database-migration-mte1livc/SKILL.md.part' && mv '.skill-downloads/create-database-migration-mte1livc/SKILL.md.part' '.skill-downloads/create-database-migration-mte1livc/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/create-database-migration-mte1livc/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills