creating-database-migrations

Creates timestamped CommonJS database migrations following Nango repository conventions.

11.7k|1.3k|Updated Apr 9, 2020
One-click install
npx skills add https://github.com/NangoHQ/nango --skill creating-database-migrations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: creating-database-migrations
Source: https://github.com/NangoHQ/nango/tree/main/.agents/skills/creating-database-migrations
Command: npx skills add https://github.com/NangoHQ/nango --skill creating-database-migrations

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing database migrations in the Nango codebase requires following specific conventions: choosing the correct migration directory, using timestamped .cjs filenames, matching existing migration style, and deciding rollback and foreign key delete behavior. This Skill guides the AI through each of those decisions so migrations stay consistent with the repository.

Core Features & Use Cases

  • Directory Selection: Identifies the correct migration directory, such as packages/database/lib/migrations/ for the main database or service-specific directories.
  • Naming & Style Conventions: Enforces the <YYYYMMDDHHMMSS>_<description>.cjs filename format and instructs reading recent migrations to match their style.
  • Rollback & Foreign Key Decisions: Prompts for explicit exports.down behavior and applies ON DELETE CASCADE for ownership relationships versus ON DELETE SET NULL for optional references.
  • Use Case: When adding a new customer_keys table to the Nango database, the Skill produces a properly named migration file like 20260420120000_create_customer_keys.cjs with confirmed rollback logic and correct foreign key constraints.

Quick Start

Create a new Nango database migration that adds a customer_keys table with a foreign key to the accounts table.

Frequently Asked Questions about creating-database-migrations

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

FAQPage Schema
How do I create a database migration in the Nango repository?

Place the migration in the correct directory, typically packages/database/lib/migrations/ for the main database. Name it with the timestamped format <YYYYMMDDHHMMSS>_<description>.cjs and match the style of 2-3 recent migrations in the same directory.

What naming format do Nango database migrations use?

Main database migrations use a timestamped CommonJS format: <YYYYMMDDHHMMSS>_<description>.cjs, for example 20260420120000_create_customer_keys.cjs. The timestamp prefix keeps migrations ordered chronologically.

Should a migration include a down migration for rollback?

The exports.down behavior must be decided explicitly for each migration. Either include rollback logic or leave exports.down empty, but confirm the choice with the user or follow the rollback behavior they already specified.

When should I use ON DELETE CASCADE vs SET NULL in migrations?

Use ON DELETE CASCADE for ownership relationships where the child row cannot exist without the parent. Use ON DELETE SET NULL for optional references where the child should survive parent deletion. Check existing migrations for the closest matching relationship first.

Where do migrations live for services other than the main database?

Other services in the Nango monorepo may have their own migration directories. Always use the migration directory belonging to the service being changed rather than the main database directory.