
Postgres database migration
Guides an agent through planning, testing and running PostgreSQL schema migrations safely
Postgres database migration is an open-source agent skill for databases. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.
- Scripts
- None
- Platforms
- Claude Code, Codex, Cursor
- GitHub stars
- 1.9K
- Last commit
- License
- Apache-2.0
- Listing updated
Similar skills
About Postgres database migration
This skill gives an agent a detailed playbook for changing PostgreSQL schemas on live databases. It includes a reference of which DDL operations take heavy locks and which are fast, along with safe patterns for adding, dropping and renaming columns, changing types, adding NOT NULL checks, foreign keys, indexes and primary keys using non-blocking steps.
The guide also covers operational safeguards: setting lock and statement timeouts, retry loops for lock acquisition, batched backfills, checking for invalid indexes after concurrent builds, and writing rollback plans that distinguish reversible from irreversible changes. Testing is centered on running the migration against a copy of the production database, either through a provider's fork feature or a dump and restore.
The skill is documentation-driven and contains no scripts. It refers to separate reference files for backfill strategies, validation queries and a complete end-to-end example. The examples are SQL and shell commands, so the agent needs access to a PostgreSQL instance and a way to run statements against it.
When your agent uses it
Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. **Trigger when user asks to:** - Test a schema migration before applying it to production - Add, remove, or rename columns safely on a live table - Change a column's data type without downtime - Add or drop indexes, constraints, or foreign keys on large tables - Understand which ALTER TABLE operations lock the table - Roll back a failed migration - Plan a zero-downtime migration strategy - Fork a database to test a migration safely **Keywords:** migration, schema change, ALTER TABLE, add column, drop column, rename column, change type, zero downtime, lock, AccessExclusiveLock, concurrent index, forking, rollback, backfill, deploy Covers: lock-level reference for every common DDL operation, safe migration patterns, fork-based testing, zero-downtime column changes, index creation, constraint addition, backfill strategies, pre/post-migration validation, an
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 4 files (32 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the pg plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add timescale/pg-aiguide
/plugin install pg@aiguideOr copy only this skill to ~/.claude/skills/postgres-database-migration:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/postgres-database-migration &&
cp -R "$tmp/skills/postgres-database-migration" ~/.claude/skills/postgres-database-migration &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/postgres-database-migration inside it instead.
Copy the skill folder to ~/.agents/skills/postgres-database-migration to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/postgres-database-migration &&
cp -R "$tmp/skills/postgres-database-migration" ~/.agents/skills/postgres-database-migration &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/postgres-database-migration inside it instead.
Copy the skill folder to ~/.cursor/skills/postgres-database-migration to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/postgres-database-migration &&
cp -R "$tmp/skills/postgres-database-migration" ~/.cursor/skills/postgres-database-migration &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/postgres-database-migration inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/timescale/pg-aiguide.git --path skills/postgres-database-migrationOr copy the folder to ~/.gemini/skills/postgres-database-migration yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/postgres-database-migration:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/postgres-database-migration &&
cp -R "$tmp/skills/postgres-database-migration" ~/.copilot/skills/postgres-database-migration &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/postgres-database-migration inside it instead.
Get the folder:
git clone --depth 1 https://github.com/timescale/pg-aiguide.gitThen copy pg-aiguide/skills/postgres-database-migration into your agent's skills folder as postgres-database-migration. Agents that support SKILL.md read one folder per skill.
What it does
- DDL lock reference
- Lists common ALTER TABLE and index operations with the lock level each acquires and whether it blocks traffic.
- Non-blocking column changes
- Patterns for adding, renaming and retyping columns without a long table rewrite or downtime.
- Safe constraint and index creation
- Two-step NOT VALID and CONCURRENTLY approaches for foreign keys, NOT NULL, unique constraints and indexes.
- Timeout and retry guidance
- Explains lock_timeout and statement_timeout choices and a retry loop for DDL that waits on busy tables.
- Fork-based testing
- Steps for trying a migration on a database copy before applying it to production.
- Rollback planning
- Separates reversible operations from those that need a backup or fork to undo.
Good for
- Add a column to a large production table without locking out writes
- Change a column type on a live table with minimal downtime
- Create an index on a busy table without blocking inserts
- Add a foreign key to an existing table safely
- Plan a rollback for a failed schema change
- Test a migration on a copy of the database before applying it
Postgres database migration FAQ
What does Postgres database migration need to work?
It assumes access to a PostgreSQL database and the ability to run SQL statements. Fork-based testing requires a provider that supports database forking, such as Neon, while dump and restore works with any PostgreSQL instance.
Does Postgres database migration change my database on its own?
No. It is a set of instructions and SQL patterns the agent follows when a task calls for a schema migration. Any statements run against your database happen through the agent's normal execution.
Which tasks trigger Postgres database migration?
Requests about testing schema migrations, adding, removing or renaming columns on live tables, changing column types, adding indexes or constraints on large tables, understanding ALTER TABLE locks, rolling back failed migrations, and forking a database to test a change.
Does Postgres database migration include scripts?
No. The skill folder contains instructions and reference files only, with no bundled scripts.
How do I install Postgres database migration in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/postgres-database-migration to use it in all your projects, or to .claude/skills/postgres-database-migration in one project. Or install the pg plugin, which includes it: /plugin marketplace add timescale/pg-aiguide, then /plugin install pg@aiguide.
Does Postgres database migration 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 Postgres database migration?
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 Postgres database migration?
The closest alternatives to Postgres database migration are Database migrations, Database migrations, Design postgres tables, Postgres and Db change management.
Where this comes from
- Description: from the skill's own SKILL.md.
More from timescale/pg-aiguide

Guides an agent in designing PostGIS spatial tables, types, SRIDs and indexes
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through PostgreSQL table design, types, constraints and indexing
- Open source
- 1.9K GitHub stars
- Databases

Scores existing PostgreSQL tables to find which should become TimescaleDB hypertables
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through converting PostgreSQL tables into TimescaleDB hypertables safely
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through pgvector setup, HNSW indexing and tuning for semantic search
- Open source
- 1.9K GitHub stars
- Databases

Guides an agent through PostgreSQL schema design, indexing, search, TimescaleDB
- Open source
- 1.9K GitHub stars
- Databases



