Agent skill

Database Migration

by seb1n in seb1n/awesome-ai-agent-skills

Create, execute, and roll back versioned database schema migrations using tools like Alembic, Prisma Migrate, Flyway, and Knex.

MITAuto-check passedDatabases

Install Database Migration

skills CLI
$ npx skills add seb1n/awesome-ai-agent-skills --skill database-migration -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install seb1n/awesome-ai-agent-skills database-migration --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/database/database-migration .claude/skills/database-migration && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
database-migration
GitHub stars
206
Token cost
~2.3k tokens
SKILL.md length
828 words
Files
1
Skills in repo
92
Repo updated
First seen
Licence
MIT

At a glance

Create, execute, and roll back versioned database schema migrations using tools like Alembic, Prisma Migrate, Flyway, and Knex.

  • Works in 6 steps: Assess the schema change: Analyze the… → Select the migration tool: Choose the… → Generate the migration script:… → …
  • The user requests database migration
  • SKILL.md covers Workflow, Supported Technologies, Usage and Examples, plus 2 more sections
  • Calls npx

What it does

Database Migration is an agent skill from seb1n/awesome-ai-agent-skills. Create, execute, and roll back versioned database schema migrations using tools like Alembic, Prisma Migrate, Flyway, and Knex. Use when the user requests database migration or provides relevant inputs for this workflow.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Database migrations. It works with Prisma. The repository describes itself as: 103 ready-to-use AI agent skills for Claude Code, OpenAI Codex, Gemini CLI, Cursor, GitHub Copilot, Windsurf, and other Agent Skills-compatible tools. Complete SKILL.md… The licence is MIT.

When your agent uses it

  • The user requests database migration
  • Provides relevant inputs for this workflow

Example prompts

  • “/database-migration”

Requirements

  • Python 3
  • Node.js

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Assess the schema change: Analyze the requested change — adding columns, creating tables, modifying constraints, renaming fields, or…
  2. Select the migration tool: Choose the appropriate migration framework based on the project's tech stack. Use Alembic for Python/SQLAlchemy…
  3. Generate the migration script: Auto-generate a migration from schema diffs where supported (Alembic autogenerate, Prisma migrate dev)…
  4. Test in a staging environment: Apply the migration against a staging database that mirrors production. Verify that the migration applies…
  5. Deploy with zero-downtime strategy: For production, use expand-and-contract migrations. Phase 1: add new columns/tables (expand) without…
  6. Verify and monitor: After deployment, verify migration status with the framework's status command. Monitor application logs and database…

What it can do on your machine

Read from SKILL.md and the folder at commit 75865a5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npx, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Database Migration loads about 2.3k tokens when it runs. Until then it costs about 60 tokens; SKILL.md has 828 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~60
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from seb1n/awesome-ai-agent-skills at commit 75865a5, republished under its MIT licence (© seb1n). 828 words, ~2,296 tokens.

Download SKILL.mdSave it as .claude/skills/database-migration/SKILL.md (or your agent's skills folder).
name
database-migration
description
Create, execute, and roll back versioned database schema migrations using tools like Alembic, Prisma Migrate, Flyway, and Knex. Use when the user requests database migration or provides relevant inputs for this workflow.
license
MIT
metadata.author
AI Agent Skills Community
metadata.version
1.0.0

Database Migration

This skill enables an AI agent to manage versioned database schema changes through migration frameworks. The agent creates forward and rollback migration scripts, handles data backfills during schema changes, ensures zero-downtime deployments with safe migration patterns, and integrates migration workflows into CI/CD pipelines. It supports major tools including Alembic (Python/SQLAlchemy), Prisma Migrate (TypeScript/Node), Flyway (Java/SQL), and Knex (JavaScript).

Workflow

  1. Assess the schema change: Analyze the requested change — adding columns, creating tables, modifying constraints, renaming fields, or transforming data. Classify the change as backward-compatible (additive) or breaking (destructive) to determine the deployment strategy. Breaking changes require a multi-phase migration approach.

  2. Select the migration tool: Choose the appropriate migration framework based on the project's tech stack. Use Alembic for Python/SQLAlchemy projects, Prisma Migrate for TypeScript/Prisma projects, Flyway for Java or SQL-first workflows, and Knex for Node.js/Express projects. Ensure the tool is initialized and connected to the target database.

  3. Generate the migration script: Auto-generate a migration from schema diffs where supported (Alembic autogenerate, Prisma migrate dev), then review and edit the generated script. Add explicit rollback (downgrade) logic. For data backfills, include the data transformation within the migration to keep schema and data changes atomic.

  4. Test in a staging environment: Apply the migration against a staging database that mirrors production. Verify that the migration applies cleanly, that existing queries still work, and that the rollback restores the previous state. Run the application's test suite against the migrated schema.

  5. Deploy with zero-downtime strategy: For production, use expand-and-contract migrations. Phase 1: add new columns/tables (expand) without removing old ones. Phase 2: deploy application code that writes to both old and new structures. Phase 3: backfill data. Phase 4: deploy code using only new structures. Phase 5: remove old columns/tables (contract). This ensures no downtime and safe rollback at each phase.

  6. Verify and monitor: After deployment, verify migration status with the framework's status command. Monitor application logs and database performance for regressions. Confirm all migration metadata is recorded in the framework's version table.

Supported Technologies

  • Alembic: Python, SQLAlchemy, PostgreSQL/MySQL/SQLite
  • Prisma Migrate: TypeScript/JavaScript, Prisma ORM, PostgreSQL/MySQL/SQLite/SQL Server
  • Flyway: Java, SQL-based migrations, all major RDBMS
  • Knex: JavaScript/TypeScript, Node.js, PostgreSQL/MySQL/SQLite
  • Django Migrations: Python, Django ORM
  • Sequelize: JavaScript, Node.js ORM

Usage

Describe the schema change you need (e.g., "add a phone_number column to the users table") and specify which migration framework your project uses. The agent will generate the migration file with both upgrade and downgrade logic, provide instructions to apply it, and advise on safe deployment strategies for production.

Examples

Example 1: Alembic Migration — Adding a Column with Data Backfill

Request: Add a display_name column to the users table and backfill it by concatenating first_name and last_name.

Generate the migration:

bash
alembic revision --autogenerate -m "add_display_name_to_users"

Migration file (versions/20250115_add_display_name_to_users.py):

python
"""add display_name to users

Revision ID: a1b2c3d4e5f6
Revises: 9z8y7x6w5v4u
Create Date: 2025-01-15 10:30:00.000000
"""
from alembic import op
import sqlalchemy as sa

revision = "a1b2c3d4e5f6"
down_revision = "9z8y7x6w5v4u"
branch_labels = None
depends_on = None


def upgrade():
    # Phase 1: Add the column as nullable (safe, no locks on reads)
    op.add_column("users", sa.Column("display_name", sa.String(300), nullable=True))

    # Phase 2: Backfill existing rows
    users = sa.table(
        "users",
        sa.column("id", sa.Integer),
        sa.column("first_name", sa.String),
        sa.column("last_name", sa.String),
        sa.column("display_name", sa.String),
    )
    op.execute(
        users.update().values(
            display_name=sa.func.concat(
                users.c.first_name, " ", users.c.last_name
            )
        )
    )

    # Phase 3: Set NOT NULL after backfill is complete
    op.alter_column("users", "display_name", nullable=False)


def downgrade():
    op.drop_column("users", "display_name")

Apply and verify:

bash
alembic upgrade head
alembic current   # Confirms: a1b2c3d4e5f6 (head)
Example 2: Prisma Migrate — Adding a Reviews Model

Request: Add a Review model linked to User and Product in a Prisma project.

Update prisma/schema.prisma:

prisma
model Review {
  id        Int      @id @default(autoincrement())
  rating    Int      @db.SmallInt
  comment   String?  @db.Text
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  userId    Int
  productId Int
  user      User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  product   Product  @relation(fields: [productId], references: [id], onDelete: Cascade)

  @@unique([userId, productId])
  @@index([productId])
  @@index([rating])
}

Generate and apply the migration:

bash
npx prisma migrate dev --name add_reviews_table

Generated SQL (prisma/migrations/20250115_add_reviews_table/migration.sql):

sql
CREATE TABLE "Review" (
    "id" SERIAL NOT NULL,
    "rating" SMALLINT NOT NULL,
    "comment" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" INTEGER NOT NULL,
    "productId" INTEGER NOT NULL,
    CONSTRAINT "Review_pkey" PRIMARY KEY ("id")
);

CREATE INDEX "Review_productId_idx" ON "Review"("productId");
CREATE INDEX "Review_rating_idx" ON "Review"("rating");
CREATE UNIQUE INDEX "Review_userId_productId_key" ON "Review"("userId", "productId");
ALTER TABLE "Review" ADD CONSTRAINT "Review_userId_fkey"
    FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE;
ALTER TABLE "Review" ADD CONSTRAINT "Review_productId_fkey"
    FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE CASCADE;
Show full SKILL.md (341 more words)Show less

Best Practices

  • Always write explicit downgrade/rollback logic for every migration so you can revert safely if the deployment causes issues. Never assume you can manually undo a migration under pressure.
  • Make migrations backward-compatible by using expand-and-contract: add new structures first, then migrate data, then remove old structures in a separate migration after the new code is fully deployed.
  • Never run autogenerated migrations without review — auto-detect tools may produce destructive operations (dropping columns) when they encounter renamed fields. Always inspect the generated SQL.
  • Use transactions for DDL where supported (PostgreSQL wraps DDL in transactions; MySQL does not). For non-transactional DDL databases, plan for partial-failure recovery.
  • Keep migrations small and focused — one logical change per migration file. This makes rollbacks granular and makes it easier to identify which migration caused a problem.
  • Run migrations in CI against a disposable database to catch errors before they reach production. Include both upgrade and downgrade paths in the test.

Edge Cases

  • Large table migrations: Adding a NOT NULL column with a default to a table with millions of rows can lock the table for minutes in older PostgreSQL versions. Use ADD COLUMN ... DEFAULT ... NOT NULL (lock-free in PostgreSQL 11+) or add as nullable, backfill in batches, then set NOT NULL.
  • Renaming columns: Most migration tools treat renames as a drop + add, which causes data loss. Use op.alter_column() in Alembic or raw ALTER TABLE ... RENAME COLUMN to perform a true rename. Verify the generated migration before applying.
  • Concurrent migrations: In multi-instance deployments, ensure only one instance runs migrations. Use advisory locks (Flyway and Alembic support this) or a deployment pipeline that runs migrations as a dedicated step before rolling out application instances.
  • Enum type changes: Adding values to a PostgreSQL enum is non-transactional. Create a new enum type, migrate the column, then drop the old type. Alternatively, use a VARCHAR with a CHECK constraint for easier modification.
  • Data-only migrations: When you need to transform data without changing the schema (e.g., encrypting a column's values), still use a migration file to keep it versioned and reproducible across environments.

© seb1n, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in database/database-migration of seb1n/awesome-ai-agent-skills.

Open the folder on GitHubat commit 75865a5

Compare with similar skills

Database Migration next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Database Migration compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Database Migration this skillseb1n/awesome-ai-agent-skills206—~2.3kAutomated safety check: PassMIT
Migration Patternsbybren-llc/safe-agentic-workflow421—~1.2kAutomated safety check: NotesMIT
Database Migrationagulli/atlas-agents578—~702Automated safety check: PassMIT
Prisma 8 Contract-First ORMprisma/orm48k—~3.7kAutomated safety check: NotesApache-2.0
Database Migrationsaffaan-m/ECC274k4 repos~3kAutomated safety check: PassMIT
Database Migrationdavila7/claude-code-templates32k11 repos~2.8kAutomated safety check: PassMIT

Similar skills

  • Migration Patterns

    bybren-llc/safe-agentic-workflow

    Database migration creation with mandatory RLS policies and ARCHitect approval workflow.

    421 GitHub stars~1.2k tokensUpdated 2 mo ago
    DatabasesAuto-check: notes
  • Database Migration

    agulli/atlas-agents

    Safely run database schema migrations. An agent skill from agulli/atlas-agents.

    578 GitHub stars~702 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Official

    Routes Prisma 8 tasks such as contracts, migrations, queries and upgrades to the right reference files for projects on the contract-first @prisma/orm packages.

    48k GitHub stars~3.7k tokensUpdated yesterday
    DatabasesAuto-check: notes
  • Safe, reversible database migration patterns: forward-only production changes, expand-contract zero-downtime renames, concurrent indexes, batched backfills, and per-tool workflows for PostgreSQL…

    274k GitHub starsUsed in 4 repos~3k tokens
    DatabasesAuto-check passed
  • Database Migration

    davila7/claude-code-templates

    Master database schema and data migrations across ORMs (Sequelize, TypeORM, Prisma), including rollback strategies and zero-downtime deployments.

    32k GitHub starsUsed in 11 repos~2.8k tokens
    DatabasesAuto-check passed
  • Database Migration Patterns with RLS

    bybren-llc/safe-agentic-workflow

    Database migration creation with mandatory RLS policies and ARCHitect approval workflow. Use when creating migrations, adding tables with RLS, updating ORM…

    421 GitHub stars~1.3k tokensUpdated 2 mo ago
    DatabasesAuto-check passed

More from seb1n/awesome-ai-agent-skills

All 92 skills in this repo
  • Agent Red Teaming

    seb1n/awesome-ai-agent-skills

    Plan, execute, document, and retest authorized security assessments of AI agents and multi-agent workflows using safe adversarial cases, synthetic identities, canaries, and evidence-based findings.

    206 GitHub stars~2.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Eu AI Act Readiness

    seb1n/awesome-ai-agent-skills

    Build a preliminary, evidence-based EU AI Act readiness assessment across AI-system inventory, territorial scope, operator roles, prohibited-practice screening, risk classification, transparency…

    206 GitHub stars~3.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Human In The Loop

    seb1n/awesome-ai-agent-skills

    Design and verify auditable human oversight, approval gates, escalation paths, and safe state transitions for AI agent workflows.

    206 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • MCP Server Building

    seb1n/awesome-ai-agent-skills

    Design, implement, harden, and verify Model Context Protocol (MCP) servers with precise tool contracts, least-privilege authorization, safe transports, structured errors, and interoperability tests.

    206 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • PDF Processing

    seb1n/awesome-ai-agent-skills

    Inspect, extract, OCR, create, merge, split, reorder, rotate, annotate, fill, redact, compress, secure, and verify PDF documents while preserving source files and visual fidelity.

    206 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Skill Supply Chain Audit

    seb1n/awesome-ai-agent-skills

    Audit agent skills, plugins, prompts, manifests, scripts, dependencies, and bundled assets for provenance, prompt-injection, permission, execution, exfiltration, persistence, and update risk.

    206 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Categories

Questions about Database Migration

What does Database Migration do?

Create, execute, and roll back versioned database schema migrations using tools like Alembic, Prisma Migrate, Flyway, and Knex. Database Migration is an agent skill from seb1n/awesome-ai-agent-skills. Create, execute, and roll back versioned database schema migrations using tools like Alembic, Prisma Migrate, Flyway, and Knex.

When should I use Database Migration?

Database Migration fits situations like: the user requests database migration; provides relevant inputs for this workflow.

How do I install Database Migration in Claude Code?

Run `npx skills add seb1n/awesome-ai-agent-skills --skill database-migration -a claude-code`. Or copy the skill folder (database/database-migration in seb1n/awesome-ai-agent-skills) into .claude/skills/database-migration in your project. Claude Code loads it when a task matches its description.

How do I install Database Migration in Codex?

Run `npx skills add seb1n/awesome-ai-agent-skills --skill database-migration -a codex`. Or copy the skill folder (database/database-migration in seb1n/awesome-ai-agent-skills) into .agents/skills/database-migration in your project. Codex loads it when a task matches its description.

Can I use Database Migration in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add seb1n/awesome-ai-agent-skills --skill database-migration -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/database-migration, .gemini/skills/database-migration, .github/skills/database-migration and .opencode/skills/database-migration in your project.

What does Database Migration need to run?

Going by SKILL.md and its folder, Database Migration needs the command-line tools its instructions call (npx). Our summary lists: Python 3; Node.js.

Does Database Migration access the network?

SKILL.md contains no URLs. Its commands use npx, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Database Migration safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Database Migration use?

Database Migration is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Database Migration use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Database Migration?

Skills that share tags, products or a category with Database Migration: Migration Patterns (bybren-llc/safe-agentic-workflow, 421 stars), Database Migration (agulli/atlas-agents, 578 stars), Prisma 8 Contract-First ORM (prisma/orm, 48k stars) and Database Migrations (affaan-m/ECC, 274k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Database Migration?

seb1n (a GitHub user) maintains it in seb1n/awesome-ai-agent-skills, which has 206 GitHub stars. The repository holds 92 skills in this directory. The repository was last updated on August 9, 2026.

Source: seb1n/awesome-ai-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.