flyway-migrations

Generates safe, zero-downtime Flyway SQL migrations for PostgreSQL databases.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/balajirags/aifsd-kit --skill flyway-migrations-balajirags
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flyway-migrations
Source: https://github.com/balajirags/aifsd-kit/tree/main/docs/skills/flyway-migrations
Command: npx skills add https://github.com/balajirags/aifsd-kit --skill flyway-migrations-balajirags

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing database migrations that avoid table locks, failed deployments, and downtime is error-prone, especially when renaming columns, adding constraints, or backfilling data on live PostgreSQL systems. ## Core Features & Use Cases - Versioned & Repeatable Migrations: Enforces naming conventions like VyyyyMMddHHmm__title.sql and R__object.sql with checksum markers. - Expand/Contract Patterns: Guides zero-downtime schema changes using shadow columns, batched backfills, and deferred contract phases. - Lock-Safe Constraints & Indexes: Adds foreign keys with NOT VALID plus VALIDATE CONSTRAINT and creates indexes CONCURRENTLY outside transactions. - Use Case: When renaming a column on a production table, generate an expand migration that adds the new column, backfills it in idempotent batches, and a later contract migration that drops the old column. ## Quick Start Ask the AI to write a Flyway migration that adds a NOT NULL column with a default to an existing PostgreSQL table without downtime.

Frequently Asked Questions about flyway-migrations

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

FAQPage Schema
How do I write a zero-downtime Flyway migration in PostgreSQL?

Use the expand/contract pattern: first add new nullable columns or tables, backfill data in small batches, switch the application to the new structure, then drop old objects in a separate later migration. Never drop or rename columns used by running code in the same deploy.

How to add a foreign key without locking a PostgreSQL table?

Add the constraint with NOT VALID, which skips scanning existing rows, then run VALIDATE CONSTRAINT in a separate step. This avoids long table scans and exclusive locks on large tables.

What naming convention should Flyway migration files use?

Versioned migrations use VyyyyMMddHHmm__short_kebab_title.sql with a UTC timestamp for ordering, one change per file. Repeatable migrations for views and functions use R__object.sql with a checksum marker.

Can I create an index concurrently inside a Flyway migration?

Yes, use CREATE INDEX CONCURRENTLY, but it cannot run inside a transaction. Place it in a separate migration configured as non-transactional so it does not block reads and writes on the table.

How do I backfill data idempotently in a migration?

Use primary key pagination with small batches of around 5,000 rows, updating only rows where the target column IS NULL so reruns are safe. Add pg_sleep between batches to reduce load on the production database.