db-migration

Generate reversible PostgreSQL and PostGIS migrations with rollback plans.

2|1|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/Kaakati/sdh-claude-skills --skill db-migration-kaakati
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-migration
Source: https://github.com/Kaakati/sdh-claude-skills/tree/main/.claude/skills/db-migration
Command: npx skills add https://github.com/Kaakati/sdh-claude-skills --skill db-migration-kaakati

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of designing and implementing safe, reversible database migrations for PostgreSQL, ensuring data integrity and minimizing downtime.

Core Features & Use Cases

  • Schema Design: Assists in designing PostgreSQL and PostGIS schemas, including spatial column considerations.
  • Migration Creation: Generates safe, reversible SQL migrations with rollback plans.
  • Zero-Downtime Deployment: Implements patterns like "expand and contract" for schema changes without service interruption.
  • Index Strategy: Provides guidance on creating effective indexes for performance.
  • Use Case: When asked to "create a migration to add a new location column with PostGIS geometry type to the events table," this skill will generate the necessary SQL for adding the column, backfilling data, and ensuring it's done without locking the table.

Quick Start

Use the db-migration skill to design a PostgreSQL migration to add a status column to the orders table.

Frequently Asked Questions about db-migration

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

FAQPage Schema
How do I create a zero-downtime PostgreSQL migration when adding a new column?

To create a zero-downtime PostgreSQL migration, use the expand and contract pattern to add columns without locking the table. This approach generates reversible SQL that backfills data while maintaining service availability.

What is the best way to handle PostGIS spatial column schema changes in a database migration?

Handling PostGIS spatial column schema changes requires generating safe migrations that account for geometry types and spatial indexing. The process ensures data integrity by validating spatial constraints and planning rollbacks for complex type modifications.

How does the expand and contract pattern work for reversible database migrations?

The expand and contract pattern works by expanding the schema first with new columns or constraints, then migrating data, and finally contracting by removing old structures. This enables zero-downtime deployments while maintaining full rollback capability.

Can I rename a column in PostgreSQL without causing downtime during the migration?

Renaming a column in PostgreSQL without downtime requires a phased migration approach using expand and contract patterns. You add the new column, backfill data, update application queries, and eventually drop the old column safely.

How do I plan a rollback strategy for complex PostgreSQL type changes and constraint additions?

Planning a rollback strategy for PostgreSQL type changes involves generating reversible SQL migrations that document each step's inverse operation. This includes index strategy adjustments and data conversion scripts to restore the previous schema state.