postgres-database-migration

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 Claude CodeCodex

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.

agentmods
npx agentmods add skills/timescale/pg-aiguide/postgres-database-migration
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: Claude Code, Codex.

Per session 222 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,633 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00222 $0.05633
Opus 5 $0.00111 $0.02816
Sonnet 5 $0.00044 $0.01127
Haiku 4.5 $0.00022 $0.00563

Measured yesterday against content hash 19cb18c5a55d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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. yesterday 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,825 stars, last pushed 5d ago), licensed Apache-2.0. It adds 222 tokens to every session and 5,633 once invoked, about $0.0011 per session on Opus 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

implement-factory

Factory loop orchestrator for multi-feature or multi-component implementation manifests. Use for high-complexity work with parallel-eligible workstreams and holdout-scenario evaluation.

rsmdt/the-startup · 37 tokens

analyze

Deep-dive codebase analysis that explains how things actually work — business rules, architecture patterns, auth flows, data models, integrations, and performance hotspots. Use whenever the user asks "how does X work", "map the Y flow", "what are the business rules for Z", "trace the auth path", "explore the codebase…

rsmdt/the-startup · 118 tokens

debug

Systematically diagnose and resolve bugs through conversational investigation and root cause analysis.

rsmdt/the-startup · 15 tokens

specify-factory

Decompose a multi-feature or multi-component specification into factory-consumable artifacts. Use this for high-complexity work — multiple features, three or more components, or parallel-eligible workstreams.

rsmdt/the-startup · 45 tokens

specify-solution

Create and validate solution design documents (SDD). Use when designing architecture, defining interfaces, documenting technical decisions, analyzing system components, or working on solution.md files in .start/specs/.

rsmdt/the-startup · 43 tokens

brainstorm

You MUST use this before any creative work — creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements, and design before implementation.

rsmdt/the-startup · 37 tokens