database-migrations

Create and apply versioned PostgreSQL schema migrations with SQL up/down scripts.

3|Updated Jan 22, 2024
One-click install
npx skills add https://github.com/castlemilk/shorted.com.au --skill database-migrations-castlemilk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/castlemilk/shorted.com.au/tree/main/.claude/skills/database-migrations
Command: npx skills add https://github.com/castlemilk/shorted.com.au --skill database-migrations-castlemilk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Create and manage PostgreSQL database migrations. Use when adding tables, columns, indexes, or modifying the database schema.

Core Features & Use Cases

  • Provides a structured workflow to generate, apply, and rollback migrations
  • Stores forward and backward SQL in services/migrations with sequential versioning
  • Supports common patterns such as adding tables, columns, and indexes, with version tracking and safe rollbacks

Quick Start

Create a new migration by running the make migrate-create NAME=add_users_table inside the services directory.

Frequently Asked Questions about database-migrations

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

FAQPage Schema
How do I create and apply PostgreSQL schema migrations?

PostgreSQL schema migrations are created using the make migrate-create command and applied via Make targets. This generates sequential SQL scripts in the services/migrations directory and tracks them using a schema_migrations table for safe rollbacks.

What is the best way to add columns or indexes to a PostgreSQL database safely?

The best way to add columns or indexes safely is using versioned migration scripts. This Skill automates PostgreSQL schema evolution by generating sequential up/down SQL files, ensuring changes are tracked and can be rolled back if issues arise.

Does this database migration approach support production environments?

Yes, this database migration approach supports production environments. It automates PostgreSQL schema evolution for both development and production workflows, using a schema_migrations tracking mechanism to ensure safe rollbacks.

How do I rollback a schema change in PostgreSQL?

To rollback a schema change in PostgreSQL, this Skill uses down migration scripts stored in the services/migrations directory. The schema_migrations tracking mechanism ensures that applied changes can be safely reversed.

Do I need Make to run PostgreSQL migrations?

Yes, you need Make to run these PostgreSQL migrations. The workflow requires Make targets to generate, apply, and rollback migrations, specifically executing commands like make migrate-create within the services directory.

Why use versioned migration scripts for schema evolution?

Versioned migration scripts provide structured schema evolution by storing forward and backward SQL sequentially. This ensures database changes are tracked consistently and allows safe rollbacks when modifying PostgreSQL tables, columns, or indexes.