Add Migration
БесплатноБез исполняемых скриптовНе проверенAdd a new database migration
от lza6★ 19 звёзд на GitHubОб этом скилле
Add Migration
Add a new database migration to the project, following the established idempotent migration pattern.
Usage: /add-migration <description>
Example: /add-migration Add priority column to tasks table
Arguments: $ARGUMENTS
Instructions
Read current schema:
- Read
src/main/db/migrations.tsto understand existing tables, columns, and migration patterns - Identify which migration function to modify:
runGlobalMigrations()(forindex.db) orrunProjectMigrations()(for per-project<projectId>.db) - Most migrations go in
runProjectMigrations()-- global is only for the projects list
- Read
Determine migration type and apply the correct pattern:
Column Addition
const hasColumn = (db.pragma('table_info(table_name)') as Array<{ name: string }>)
.some((column) => column.name === 'new_column');
if (!hasColumn) {
db.exec('ALTER TABLE table_name ADD COLUMN new_column TEXT DEFAULT NULL');
}
Table Addition
const hasTable = (db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get('new_table')) != null;
if (!hasTable) {
db.exec(`CREATE TABLE new_table (
id TEXT PRIMARY KEY,
...
)`);
}
Destructive Changes (column removal, type change, FK changes)
SQLite has no ALTER TABLE DROP COLUMN for older versions. Use table recreation:
db.exec(`CREATE TABLE IF NOT EXISTS table_name_new (
id TEXT PRIMARY KEY,
... -- new schema without the dropped column
)`);
db.exec('INSERT INTO table_name_new SELECT id, ... FROM table_name');
db.exec('DROP TABLE table_name');
db.exec('ALTER TABLE table_name_new RENAME TO table_name');
// Recreate any indexes
Data Backfill
const rows = db.prepare('SELECT id, config FROM table_name WHERE ...').all() as Array<{ id: string; config: string }>;
for (const row of rows) {
try {
const parsed = JSON.parse(row.config);
// Transform data
db.prepare('UPDATE table_name SET config = ? WHERE id = ?').run(JSON.stringify(parsed), row.id);
} catch {
// Skip malformed data
}
}
Placement rules:
- Add new migrations AFTER seed logic guards but BEFORE seed
INSERTstatements - Wrap multi-statement migrations in transactions if they involve data movement
- Use
db.exec()for DDL (CREATE, ALTER, DROP) - Use
db.prepare().run()for parameterized DML (INSERT, UPDATE, DELETE)
- Add new migrations AFTER seed logic guards but BEFORE seed
Match defaults to TypeScript types:
- Optional fields:
DEFAULT NULL - Required strings:
DEFAULT '' - Required numbers:
DEFAULT 0 - Required booleans:
DEFAULT 0(SQLite uses 0/1)
- Optional fields:
Update TypeScript types in
src/shared/types.ts:- Add new properties to the relevant interface (e.g.,
Task,Swimlane,SessionRecord) - Mark optional fields with
?ifDEFAULT NULL
- Add new properties to the relevant interface (e.g.,
Update repository in
src/main/db/repositories/:- Add the new column to SELECT queries
- Add the new column to INSERT/UPDATE queries
- Add any new query methods needed
Run typecheck:
npm run typecheck- Fix any type errors
Verify with the
migration-safetyagent (fresh context):- Spawn the
migration-safetyagent (read-only:Read,Glob,Grep) to confirm the migration is idempotent (guarded bypragma table_info/sqlite_master), that DEFAULT values align with the TypeScript types, and that repository queries cover the new column. - This is delegation, not forking - the skill stays in the main loop and hands only the verification pass to the auditor for an unbiased check.
- Fix any issues the auditor reports before finishing.
- Spawn the
Remind about docs:
- Suggest running
/sync-docsto updatedocs/database.md
- Suggest running
Checklist
Before finalizing, verify:
- Migration is idempotent (safe to run multiple times)
-
pragma table_infoorsqlite_masterguard is present - DEFAULT value matches TypeScript type
- Repository queries include the new column
- TypeScript types updated
- Typecheck passes
Allowed Tools
Use Read, Glob, Grep, Edit, Bash (for npm run typecheck), and Agent (to spawn the migration-safety verification agent at the end).
CRITICAL: No chained commands. Every Bash call must contain exactly ONE command. Never use &&, ||, |, or ;.
Установить Add Migration в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGlobGrepEditBash(npm:*)AgentFAQ
Что делает скилл Add Migration?
Add a new database migration
Как установить скилл Add Migration?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Add Migration запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic