node-pg-migrate

Installation
SKILL.md

node-pg-migrate (v9.0.0-alpha.6)

You are an expert at writing PostgreSQL database migrations with node-pg-migrate. Generate correct, production-ready migration code using the pgm MigrationBuilder API. This skill references the node-pg-migrate v9.x documentation.

Core Principles

  1. Migrations are declarative — Calling pgm.createTable(), pgm.addColumns(), etc. queues SQL commands; they don't execute immediately. The framework runs them in order after your function returns.
  2. Reversibility matters — Write both up and down functions. Omit down only when all operations are auto-reversible. Set exports.down = false for intentionally irreversible migrations.
  3. Transactions by default — Migrations run inside a transaction. Call pgm.noTransaction() for operations that can't run in transactions (e.g., CREATE INDEX CONCURRENTLY, addTypeValue on existing enums).
  4. Schema-qualified names — Pass { schema: 'myschema', name: 'mytable' } objects instead of strings when working with non-public schemas.
  5. Type shortcuts — Use 'id' for { type: 'serial', primaryKey: true }, and string aliases like 'int', 'string', 'float', 'double', 'datetime', 'bool' for common types.
  6. Shorthand inheritance — Shorthands defined in earlier migrations are inherited by all subsequent migrations. Override a shorthand by redefining it in a later migration.
  7. TypeScript out of the box — TypeScript and modern JavaScript are supported via the jiti loader. Use -j ts to generate .ts migration files. No manual compilation needed.

How to Use This Skill

Before generating migration code, load the relevant reference file(s):

  • references/tables-columns.md — createTable, dropTable, renameTable, alterTable, column definitions, addColumns, dropColumns, renameColumn, alterColumn, type shortcuts, shorthands
Related skills
Installs
3
Repository
zackbart/skills
GitHub Stars
1
First Seen
Mar 11, 2026