add-migration

A guide for creating database migrations in a Sequelize and PostgreSQL project. A migration is a versioned change that updates the real database, such as adding a table, column, index, or constraint.

In plain words
What is it for?
Planning, generating, naming, applying, and rolling back schema changes while updating related models and test fixtures.
Why use it?
It prevents the application’s models and the real development or production database from getting out of sync.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hackbyrd/orbital-express/add-migration
Any agent
npx skills add Hackbyrd/orbital-express --skill add-migration
Clone the repo
git clone --depth 1 https://github.com/Hackbyrd/orbital-express

Made for: Claude Code, Codex.

Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,192 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00065 $0.01192
Opus 5 $0.00032 $0.00596
Sonnet 5 $0.00013 $0.00238
Haiku 4.5 $0.00006 $0.00119

Measured 3d ago against content hash f287cfe0ab48, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

add-migration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/add-migration/SKILL.md · 44 lines

How it starts

The opening of the file, as written. The whole thing — 44 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Write a migration

Migrations are the source of truth for the real database (dev/prod). The test DB is built from the models via sync, so when you add a column also add it to the model. Read README "Migrations" + "Database Conventions".

Before generating or editing, plan the schema, constraints, indexes, backfill, rollback, model changes, and fixture impact and get sign-off. For feature work, confirm the complete feature folder with yarn repair <Feature> --dry-run, then yarn repair <Feature>; repair never overwrites.

Filename convention (critical — it documents the change)

  • New table: <timestamp>-create-<Model>-model.js (Model singular PascalCase)
  • Alter table: <timestamp>-add-cols-<colA>-and-<colB>-to-<TablePlural>-tbl.js
  • Add index: <timestamp>-add-index-<colA>_<colB>-to-<TablePlural>-tbl.js

Generate the file, then fill it. Two documented ways (both produce a timestamped file you then rename to the convention above):

  • yarn model — for a NEW table; yarn migration — for ALTERing a table. Both create a generically-named file in migrations/rename it to the convention.
  • Or call the CLI directly with the right name (no rename needed):
    ./node_modules/.bin/sequelize migration:create --name create-<Model>-model
    ./node_modules/.bin/sequelize migration:create --name add-cols-<col>-to-<TablePlural>-tbl
    

Rules

  • Wrap up and down in queryInterface.sequelize.transaction(async t => { ... }, { transaction: t }) on every call.
  • Never delete columns/tables or rename in place (rollback safety). To rename: add new column, copy data, drop the old one much later. We don't auto-destroy data.
  • IDs: DataTypes.UUID with no DB-level default (the model's defaultValue: () => uuidv7() always provides the ID before insert). FK column types must match the referenced PK type.
  • Named indexes, {Table}_{col}_{idx|unique}, matching the model's indexes array exactly. {Table} is the exact explicit static PascalCase plural tableName, including irregular plurals—not naive <Feature>s. addIndex(table, [cols], { name, unique, transaction: t }).
  • Foreign keys: references: { model, key }, explicit onDelete/onUpdate. For self-referencing or composite FKs use addConstraint(table, { fields, type:'foreign key', name, references:{ table, field }, onDelete, onUpdate, transaction: t }).
  • Flattened ownership: when data is nested, carry every ancestor's id onto the descendant — not just the immediate parent, but the parent's parent, on up to the top-level owner (e.g. userId). It looks redundant on purpose: it flattens the hierarchy so you can query "all X for any ancestor" (and scope security to userId) as a single indexed where with no joins. The duplication can't drift because a composite FK enforces it (parent needs a UNIQUE (id, userId); child FKs (parentId, userId) → parent (id, userId), so Postgres rejects any mismatch). See README "Carry the Owner Foreign Key Down to Every Descendant".
  • You may (and are encouraged to) run data-backfill SQL in the migration after addColumn — e.g. populate a new NOT NULL column from an existing one so it's ready immediately, instead of a separate script.
  • Column order in createTable attrs: id → FKs → vendor IDs → custom → deletedAt/createdAt/updatedAt.
  • Timestamps: all times are UTC. createdAt/updatedAt/deletedAt are auto-managed by the model (timestamps: true) but must be defined explicitly in the migration attrs.
  • ENUMs: type name is ALL CAPS, no underscores/spaces/dashes (e.g. ORDERSTATUS); values are ALL_CAPS_WITH_UNDERSCORES (e.g. PENDING_REVIEW). Keep ENUM values in sync with the matching constants.js array.
  • Booleans is/has/can/does; FK cols <entity>Id; vendor IDs prefixed.
  • Add-index migration filename: <timestamp>-add-index-<colA>_<colB>-to-<TablePlural>-tbl.js.

Read the full file on GitHub · 44 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 44 lines · 65 tokens per session scan A f287cfe0ab48

Subscribe to this mod's changes

add-migration is a skill published in the GitHub repository Hackbyrd/orbital-express (14 stars, last pushed 14d ago), licensed MIT. It adds 65 tokens to every session and 1,192 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

db-repair

Auto-fix gbrain's Postgres access so the brain stays available. When any gbrain command or MCP tool result carries a GBRAINDBACCESS marker (or an operator reports the brain database is down), run the hardcoded gbrain db-repair ladder: diagnose, apply the safe tier, verify. The action is ALWAYS the hardcoded command …

garrytan/gbrain · 96 tokens

postgres-pro

Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.

Jeffallan/claude-skills · 41 tokens

postgres-database-migration

Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. Trigger when user asks to: Test a schema migration before applying it to production Add, remove, or rename columns safely on a live table Change a column's data…

timescale/pg-aiguide · 222 tokens

setup-timescaledb-hypertables

Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. Trigger when user asks to: Create or design SQL schemas/tables AND…

timescale/pg-aiguide · 219 tokens

claimable-postgres

Provision instant temporary Postgres databases via Claimable Postgres by Neon (neon.new) with no login, signup, or credit card. Supports REST API, CLI, and SDK. Use when users ask for a quick Postgres environment, a throwaway DATABASEURL for prototyping/tests, or "just give me a DB now". Triggers include: "quick…

neondatabase/mcp-server-neon · 123 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, FK…

awslabs/agent-plugins · 227 tokens