Skip to main content
command

create-database-migrations — Claude Code command: migrations

A Claude slash command that generates database migration files with versioning and rollback methods. Useful when you change a schema and don't want to hand-write up/down.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command setup/create-database-migrations
Open on GitHub

What create-database-migrations does

The command starts by reading your current database state: it detects the ORM from package.json or requirements.txt (Sequelize, Prisma, Alembic and others), reads the database config or prisma/schema.prisma, and counts files in migrations/. Then it picks the migration type from your argument — table creation, column addition, table alteration or a data migration.

You get timestamped migration files with up and down methods, schema updates, index handling, and a rollback strategy for each change. Data transformations and backfills are planned separately so existing rows don't break mid-deploy.

Tool access is limited to Read, Write, Edit and Bash. No write or shell access in the project means the command can't do its job. Pass the migration name as the argument; flags like --create-table or --add-column set the change type.

What it helps with

  • generate a migration file with up and down methods
  • add a column to an existing table without hand-written SQL
  • write a backfill for a new schema
  • plan a rollback for every schema change
  • update indexes alongside a migration

Example prompts for the agent

  • /create-database-migrations add-users-table
  • /create-database-migrations add-email-column --add-column
  • /create-database-migrations alter-orders --alter-table

How to install create-database-migrations

1claude-code-templates

npx claude-code-templates@latest --command setup/create-database-migrations

2Manually: put the files in place

.claude/commands/create-database-migrations.md

Call it with /create-database-migrations. For all projects use ~/.claude/commands/

Questions about create-database-migrations

How do I install create-database-migrations in Claude?

Run npx claude-code-templates@latest --command setup/create-database-migrations, then check that the file landed at .claude/commands/create-database-migrations.md.

What does create-database-migrations do?

It creates and manages database migrations: generates versioned files, updates the schema, and writes rollback procedures.

What tools does the command need?

The frontmatter lists Read, Write, Edit and Bash. Without file-write and shell access, no migrations get created.

Source text

create-database-migrations.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[migration-name] | --create-table | --add-column | --alter-table"
description: Create and manage database migrations with proper versioning and rollback support
---

# Create Database Migrations

Create and manage database migrations: **$ARGUMENTS**

## Current Database State

- ORM detection: @package.json or @requirements.txt (detect Sequelize, Prisma, Alembic, etc.)
- Migration files: !`find . -name "*migration*" -type f | head -5`
- Database config: @config/database.* or @prisma/schema.prisma
- Current schema: !`ls migrations/ 2>/dev/null | wc -l` migrations found

## Task

Create comprehensive database migrations with proper versioning and rollback capabilities:

**Migration Types**: Use $ARGUMENTS to specify table creation, column addition, table alteration, or data migration

**Migration Framework**:
1. **Migration Planning** - Analyze schema changes, dependencies, and data impact
2. **Migration Generation** - Create timestamped migration files with up/down methods
3. **Schema Updates** - Table creation, column modifications, index management
4. **Data Migrations** - Safe data transformations and backfills
5. **Rollback Strategy** - Implement reliable rollback procedures for each change
6. **Testing** - Validate migrations in development and staging environments

**Best Practices**: Follow database-specific conventions, maintain referential integrity, handle large datasets efficiently, and ensure zero-downtime deployments.

**Output**: Production-ready migration files with comprehensive rollback support, proper indexing, and data safety measures.

© davila7 · MIT · davila7/claude-code-templates

Similar slash commands

All slash commands for Data and databases →

From the same set205

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor