Skip to content
Back to skills

Add Migration

ASecurity

Add a database change to TRouteAI the safe way (an additive SQL migration and its database module). Use when a change needs a new table, column or index, or new stored data.

  • 29 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 25, 2026
ai-agentsgosqlnodegitdatabase

Security analysis

A100/100

Scanned November 25, 2026

npx -y skills add allswebtech/trouteai --skill add-migration --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Migration?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Add Migration
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/allswebtech-add-migration/badge)](https://www.skillsdirectory.com/skills/allswebtech-add-migration)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: add-migration
description: Add a database change to TRouteAI the safe way (an additive SQL migration and its database module). Use when a change needs a new table, column or index, or new stored data.
argument-hint: [what needs to be stored]
---

# Add a database change

Change wanted: $ARGUMENTS

**The one rule: migrations only add.** New tables, new columns, new indexes. Never `DROP`, never
rename a table or a column, never change what an existing column means. During an update the old
and the new version share one SQLite file for a moment, and a rollback runs old code on the new
schema. If the change seems to need a rename or a removal, stop and propose an additive design
(a new column, the old one left in place).

1. **Find the next number:** `ls src/lib/db/migrations | tail -3`. Files are named
   `NNN_short_name.sql` and run in name order, so keep three digits. Two files with the same
   number stop the app at start.
2. **Write the migration** as plain SQL that can run twice without harm:
   `CREATE TABLE IF NOT EXISTS …`, `CREATE INDEX IF NOT EXISTS …`,
   `ALTER TABLE … ADD COLUMN …` with a default so existing rows stay valid. Copy the style of
   the newest file in the folder.
3. **Use SQL every driver runs.** The app works on better-sqlite3, on Node's built-in
   `node:sqlite` and on sql.js. No extension functions, no driver-specific syntax.
4. **Database code** goes in `src/lib/db/<module>.ts` (copy a small one such as
   `featureFlags.ts`): import `getDbInstance` from `./core`, export small functions, and add
   `export * from "./db/<module>"` to `src/lib/localDb.ts`. Routes never contain SQL.
5. **Secrets** stored in the database go through `encryptConnectionFields()`
   (`src/lib/db/encryption.ts`) or the secrets module. Never store a credential in plain text
   and never log one.

Check it on a copy, never on real data:

- Fresh database: start the app with `DATA_DIR=$(mktemp -d)` and a spare port; it must start
  without a migration error.
- Existing database: start the previous build once in a temporary data folder, then start the
  new build on the same folder. The migration must apply, and a backup must appear in
  `db_backups/` inside that folder.
- Then the old build must still start on the migrated folder (the rollback case).

Finish with the `verify` skill and say which of the three starts you ran.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.