Communitygithub.com

データベースマイグレーションヘルパー

Prisma、Sequelize、Alembic、Knex、TypeORMなどのORMのプロジェクト規約に従ったデータベースマイグレーションファイルを作成します。テーブル追加、スキーマ変更、データベース変更のユーザー言及時に使用します。

データベースマイグレーションヘルパー とは?

このスキルは、開発者がプロジェクトで使用しているORMやマイグレーションツールを自動検出し、そのツールの規約に沿ったマイグレーションファイルを生成します。Prisma、Sequelize、Knex、TypeORM、Alembic、Django、Rails、Flyway、Liquibaseなど、幅広いツールをサポートしています。ファイルの命名規則、ディレクトリ構造、コードパターンを既存のマイグレーションから学習し、一貫性のあるマイグレーションを作成します。また、アップとダウンの両方向の操作を提供し、データ損失やダウンタイムのリスクをチェックするなど、安全なマイグレーションを支援します。Claude CodeやCursorなどのAIエージェント開発環境で活用でき、開発者はスキーマ変更の記述に集中できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazydubya/database-migration-helper

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

データベースマイグレーションヘルパー は何をしますか?

このスキルは、プロジェクトのORM規約と命名パターンに従ったデータベースマイグレーションファイルを作成するのに役立ちます。

このスキルを使用するタイミング

  • ユーザーがデータベースマイグレーションの作成をリクエストしたとき
  • 新しいテーブルやカラムをデータベースに追加するとき
  • 既存のデータベーススキーマを変更するとき
  • インデックス、制約、リレーションシップを作成するとき
  • ユーザーが「マイグレーション」「スキーマ変更」「データベース更新」に言及したとき

手順

1. ORM/マイグレーションツールの検出

まず、プロジェクトが使用しているORMまたはマイグレーションツールを特定します。

  • Prisma: prisma/schema.prisma または package.json 内の @prisma/client を確認
  • Sequelize: .sequelizerc または package.json 内の sequelize-cli を確認
  • Knex: knexfile.js または package.json 内の knex を確認
  • TypeORM: ormconfig.json または package.json 内の typeorm を確認
  • Alembic (Python): alembic.ini または alembic/ ディレクトリを確認
  • Django: manage.py と */migrations/ 内のDjangoマイグレーションを確認
  • Active Record (Rails): db/migrate/ ディレクトリを確認
  • Flyway: flyway.conf または db/migration/ を確認
  • Liquibase: liquibase.properties またはチェンジログファイルを確認

Globを使用してこれらの指標ファイルを検索します。

2. 既存のマイグレーションの確認

既存のマイグレーションファイルを読み取り、以下を把握します。

  • 命名規則(タイムスタンプ形式、説明形式)
  • ディレクトリ構造
  • マイグレーションファイルの形式(SQL、JavaScript、TypeScript、Pythonなど)
  • コーディングパターン(up/down関数、forwards/rollbackなど)

Grepを使用して最近のマイグレーションを検索します。一般的なディレクトリは以下の通りです。

  • prisma/migrations/
  • db/migrate/
  • migrations/ または database/migrations/
  • alembic/versions/

3. マイグレーションファイルの生成

検出されたORMに基づいて、適切なマイグレーションファイルを作成します。

Prisma

  • npx prisma migrate dev --name <説明> を実行
  • または、prisma/migrations/<タイムスタンプ>_<名前>/migration.sql に手動でマイグレーションSQLを作成

Sequelize

  • 生成: npx sequelize-cli migration:generate --name <説明>
  • その後、up/down関数にスキーマ変更を記述

Knex

  • 生成: npx knex migrate:make <説明>
  • exports.up と exports.down 関数を記述

TypeORM

  • 生成: npm run typeorm migration:create src/migrations/<名前>
  • up() と down() メソッドを実装

Alembic

  • 生成: alembic revision -m "<説明>"
  • upgrade() と downgrade() 関数を記述

Django

  • 実行: python manage.py makemigrations
  • または <アプリ>/migrations/ に手動でマイグレーションを作成

