postgres-database-migration

postgres-database-migration is a skill for Cursor from timescale/pg-aiguide. It costs 220 tokens per session (5,620 once invoked), scanned A, original, Apache-2.0.

A guide to changing the structure of a PostgreSQL database, such as adding, removing, or changing table columns.

In plain words
What is it for?
Use it to plan, test, and safely apply schema changes to live or shared PostgreSQL databases.
Why use it?
It helps reveal whether a database change could lock a busy table, fail on existing data, or cause problems in production.

Skill for Cursor

Written for Cursor: shipped in a Cursor plugin.

Part of the pg-aiguide plugin — 11 skills, 1 MCP server shipped together

Good fit Use it to plan, test, and safely apply schema changes to live or shared PostgreSQL databases.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/timescale/pg-aiguide/postgres-database-migration
About the project

pg-aiguide is a knowledge and tooling project that gives AI coding assistants version-aware PostgreSQL documentation and curated database practices. Developers use it through agent skills, an MCP server, or a Claude Code plugin to help coding tools generate better PostgreSQL code. The catalogue entries are its skills, instructions, MCP integration, and rule.

timescale/pg-aiguide · 1,870 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add timescale/pg-aiguide --skill postgres-database-migration
Clone the repo
git clone --depth 1 https://github.com/timescale/pg-aiguide

Made for: Cursor.

Or install pg-aiguide, the plugin that ships this one along with the rest of its 11 skills, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for postgres-database-migration

README.md
[![agentmods](https://agentmods.dev/badge/skills/timescale/pg-aiguide/postgres-database-migration/github.svg)](https://agentmods.dev/skills/timescale/pg-aiguide/postgres-database-migration)
Your own site
<a href="https://agentmods.dev/skills/timescale/pg-aiguide/postgres-database-migration"><img src="https://agentmods.dev/badge/skills/timescale/pg-aiguide/postgres-database-migration/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for postgres-database-migration

Your own site · 80×15
<a href="https://agentmods.dev/skills/timescale/pg-aiguide/postgres-database-migration"><img src="https://agentmods.dev/badge/skills/timescale/pg-aiguide/postgres-database-migration.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 220 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,620 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Memory Poisoning · line 381
    Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.
    Fix: Protect agent memory and state from modification by untrusted content. Use read-only memory for critical instructions and validate all state changes.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00220 $0.05620
Opus 5.5 $0.00088 $0.02248
Sonnet 5.5 $0.00044 $0.01124
Haiku 4.5 $0.00022 $0.00562

Measured 1mo ago against content hash b37d01fa733e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

postgres-database-migration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/postgres-database-migration/SKILL.md · 487 lines

How it starts

The opening of the file, as written. The whole thing — 487 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PostgreSQL Database Migrations

A schema migration that works on an empty dev database can fail, lock, or corrupt data on a production table with millions of rows. This guide covers how to assess risk, test against real data, and execute migrations safely.

DDL Lock Reference

Every schema change acquires a lock. The critical question is: does it block reads and writes, and for how long?

Fast, Non-Blocking Operations

These complete in milliseconds regardless of table size. They only hold a brief AccessExclusiveLock for the catalog update, not for data rewriting.

Operation Lock Level Notes
ADD COLUMN (nullable, no default) AccessExclusiveLock (brief) Fast. No table rewrite. Metadata-only change.
ADD COLUMN ... DEFAULT x (PG 11+) AccessExclusiveLock (brief) Fast. Non-volatile defaults stored in catalog, not backfilled.
DROP COLUMN AccessExclusiveLock (brief) Fast. Column marked invisible; space reclaimed by VACUUM over time.
SET DEFAULT / DROP DEFAULT AccessExclusiveLock (brief) Metadata change only. Does not touch existing rows.
CREATE INDEX CONCURRENTLY ShareUpdateExclusiveLock Non-blocking. Allows reads and writes during build. Slower than regular index creation.
DROP INDEX CONCURRENTLY ShareUpdateExclusiveLock Non-blocking. Waits for queries using the index to finish, then drops. No table-level exclusive lock.
RENAME COLUMN AccessExclusiveLock (brief) Metadata change only. Fast.
RENAME TABLE AccessExclusiveLock (brief) Metadata change only. Fast.
ADD CONSTRAINT ... NOT VALID ShareUpdateExclusiveLock Adds constraint for new rows only. Does not scan existing data.
VALIDATE CONSTRAINT ShareUpdateExclusiveLock Scans existing rows but allows concurrent reads and writes.
CREATE/DROP TRIGGER ShareRowExclusiveLock Brief catalog update.

Slow or Blocking Operations

Read the full file on GitHub · 487 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · -2 tokens per session b37d01fa733e
  2. 1mo ago First seen · 487 lines · 222 tokens per session scan A 19cb18c5a55d

Subscribe to this mod's changes

postgres-database-migration is a skill published in the GitHub repository timescale/pg-aiguide (1,870 stars, last pushed 2d ago), licensed Apache-2.0. It adds 220 tokens to every session and 5,620 once invoked, about $0.0009 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories