db-migrations

Automate PostgreSQL schema migrations with Knex.js across environments.

1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/cr330326/AgentSkill --skill db-migrations-cr330326
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-migrations
Source: https://github.com/cr330326/AgentSkill/tree/main/validate/skill-generator-workspace/iteration-1/eval-4-db-migrations/without_skill/db-migrations
Command: npx skills add https://github.com/cr330326/AgentSkill --skill db-migrations-cr330326

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL database migration management with Knex.js. Create, modify, and rollback schema migrations including tables, columns, indexes, constraints, enums, and data transforms. Use when user asks to "create a migration", "add a column", "change schema", "alter table", "rollback migration", "create table", "add index", "rename column", "database migration", "knex migrate", or needs help with any PostgreSQL schema change in a Node.js/Knex project.

Core Features & Use Cases

  • Robust migration workflows with safe defaults and rollback support.
  • Templates and patterns for common schema changes (create table, add column, etc.).
  • Real-world guidance for production-grade migrations and risk mitigation.

Quick Start

Follow a step-by-step workflow: discover the migration setup, generate the migration file, verify it compiles and rollback is complete, and optionally run the migration.

Frequently Asked Questions about db-migrations

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

FAQPage Schema
How do I create reversible PostgreSQL schema migrations using Knex.js?

Reversible PostgreSQL schema migrations using Knex.js are generated as files with explicit up and down functions, ensuring every table, column, or index change includes a complete rollback path for safe execution.

What is the best way to rollback a database migration in production safely?

Safe production database migration rollbacks require writing idempotent down functions in your Knex.js scripts, allowing you to revert schema changes like altered tables or added indexes without causing data loss or downtime.

How do I add a column or create a table in a Node.js project with Knex?

Adding a column or creating a table in a Node.js project with Knex involves generating a migration file, defining the schema changes inside the up method, and verifying the script compiles before applying it to the database.

Does Knex support idempotent checks for database schema changes?

Knex supports idempotent checks for database schema changes by allowing you to conditionally execute operations, ensuring migrations like adding indexes or constraints only run if they do not already exist in the PostgreSQL database.

Why do my database migrations fail when altering tables in staging environments?

Database migrations altering tables in staging environments often fail due to non-idempotent scripts or missing rollback functions, which can be prevented by enforcing explicit migration names and verifying compilation before execution.

When do I need a database migration workflow for schema changes?

You need a database migration workflow for schema changes whenever you modify PostgreSQL structures like tables, columns, or enums in a Node.js application, ensuring updates are tracked, reversible, and safely applied across environments.