Rails

  • 生成: rails generate migration <クラス名>
  • change メソッド(複雑なマイグレーションの場合は up/down)を記述

4. 命名規則に従う

一貫性のある説明的な名前を使用します。

  • 良い例: add_user_email_index、create_products_table、add_payment_status_to_orders
  • 悪い例: migration1、update、fix

プロジェクトのパターンに基づいてフォーマットします。

  • タイムスタンププレフィックス: 20231215120000_add_email_to_users
  • 連番: 001_create_users、002_add_indexes

5. UpとDown/Rollbackの両方を含める

サポートされている場合は、常に両方向を提供します。

  • Up/Upgrade/Forward: スキーマ変更を適用
  • Down/Downgrade/Rollback: スキーマ変更を元に戻す

Railsや一部のSequelizeのようにリバーシブル操作を使用するORMの場合は、単一の change メソッドで十分な場合があります。

6. マイグレーション内容のガイドライン

テーブルの作成:

  • 適切な型ですべてのカラムを定義
  • 必要に応じてNOT NULL制約を設定
  • 主キーを追加
  • プロジェクトが使用している場合はタイムスタンプ(created_at、updated_at)を含める
  • 同じマイグレーション内、またはプロジェクトの好みに応じて別のマイグレーションで外部キーとインデックスを追加

テーブルの変更:

  • 具体的に記述: ADD COLUMN、DROP COLUMN、MODIFY COLUMN
  • 既存データを適切に処理(デフォルト値、バックフィル)
  • 後方互換性を考慮

インデックスの追加:

  • インデックス名を明確に: idx_users_email、idx_orders_user_id_created_at
  • 適切なインデックスタイプ(B-tree、Hash、GINなど)を使用
  • 大規模テーブルでは部分インデックスを検討

データマイグレーション:

  • 可能であればスキーママイグレーションとデータマイグレーションを分離
  • 大規模データセットには注意(バッチ操作)
  • 現実的なデータ量でロールバックをテスト

7. マイグレーションの安全性検証

最終確定前に以下をチェックします。

  • リバーシビリティ: マイグレーションはロールバック可能ですか?
  • データ損失: データは失われますか?ユーザーに警告してください!
  • ダウンタイム: テーブルはロックされますか?大規模テーブルにはオンラインマイグレーションを検討
  • 依存関係: 先に実行する必要のある依存するマイグレーションはありますか?

8. テストの推奨事項

ユーザーに以下を提案します。

  • 最初に開発データベースでマイグレーションを実行
  • ロールバック機能をテスト
  • 本番環境ではステージング環境でテスト
  • 生成されたSQLを確認(自動生成するORMの場合)

ORM別テンプレート

templates/ ディレクトリ内のテンプレートを参照してください。

  • prisma-migration.sql - Prismaマイグレーションの例
  • sequelize-migration.js - Sequelizeマイグレーションの例
  • knex-migration.js - Knexマイグレーションの例
  • typeorm-migration.ts - TypeORMマイグレーションの例
  • alembic-migration.py - Alembicマイグレーションの例
  • rails-migration.rb - Railsマイグレーションの例

ベストプラクティス

  1. マイグレーションは1つの目的に: 無関係な変更を混在させない
  2. 説明的な名前: 名前がそのマイグレーションの内容を説明するように
  3. タイムスタンプ: 順序付けのためにORMのタイムスタンプ形式を使用
  4. 可能な限り冪等性: 複数回実行しても安全
  5. ロールバックのテスト: down/rollbackが正しく動作することを確認
  6. 複雑なロジックの文書化: 明白でない操作にはコメントを追加
  7. 大規模操作のバッチ処理: 多数の行に影響するデータマイグレーションの場合
  8. トランザクションの使用: サポートされている場合は操作をトランザクションでラップ

サポートファイル

  • templates/: 様々なORM向けのマイグレーションテンプレート
  • reference.md: 命名規則とマイグレーションパターン

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル