DA

database-migration

Tools to manage database schema changes with TypeORM.

Install

mkdir -p .claude/skills/database-migration-xiangteng007 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15740" && unzip -o skill.zip -d .claude/skills/database-migration-xiangteng007 && rm skill.zip

Installs to .claude/skills/database-migration-xiangteng007

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

創建和執行 TypeORM 資料庫遷移,管理 schema 變更
32 charsno explicit “when” trigger
Beginner

Key capabilities

  • Automatically generate TypeORM migrations from entity changes
  • Manually create blank migration files
  • Run all pending database migrations
  • Revert the last executed migration
  • View the status of database migrations
  • Implement reversible database schema changes

How it works

The skill provides commands to generate, run, revert, and show the status of TypeORM database migrations. It supports both automatic generation from entity changes and manual creation of migration files.

Inputs & outputs

You give it
TypeORM entity changes or a command to create a blank migration
You get back
A new migration file, updated database schema, or a report on migration status

When to use database-migration

  • Generate migration from entity changes
  • Run pending database migrations
  • Revert a failed migration

About this skill

Database Migration Skill

管理 TypeORM 資料庫遷移。

創建遷移

自動生成(從 Entity 變更)

cd backend
npm run migration:generate -- src/migrations/DescriptiveName

手動創建空白遷移

cd backend
npm run migration:create -- src/migrations/DescriptiveName

執行遷移

運行所有待執行遷移

npm run migration:run

回滾上一次遷移

npm run migration:revert

查看遷移狀態

npm run migration:show

遷移檔案結構

import { MigrationInterface, QueryRunner } from 'typeorm';

export class DescriptiveName1234567890 implements MigrationInterface {
    name = 'DescriptiveName1234567890';

    public async up(queryRunner: QueryRunner): Promise<void> {
        // 升級操作
        await queryRunner.query(`ALTER TABLE ...`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        // 回滾操作
        await queryRunner.query(`ALTER TABLE ...`);
    }
}

最佳實踐

  1. 命名規範: 使用描述性名稱,如 AddUserEmailIndex
  2. 原子性: 每個遷移只做一件事
  3. 可回滾: 確保 down() 方法正確實作
  4. 測試: 在開發環境先測試遷移
  5. 備份: 生產環境執行前先備份資料庫

When not to use it

  • When using a different ORM or database migration tool
  • When direct SQL schema changes are preferred
  • When the database schema is static and does not require versioning

Limitations

  • Specific to TypeORM database migrations
  • Requires manual implementation of the down() method for reversibility
  • Best practices recommend testing migrations in a development environment first

How it compares

This skill offers a structured approach to managing TypeORM database schema changes through versioned migrations, ensuring atomic and reversible updates, unlike manual SQL script execution.

Compared to similar skills

database-migration side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
database-migration (this skill)07moReviewBeginner
drizzle-orm322moNo flagsIntermediate
backend-dev16moNo flagsIntermediate
prisma-database06moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry