database-migration-helper

Creates database migration files following project conventions for Prisma, Sequelize, Alembic, Knex, TypeORM, and other ORMs. Use when adding tables, modifying schemas, or when user mentions database changes.

242 stars

Best use case

database-migration-helper is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Creates database migration files following project conventions for Prisma, Sequelize, Alembic, Knex, TypeORM, and other ORMs. Use when adding tables, modifying schemas, or when user mentions database changes.

Creates database migration files following project conventions for Prisma, Sequelize, Alembic, Knex, TypeORM, and other ORMs. Use when adding tables, modifying schemas, or when user mentions database changes.

Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.

Practical example

Example input

Use the "database-migration-helper" skill to help with this workflow task. Context: Creates database migration files following project conventions for Prisma, Sequelize, Alembic, Knex, TypeORM, and other ORMs. Use when adding tables, modifying schemas, or when user mentions database changes.

Example output

A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.

When to use this skill

  • Use this skill when you want a reusable workflow rather than writing the same prompt again and again.

When not to use this skill

  • Do not use this when you only need a one-off answer and do not need a reusable workflow.
  • Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/database-migration-helper/SKILL.md --create-dirs "https://raw.githubusercontent.com/aiskillstore/marketplace/main/skills/crazydubya/database-migration-helper/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/database-migration-helper/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How database-migration-helper Compares

Feature / Agentdatabase-migration-helperStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Creates database migration files following project conventions for Prisma, Sequelize, Alembic, Knex, TypeORM, and other ORMs. Use when adding tables, modifying schemas, or when user mentions database changes.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Database Migration Helper

This skill helps you create database migration files that follow your project's ORM conventions and naming patterns.

## When to Use This Skill

- User requests to create a database migration
- Adding new tables or columns to the database
- Modifying existing database schema
- Creating indexes, constraints, or relationships
- User mentions "migration", "schema change", or "database update"

## Instructions

### 1. Detect the ORM/Migration Tool

First, identify which ORM or migration tool the project uses:

- **Prisma**: Look for `prisma/schema.prisma` or `@prisma/client` in package.json
- **Sequelize**: Look for `.sequelizerc` or `sequelize-cli` in package.json
- **Knex**: Look for `knexfile.js` or `knex` in package.json
- **TypeORM**: Look for `ormconfig.json` or `typeorm` in package.json
- **Alembic** (Python): Look for `alembic.ini` or `alembic/` directory
- **Django**: Look for `manage.py` and Django migrations in `*/migrations/`
- **Active Record** (Rails): Look for `db/migrate/` directory
- **Flyway**: Look for `flyway.conf` or `db/migration/`
- **Liquibase**: Look for `liquibase.properties` or changelog files

Use Glob to search for these indicator files.

### 2. Examine Existing Migrations

Read existing migration files to understand:

- Naming conventions (timestamp format, description format)
- Directory structure
- Migration file format (SQL, JavaScript, TypeScript, Python, etc.)
- Coding patterns (up/down functions, forwards/rollback, etc.)

Use Grep to find recent migrations: look in common directories like:
- `prisma/migrations/`
- `db/migrate/`
- `migrations/` or `database/migrations/`
- `alembic/versions/`

### 3. Generate Migration File

Based on the detected ORM, create an appropriate migration file:

#### Prisma
- Run `npx prisma migrate dev --name <description>` OR
- Manually create migration SQL in `prisma/migrations/<timestamp>_<name>/migration.sql`

#### Sequelize
- Generate: `npx sequelize-cli migration:generate --name <description>`
- Then fill in the up/down functions with the schema changes

#### Knex
- Generate: `npx knex migrate:make <description>`
- Fill in exports.up and exports.down functions

#### TypeORM
- Generate: `npm run typeorm migration:create src/migrations/<Name>`
- Implement up() and down() methods

#### Alembic
- Generate: `alembic revision -m "<description>"`
- Fill in upgrade() and downgrade() functions

#### Django
- Run: `python manage.py makemigrations`
- Or manually create migration in `<app>/migrations/`

#### Rails
- Generate: `rails generate migration <ClassName>`
- Fill in the change method (or up/down for complex migrations)

### 4. Follow Naming Conventions

Use consistent, descriptive names:

- **Good**: `add_user_email_index`, `create_products_table`, `add_payment_status_to_orders`
- **Bad**: `migration1`, `update`, `fix`

Format based on project patterns:
- Timestamp prefix: `20231215120000_add_email_to_users`
- Sequential: `001_create_users`, `002_add_indexes`

### 5. Include Both Up and Down/Rollback

Always provide both directions when supported:

- **Up/Upgrade/Forward**: Apply the schema change
- **Down/Downgrade/Rollback**: Revert the schema change

For ORMs that use reversible operations (Rails, some Sequelize), a single `change` method may be sufficient.

### 6. Migration Content Guidelines

**Creating Tables:**
- Define all columns with appropriate types
- Set NOT NULL constraints where appropriate
- Add primary keys
- Include timestamps (created_at, updated_at) if project uses them
- Add foreign keys and indexes in the same migration or separate if project prefers

