Database Migration Generator

Version: 1.0 Added: Jan 21, 2026

Description

Creates database migration files for schema changes. Supports up/down migrations, handles data transformations, and works with popular ORMs like Prisma, Sequelize, and Django.

Code

Skill Code
Migration includes:
1. Timestamp-prefixed filename
2. Up migration (apply changes)
3. Down migration (rollback)
4. Data migration "keyword">if needed
5. Index creation
6. Foreign key constraints

Usage Examples

Examples
User: add a "status" field to the orders table

Claude: *creates migration*
```javascript
// 20260121_add_status_to_orders.js
exports.up = async (knex) => {
  await knex.schema.alterTable("orders", (table) => {
    table.enum("status", ["pending", "paid", "shipped", "delivered"])
         .defaultTo("pending");
  });
};

exports.down = async (knex) => {
  await knex.schema.alterTable("orders", (table) => {
    table.dropColumn("status");
  });
};
```

Installation

Add the following to your CLAUDE.md file (project root or ~/.claude/CLAUDE.md for global):

CLAUDE.md
# Database Migration Generator

Migration includes:
1. Timestamp-prefixed filename
2. Up migration (apply changes)
3. Down migration (rollback)
4. Data migration if needed
5. Index creation
6. Foreign key constraints

Comments (0)

No comments yet. Be the first to share your thoughts!