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.
Best use case
database-migration-helper is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using database-migration-helper should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/database-migration-helper/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How database-migration-helper Compares
| Feature / Agent | database-migration-helper | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/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
scaffolding-oracle-to-postgres-migration-test-project
Scaffolds an xUnit integration test project for validating Oracle-to-PostgreSQL database migration behavior in .NET solutions. Creates the test project, transaction-rollback base class, and seed data manager. Use when setting up test infrastructure before writing migration integration tests, or when a test project is needed for Oracle-to-PostgreSQL validation.
reviewing-oracle-to-postgres-migration
Identifies Oracle-to-PostgreSQL migration risks by cross-referencing code against known behavioral differences (empty strings, refcursors, type coercion, sorting, timestamps, concurrent transactions, etc.). Use when planning a database migration, reviewing migration artifacts, or validating that integration tests cover Oracle/PostgreSQL differences.
planning-oracle-to-postgres-migration-integration-testing
Creates an integration testing plan for .NET data access artifacts during Oracle-to-PostgreSQL database migrations. Analyzes a single project to identify repositories, DAOs, and service layers that interact with the database, then produces a structured testing plan. Use when planning integration test coverage for a migrated project, identifying which data access methods need tests, or preparing for Oracle-to-PostgreSQL migration validation.
issue-fields-migration
Bulk-migrate metadata to GitHub issue fields from two sources: repo labels (e.g. priority labels to a Priority field) and Project V2 fields. Use when users say "migrate my labels to issue fields", "migrate project fields to issue fields", "convert labels to issue fields", "copy project field values to issue fields", or ask about adopting issue fields. Issue fields are org-level typed metadata (single select, text, number, date) that replace label-based workarounds with structured, searchable, cross-repo fields.
creating-oracle-to-postgres-migration-integration-tests
Creates integration test cases for .NET data access artifacts during Oracle-to-PostgreSQL database migrations. Generates DB-agnostic xUnit tests with deterministic seed data that validate behavior consistency across both database systems. Use when creating integration tests for a migrated project, generating test coverage for data access layers, or writing Oracle-to-PostgreSQL migration validation tests.
creating-oracle-to-postgres-migration-bug-report
Creates structured bug reports for defects found during Oracle-to-PostgreSQL migration. Use when documenting behavioral differences between Oracle and PostgreSQL as actionable bug reports with severity, root cause, and remediation steps.
creating-oracle-to-postgres-master-migration-plan
Discovers all projects in a .NET solution, classifies each for Oracle-to-PostgreSQL migration eligibility, and produces a persistent master migration plan. Use when starting a multi-project Oracle-to-PostgreSQL migration, creating a migration inventory, or assessing which .NET projects contain Oracle dependencies.
database-query
Query database safely with parameterized statements
react-native-brownfield-migration
Provides an incremental adoption strategy to migrate native iOS or Android apps to React Native or Expo using @callstack/react-native-brownfield for initial setup. Use when planning migration steps, packaging XCFramework/AAR artifacts, and integrating them into host apps.
migration-architect
Migration Architect
database-designer
Use when the user asks to design database schemas, plan data migrations, optimize queries, choose between SQL and NoSQL, or model data relationships.
obsidian-helper
Obsidian 智能笔记助手。当用户提到 obsidian、日记、笔记、知识库、capture、review 时激活。 【激活后必须执行】: 1. 先完整阅读本 SKILL.md 文件 2. 理解 AI 写入三条硬规矩(00_Inbox/AI/、追加式、白名单字段) 3. 按 STEP 0 → STEP 1 → ... 顺序执行 4. 不要跳过任何步骤,不要自作主张 【禁止行为】: - 禁止不读 SKILL.md 就开始工作 - 禁止跳过用户确认步骤 - 禁止在非 00_Inbox/AI/ 位置创建新笔记(除非用户明确指定)