postgres-migrations

Plan safe PostgreSQL schema migrations with idempotent scripts and batched updates.

8|2|Updated Jan 15, 2026
One-click install
npx skills add https://github.com/bradtaylorsf/alphaagent-team --skill postgres-migrations-bradtaylorsf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-migrations
Source: https://github.com/bradtaylorsf/alphaagent-team/tree/main/plugins/aai-stack-postgres/skills/postgres-migrations
Command: npx skills add https://github.com/bradtaylorsf/alphaagent-team --skill postgres-migrations-bradtaylorsf

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexities and risks associated with modifying PostgreSQL database schemas in production environments, ensuring data integrity and minimizing downtime.

Core Features & Use Cases

  • Safe Schema Changes: Provides patterns for adding, removing, or renaming columns and constraints with minimal locking.
  • Idempotent Migrations: Offers strategies for creating migration scripts that can be run multiple times without adverse effects.
  • Use Case: Safely add a new email column to your users table, backfill existing data, and add a NOT NULL constraint without locking the table for an extended period.

Quick Start

Use the postgres-migrations skill to safely add a nullable 'phone' column to the 'users' table.

Frequently Asked Questions about postgres-migrations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a NOT NULL column to a PostgreSQL table without locking it?

To add a NOT NULL column to a PostgreSQL table without extended locking, you should first add the column as nullable, backfill the existing data, and then apply the constraint. This migration pattern ensures data integrity while minimizing downtime.

What is the best way to write idempotent SQL migration scripts?

Idempotent SQL migration scripts are written using patterns that allow them to execute multiple times without adverse effects. Strategies include checking for existing schema objects or columns before applying structural changes to the PostgreSQL database.

Can I rename columns or constraints safely in a PostgreSQL production database?

Yes, you can rename columns and constraints safely in a PostgreSQL production database by applying specific migration patterns. These strategies minimize locking and ensure data integrity during the schema transition.

How does transactional DDL help with PostgreSQL schema migrations?

Transactional DDL helps with PostgreSQL schema migrations by wrapping structural changes in a transaction, ensuring data integrity. If a migration script fails midway, the transaction rolls back all schema modifications, preventing partial updates.

How do I backfill large datasets during a PostgreSQL schema migration?

You backfill large datasets during a PostgreSQL schema migration by using batched updates. This pattern processes data in smaller chunks to minimize lock contention and reduce the impact on production database performance.

Why do I need to monitor locks during PostgreSQL schema changes?

You need to monitor locks during PostgreSQL schema changes to prevent long-running queries from blocking production traffic. Lock monitoring identifies potential contention, ensuring migration patterns execute without causing extended downtime.