add-a-migration

Creates, applies, and rolls back timestamped SQL database migrations with paired down files.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/zhiyuan-zhang0206/Ava --skill add-a-migration-zhiyuan-zhang0206
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: add-a-migration
Source: https://github.com/zhiyuan-zhang0206/Ava/tree/main/.agents/skills/add-a-migration
Command: npx skills add https://github.com/zhiyuan-zhang0206/Ava --skill add-a-migration-zhiyuan-zhang0206

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database schema changes often break production because migrations are applied inconsistently, lack rollback paths, or drift from the baseline schema. This Skill enforces a disciplined migration workflow so every schema change is reversible, linted, and verified against the baseline. ## Core Features & Use Cases - Timestamped migration authoring: Creates YYYYMMDDTHHMMSS_<kebab-name>.sql files with mandatory paired .down.sql rollback files, keeping the baseline as the rollback floor. - Baseline synchronization: Keeps db/schema.sql current so a fresh database and a fully migrated database converge to the same schema. - Lint and smoke testing: Runs scripts/lint_migrations.py for filename, pairing, and uniqueness checks, plus scripts/test_migrations_apply.sh to verify triggers and functions actually fire on a fresh database. - Use Case: When renaming a column referenced by a trigger function, the Skill guides you to write the up/down migration pair, sync the baseline, and add an exercise line to the smoke test so PL/pgSQL body bugs are caught before production. ## Quick Start Ask the agent to add a new database migration for your schema change, including the paired down migration and an updated db/schema.sql baseline.

Frequently Asked Questions about add-a-migration

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

FAQPage Schema
How do I add a new database migration with a rollback file?▼

Write a SQL file named with a UTC timestamp prefix like YYYYMMDDTHHMMSS_kebab-name.sql, then write the paired .down.sql file that reverses it. Also sync the change into db/schema.sql so the baseline stays current.

How are pending migrations applied to the database?▼

Pending migrations run automatically as an early step of the service start command, after Postgres is up and before the schema-current assertion. Production upgrades go through the cluster update CLI, which ends in a fresh start that migrates.

Why do migration trigger bugs pass lint but fail in production?▼

CREATE OR REPLACE FUNCTION does not validate PL/pgSQL column references at apply time, so body bugs only surface when the trigger fires. The smoke test script exercises triggers on a fresh database to catch these errors before release.

Does the migration linter check for filename collisions across branches?▼

No, there is no continuity or cross-branch collision check because timestamp-based names are collision-free by construction. The linter verifies timestamp format, name uniqueness, up/down pairing, and baseline sentinel stamping.

When should I use expand-contract for schema changes?▼

Use expand-contract for lossy operations like column renames or type changes, where you add the new structure first, migrate data, then remove the old structure. This keeps every migration reversible above the baseline rollback floor.