# Database migrations

> Database migrations is an open-source agent skill for databases. Guides an agent through safe, reversible database schema and data migrations. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/smartworldarafath/REA_Skill/tree/main/.agents/skills/database-migrations
- **Repository:** https://github.com/smartworldarafath/rea_skill
- **GitHub stars:** 66
- **License:** MIT
- **Skill name:** database-migrations
- **Collection:** https://github.com/smartworldarafath/REA_Skill
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-12-01

## About

This skill gives an agent a set of production-safe rules for changing database schemas and data. It stresses forward-only migrations in production, keeping schema and data changes in separate migrations, and building indexes concurrently on large tables. It also covers expand-contract sequencing for zero-downtime renames, including dual writes, batched backfills, parity checks before read cutover, and a deferred contract step.

The skill includes concrete SQL and tool-specific examples. PostgreSQL patterns cover column additions and their lock behavior, concurrent index creation, and batched updates. Per-tool workflows are included for Prisma, Drizzle, Kysely, Django and golang-migrate, with commands for generating, applying and rolling back migrations. Two self-checking PostgreSQL example scripts are referenced for testing column additions and renames against psql.

The agent needs a PostgreSQL database for most patterns, and the relevant migration tool installed for the framework in use. Examples are written in SQL, TypeScript, Python and shell commands.

## When your agent uses it

> Safe, reversible database migration patterns: forward-only production changes, expand-contract zero-downtime renames, concurrent indexes, batched backfills, and per-tool workflows for PostgreSQL, Prisma, Drizzle, Kysely, Django, and golang-migrate. Use when writing a schema or data migration, adding a column or index to a large table, planning a rollback, or preparing a zero-downtime deploy.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/smartworldarafath/REA_Skill/tree/HEAD/.agents/skills/database-migrations)
- [License: MIT](https://github.com/smartworldarafath/REA_Skill/tree/HEAD/.agents/skills/database-migrations)

## Features

- **Forward-only migration rules:** Principles for keeping production changes immutable and rolling back through new forward migrations.
- **Zero-downtime rename sequence:** An expand-contract procedure with dual writes, batched backfill and parity validation before cutover.
- **Safe PostgreSQL column changes:** Guidance on lock levels, non-volatile defaults and NOT NULL pitfalls when altering populated tables.
- **Concurrent index creation:** Building indexes without blocking writes and handling the transaction restriction on CONCURRENTLY.
- **Batched data backfills:** Committing large updates in bounded ranges to avoid long locks and support retries.
- **Per-tool migration workflows:** Commands and file patterns for Prisma, Drizzle, Kysely, Django and golang-migrate.

## Good for

- Add a column to a large PostgreSQL table without locking writes
- Rename a production column with zero downtime
- Create an index on a big table concurrently
- Backfill a new column in batches without long transactions
- Write a Django data migration that fills in a field
- Set up a golang-migrate up and down migration pair

## Install

### Claude Code

This skill ships in the `rea-skills` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add smartworldarafath/REA_Skill
/plugin install rea-skills@smartworldarafath
```

Or copy only this skill to `~/.claude/skills/database-migrations`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/database-migrations &&
cp -R "$tmp/.agents/skills/database-migrations" ~/.claude/skills/database-migrations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/database-migrations` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/database-migrations` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/database-migrations &&
cp -R "$tmp/.agents/skills/database-migrations" ~/.agents/skills/database-migrations &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/database-migrations` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/database-migrations` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/database-migrations &&
cp -R "$tmp/.agents/skills/database-migrations" ~/.cursor/skills/database-migrations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/database-migrations` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/smartworldarafath/REA_Skill.git --path .agents/skills/database-migrations
```

Or copy the folder to `~/.gemini/skills/database-migrations` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/database-migrations`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/database-migrations &&
cp -R "$tmp/.agents/skills/database-migrations" ~/.copilot/skills/database-migrations &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/database-migrations` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/smartworldarafath/REA_Skill.git
```

Then copy `REA_Skill/.agents/skills/database-migrations` into your agent's skills folder as `database-migrations`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What tools does Database migrations cover?

It covers PostgreSQL patterns and workflows for Prisma, Drizzle, Kysely, Django and golang-migrate.

### Does Database migrations run any scripts?

It references two self-checking PostgreSQL SQL examples that are run with psql, but the skill itself ships no scripts.

### Can I roll back a production migration?

The skill advises against editing deployed migrations and recommends rolling back with a new forward migration, planning for the rollback window in expand-contract changes.

### Why are indexes created with CONCURRENTLY?

Because a plain CREATE INDEX blocks writes on large tables, while CONCURRENTLY allows writes during the build, though it cannot run inside a transaction block.

### How do I install Database migrations in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/database-migrations to use it in all your projects, or to .claude/skills/database-migrations in one project. Or install the rea-skills plugin, which includes it: /plugin marketplace add smartworldarafath/REA_Skill, then /plugin install rea-skills@smartworldarafath.

### Does Database migrations run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Database migrations?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Database migrations?

The closest alternatives to Database migrations are Db change management, Reviewing oracle to postgres migration, Migrating oracle to postgres data access code, Planning oracle to postgres migration integration testing and Migrating oracle to postgres stored procedures.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Db change management](https://ai-powered.com/skills/db-change-management): Db change management is an open-source agent skill for databases.
- [Reviewing oracle to postgres migration](https://ai-powered.com/skills/reviewing-oracle-to-postgres-migration): Reviewing oracle to postgres migration is an open-source agent skill for databases.
- [Migrating oracle to postgres data access code](https://ai-powered.com/skills/migrating-oracle-to-postgres-data-access-code): Migrating oracle to postgres data access code is an open-source agent skill for databases.
- [Planning oracle to postgres migration integration testing](https://ai-powered.com/skills/planning-oracle-to-postgres-migration-integration-testing): Planning oracle to postgres migration integration testing is an open-source agent skill for databases.
- [Migrating oracle to postgres stored procedures](https://ai-powered.com/skills/migrating-oracle-to-postgres-stored-procedures): Migrating oracle to postgres stored procedures is an open-source agent skill for databases.
- [PostgreSQL optimization](https://ai-powered.com/skills/postgresql-optimization): PostgreSQL optimization is an open-source agent skill for databases.
- [Data archaeology](https://ai-powered.com/skills/data-archaeology): Data archaeology is an open-source agent skill for databases.
- [Bigquery migration validator](https://ai-powered.com/skills/bigquery-migration-validator): Bigquery migration validator is an open-source agent skill for databases.

---
Source: https://ai-powered.com/skills/database-migrations
