Agent Skills
› NangoHQ/nango
› creating-database-migrations
creating-database-migrations
GitHub指导创建数据库迁移文件,包括定位目录、命名规范、风格对齐及外键策略。
Trigger Scenarios
需要创建新的数据库迁移文件
编辑现有的数据库迁移
Install
npx skills add NangoHQ/nango --skill creating-database-migrations -g -y
SKILL.md
Frontmatter
{
"name": "creating-database-migrations",
"description": "Use when adding or editing Nango database migrations - covers migration directory selection, timestamped .cjs naming, matching recent migration style, down migration decisions, and foreign key ON DELETE conventions."
}
Creating Database Migrations
Workflow
-
Identify the right migration directory.
- Main database migrations live in
packages/database/lib/migrations/. - Other services may have their own migration directories; use the directory for the service being changed.
- Main database migrations live in
-
Before writing a migration, read 2-3 recent migrations in the same directory and follow their style.
-
Name new main database migrations with the timestamped CommonJS format:
<YYYYMMDDHHMMSS>_<description>.cjsExample:
20260420120000_create_customer_keys.cjs -
Decide
exports.downexplicitly.- Ask the user whether rollback logic should be included or
exports.downshould be left empty. - If the user already specified rollback behavior, follow that direction.
- Ask the user whether rollback logic should be included or
-
Choose foreign key delete behavior from the relationship:
- Use
ON DELETE CASCADEfor ownership relationships where the child cannot exist without the parent. - Use
ON DELETE SET NULLfor optional references where the child should survive parent deletion. - Check existing migrations for the closest matching relationship before choosing.
- Use
Review Checklist
- Migration is in the correct service migration directory.
- Filename uses the timestamped
.cjsmigration format. - Style matches recent migrations in the same directory.
-
exports.downbehavior was confirmed or explicitly requested. - Foreign keys use
CASCADEfor ownership andSET NULLfor optional references.
Version History
- b75293e Current 2026-08-28 21:54


