Create Database Rapid
Powerful command for create, manage, database, migrations. Includes structured workflows, validation checks, and reusable patterns for setup.
Create Database Rapid
Generate timestamped database migration files with up/down methods, schema changes, data transformations, and rollback strategies for your detected ORM framework.
When to Use This Command
Run this command when...
- You need to create a new database migration for table creation, column additions, or schema alterations
- You want properly timestamped migration files with both up and down methods for safe rollbacks
- You need to perform data migrations or backfills alongside schema changes with transactional safety
- You are working with Prisma, Sequelize, Alembic, Knex, or other ORM migration frameworks
- You want migration files that follow your framework's conventions with proper indexing and constraints
Quick Start
# .claude/commands/create-database-rapid.yaml name: Create Database Rapid description: Generate database migrations with rollback support inputs: - name: description description: "What this migration does" - name: type description: "create-table, add-column, alter-table, data-migration" default: "create-table"
# Create a new users table claude "create-database-rapid 'create users table' --type create-table" # Add a column to an existing table claude "create-database-rapid 'add email_verified to users' --type add-column" # Data migration with backfill claude "create-database-rapid 'backfill user display names' --type data-migration"
Output:
[detect] ORM: Prisma (prisma/schema.prisma found)
[generate] Migration: 20260315_create_users_table
[create] prisma/migrations/20260315_create_users_table/migration.sql
[schema] Updated prisma/schema.prisma with User model
[validate] Migration syntax verified
[preview] Tables: users (id, email, name, created_at, updated_at)
Done. Run 'npx prisma migrate dev' to apply.
Core Concepts
| Concept | Description |
|---|---|
| ORM Detection | Auto-detects migration framework from Prisma, Sequelize, Knex, Alembic, TypeORM, or Django |
| Timestamped Files | Migration files include ISO timestamps for ordering and conflict-free merges |
| Up/Down Methods | Every migration includes both forward (up) and rollback (down) implementations |
| Data Safety | Data migrations use transactions and batch processing to prevent data loss on failure |
| Index Strategy | Automatically suggests indexes based on column types, foreign keys, and query patterns |
Migration Lifecycle:
ββββββββββββ ββββββββββββ ββββββββββββ
β Generate ββββ>β Validate ββββ>β Apply β
β Migrationβ β Syntax β β (Dev DB) β
ββββββββββββ ββββββββββββ ββββββ¬ββββββ
β
ββββββΌββββββ
β Test & β
β Verify β
ββββββ¬ββββββ
β
ββββββββββββββββ€
βΌ βΌ
βββββββββββ ββββββββββββ
β Promote β β Rollback β
β to Prod β β (Down) β
βββββββββββ ββββββββββββ
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
description | string | required | Human-readable description of what the migration does |
type | string | "create-table" | Migration type: create-table, add-column, alter-table, data-migration, drop-table |
table | string | inferred | Target table name; inferred from description if not specified |
columns | string | "" | Column definitions: "name:string, age:integer, email:string:unique" |
dry_run | boolean | false | Preview generated migration without writing files |
Best Practices
- One change per migration -- Keep each migration focused on a single schema change. This makes rollbacks predictable and debugging easier when a migration fails.
- Always write the down method -- Skipping rollback logic saves time now but creates pain later. Test the down method on your development database before promoting to staging.
- Use transactions for data migrations -- Wrap data transformations in transactions so that partial failures do not leave the database in an inconsistent state.
- Add indexes deliberately -- Foreign keys and frequently queried columns should have indexes. Let the command suggest them, then review whether they match your actual query patterns.
- Test migrations on a copy of production data -- Schema changes that work on empty tables may fail or be slow on tables with millions of rows. Test with realistic data volumes.
Common Issues
- ORM not detected -- The command looks for framework-specific files like
prisma/schema.prismaoralembic.ini. If your ORM config is in a non-standard location, specify the framework explicitly. - Migration conflicts with teammates -- Two developers creating migrations simultaneously can produce conflicting timestamps. Coordinate migration creation or use your ORM's conflict resolution tools.
- Rollback fails on data migration -- Data backfills cannot always be reversed (e.g., hashing a column). Document irreversible migrations clearly and consider backup strategies.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.