**Altering Tables:**
- Be specific: `ADD COLUMN`, `DROP COLUMN`, `MODIFY COLUMN`
- Handle existing data appropriately (defaults, backfills)
- Consider backwards compatibility

**Adding Indexes:**
- Name indexes clearly: `idx_users_email`, `idx_orders_user_id_created_at`
- Use appropriate index types (B-tree, Hash, GIN, etc.)
- Consider partial indexes for large tables

**Data Migrations:**
- Separate schema migrations from data migrations if possible
- Be cautious with large datasets (batch operations)
- Test rollback with realistic data volumes

### 7. Validate Migration Safety

Before finalizing, check:

- **Reversibility**: Can the migration be rolled back?
- **Data loss**: Will any data be lost? Warn the user!
- **Downtime**: Will this lock tables? Consider online migrations for large tables
- **Dependencies**: Are there dependent migrations that must run first?

### 8. Testing Recommendations

Suggest to the user:
- Run migration on a development database first
- Test rollback functionality
- For production: test on a staging environment
- Review generated SQL (for ORMs that auto-generate)

## ORM-Specific Templates

Reference the templates in `templates/` directory:

- `prisma-migration.sql` - Prisma migration example
- `sequelize-migration.js` - Sequelize migration example
- `knex-migration.js` - Knex migration example
- `typeorm-migration.ts` - TypeORM migration example
- `alembic-migration.py` - Alembic migration example
- `rails-migration.rb` - Rails migration example

## Best Practices

1. **One purpose per migration**: Don't mix unrelated changes
2. **Descriptive names**: Names should explain what the migration does
3. **Timestamps**: Use the ORM's timestamp format for ordering
4. **Idempotent when possible**: Safe to run multiple times
5. **Test rollbacks**: Ensure down/rollback works correctly
6. **Document complex logic**: Add comments for non-obvious operations
7. **Batch large operations**: For data migrations affecting many rows
8. **Use transactions**: Wrap operations in transactions when supported

## Supporting Files

- `templates/`: Migration templates for various ORMs
- `reference.md`: Naming conventions and migration patterns

Related Skills

obsidian-helper

242
from aiskillstore/marketplace

Obsidian 智能笔记助手。当用户提到 obsidian、日记、笔记、知识库、capture、review 时激活。 【激活后必须执行】: 1. 先完整阅读本 SKILL.md 文件 2. 理解 AI 写入三条硬规矩(00_Inbox/AI/、追加式、白名单字段) 3. 按 STEP 0 → STEP 1 → ... 顺序执行 4. 不要跳过任何步骤,不要自作主张 【禁止行为】: - 禁止不读 SKILL.md 就开始工作 - 禁止跳过用户确认步骤 - 禁止在非 00_Inbox/AI/ 位置创建新笔记(除非用户明确指定)

vector-database-engineer

242
from aiskillstore/marketplace

Expert in vector databases, embedding strategies, and semantic search implementation. Masters Pinecone, Weaviate, Qdrant, Milvus, and pgvector for RAG applications, recommendation systems, and similar

sqlmap-database-pentesting

242
from aiskillstore/marketplace

This skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "dump tables and columns...

sqlmap-database-penetration-testing

242
from aiskillstore/marketplace

This skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "dump tables and columns from a vulnerable database," or "perform automated database penetration testing." It provides comprehensive guidance for using SQLMap to detect and exploit SQL injection vulnerabilities.

godot-4-migration

242
from aiskillstore/marketplace

Specialized guide for migrating Godot 3.x projects to Godot 4 (GDScript 2.0), covering syntax changes, Tweens, and exports.

framework-migration-legacy-modernize

242
from aiskillstore/marketplace

Orchestrate a comprehensive legacy system modernization using the strangler fig pattern, enabling gradual replacement of outdated components while maintaining continuous business operations through ex

framework-migration-deps-upgrade

242
from aiskillstore/marketplace

You are a dependency management expert specializing in safe, incremental upgrades of project dependencies. Plan and execute dependency updates with minimal risk, proper testing, and clear migration pa

framework-migration-code-migrate

242
from aiskillstore/marketplace

You are a code migration expert specializing in transitioning codebases between frameworks, languages, versions, and platforms. Generate comprehensive migration plans, automated migration scripts, and

database-optimizer

242
from aiskillstore/marketplace

Expert database optimizer specializing in modern performance tuning, query optimization, and scalable architectures. Masters advanced indexing, N+1 resolution, multi-tier caching, partitioning strategies, and cloud database optimization. Handles complex query analysis, migration strategies, and performance monitoring. Use PROACTIVELY for database optimization, performance issues, or scalability challenges.

database-migrations-sql-migrations

242
from aiskillstore/marketplace

SQL database migrations with zero-downtime strategies for PostgreSQL, MySQL, SQL Server

database-migrations-migration-observability

242
from aiskillstore/marketplace

Migration monitoring, CDC, and observability infrastructure

database-design

242
from aiskillstore/marketplace

Database design principles and decision-making. Schema design, indexing strategy, ORM selection, serverless databases.