Skip to content
Skills Library
Programming · Building & coding

add-migration

/add-migration

Add or change a Postgres schema migration. Use when a feature needs a new table, column or index, or when running `npm run migrate`.

Licence
AGPL-3.0
Last repository change
02.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 02.11.2026, without references to retired models or APIs.

Licence

AGPL-3.0, copyleft: przeróbki udostępniane innym muszą mieć tę samą licencję.

What it does and when to use it

Add or change a Postgres schema migration. Use when a feature needs a new table, column or index, or when running `npm run migrate`.

Original author description

Add or change a Postgres schema migration. Use when a feature needs a new table, column or index, or when running `npm run migrate`.

How it works

  1. Rules
  2. Running (live Neon DB, confirm first)
  3. After writing it
  4. Dev branch first (added 2026-10-15)
Original SKILL.md headings · 37 lines, 476 words
SKILL.md preview
---
name: add-migration
description: Add or change a Postgres schema migration. Use when a feature needs a new table, column or index, or when running `npm run migrate`.
---

# Adding a migration

Migrations live in `migrations/NNN_name.sql` (next number = highest + 1; `002` is intentionally absent).
`scripts/migrate.ts` auto-discovers every `NNN_*.sql`, sorts them, and records applied files in the
`schema_migrations` table. No manual registration is needed.

## Rules
1. **Must be idempotent**: `CREATE TABLE IF NOT EXISTS`, `ADD COLUMN IF NOT EXISTS`, `CREATE INDEX IF NOT EXISTS`,
   `ON CONFLICT DO NOTHING`, or a `DO $$ ... IF NOT EXISTS ... $$` block (see `011_reversed_concepts.sql`).
   Databases that predate `schema_migrations` re-run old files once.
2. Postgres dialect only. Existing boolean-ish columns use integers (`is_admin`, `is_preset` = 0/1); match
   the neighboring table's convention.
3. Add a one-line comment at the top describing the change.
4. Never edit an already-applied migration; add a new one.
5. Update TypeScript types and queries that touch the changed tables.
6. **Say whether older versions can still use the data**, in a line of its own: `-- older-versions: ok` (only a new table, or a new column with a default that older code never reads) or `-- older-versions: no` (anything older code could misread). Unmarked counts as `no`, and `tests/local-db.test.ts` fails on an unmarked file after 099. An `ok` migration must not rely on a one-time data step for rows written later; put that in start-up code (`lib/local-seed.ts`). Why: an older downloaded copy opens newer data only when every newer change said `ok` (`docs/setup-guide.md`, "Updating a copy").

## Running (live Neon DB, confirm first)
`npm run migrate` loads `.env.local` and writes to the **live** database.
Before running: show the user the SQL and the list of pending files, and get an explicit OK.
After: confirm the output shows `✓ Applied` for the new file only (others `- Skipped`).

## After writing it
1. Run it on the dev branch (next section) and click through the change (`test-as-user`).
2. Run `data-lifecycle-check`: owner scoping, deletion, the Settings export, search, the companion, the privacy notice. Nothing fails loudly when one of these is missed.
3. Before any push or deploy, run `live-migration-check`: it lists what live is missing, which code breaks without it, and the order of steps for the user. Code that reads a new column needs the migration on live **first**, or a guard like the tiers in `lib/prefs.ts`.
4. Record the number as owed in `docs/open-items.md` (section B or D); `open-item-sync` keeps that line true.

## Dev branch first (added 2026-10-15)
Run every new migration on the Neon **dev branch** before live. `npm run migrate` reads `.env.local` (live), so point it at dev explicitly:
```bash
export DATABASE_URL="$(grep -E '^DATABASE_URL=' .env.development.local | cut -d= -f2- | tr -d '\r"')"
echo "$DATABASE_URL" | sed -E 's#.*@([^/:?]+).*#\1#'   # print ONLY the host, then check it
```
Dev host starts `ep-your-dev-branch`; live starts `ep-your-live-db`. Make migrations idempotent, never rename or drop. The live database is migrated by the user, who is owed the earlier ones (see PROGRESS.md).

Versions

RepositoryScoreLicence
This page · KyRocks19/divination-station-takeoff100AGPL-3.0
artk0de/tearags-mcp100MIT
kadirguloglu/kg-devkit96MIT
kadirguloglu/kg-devkit96MIT

Database snapshot: 13.11.2026 · package version 6407d3d551b2 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100add-store-query
    Use when adding or modifying a SQL query against the SQLite store — symptoms include "add a method to *Store", "new column on nodes", "expose X via the store", "add an index", "support a new lookup", "write a migration", or any change to `pkg/store/queries.go`, `pkg/store/*.go`…
  • 95database-migration
    Create database migration with schema changes and rollback. Auto-invoke when user says "create migration", "add table", "modify schema", or "change database".
  • 96postgres-safe-migration
    Use when writing a migration for a table that holds data, when changing a column, adding a required column, an index or a constraint, or when a pg- check refuses a migration.
  • 87postgres-migration
    Change the Postgres schema without breaking the previous release, which keeps serving on the new schema: the expand/contract recipes for adding a column or table, removing one, renaming one, changing its type, making it NOT NULL, adding an index or a unique constraint and…
  • 100db-migration
    Use when the user needs a PostgreSQL schema or data change through Liquibase or Flyway: new table, add, rename, or drop a column, add an index, change a constraint, backfill or one-time data fix, zero-downtime migration, or a new entity that needs persistence.
  • 100migration-helper
    Write safe database schema and data migrations with rollback steps, lock and timeout checks, and an expand-and-contract plan for zero-downtime deploys. Use when the user asks to add, rename or drop a column or table, add an index or constraint, backfill data, or review a…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.