Migration review

From jpicklyk/task-orchestrator · View interactive version

Migration review is an AI agent skill from the GitHub repository jpicklyk/task-orchestrator. SQLite migration assessment for items with the needs-migration-review trait. Evaluates schema changes, table recreation patterns, data migration strategy, and Flyway migration correctness. Invoked via skillPointer when filling migration-assessment notes.

How to use this skill

Skill file

Migration Review Framework

Evaluate database migration safety for SQLite-specific constraints. This project uses Flyway migrations with SQLite, which has significant limitations compared to PostgreSQL/MySQL.

Step 1: Identify Schema Changes

This runs at queue phase, as a planner, before code exists. Derive the needed changes from the

spec note, the existing migrations in current/src/main/resources/db/migration/sqlite/ and the Exposed

table objects, to determine:

1. Create new table with desired schema

2. Copy data from old table

3. Drop old table

4. Rename new table

Step 2: SQLite Constraint Check

Verify against known SQLite limitations:

Step 3: Data Migration Strategy

For migrations that modify existing data:

Guarantees that rest on engine runtime behavior need a multi-row probe. When the assessment claims an at-rest, security, or data-integrity guarantee that depends on a specific runtime/engine behavior (e.g. SQLite PRAGMA secure_delete, VACUUM page reuse, WAL checkpoint timing, FTS5 shadow-table residue), the assessment MUST specify a multi-row/multi-write empirical probe as part of the required test strategy — not a single-row assertion, which can read clean whether or not the mechanism works. It MUST NOT phrase the guarantee as absolute ("scrubbed", "removed") when only a probabilistic or partial mechanism is available ("reduces residue", "partial scrub"); once the probe exists, state the measured bound (e.g. "3–14 of 200 rows survive with the pragma, 200+ without").

Step 4: Flyway Integration

Table-recreation template

Migrations live in current/src/main/resources/db/migration/sqlite/. A migration that recreates a table

(SQLite has no ALTER COLUMN) must:

  1. Run on Flyway's connection, which has foreign_keys = OFF and busy_timeout set (do not rely on cascades; re-check child rows after).
  2. Create the new table, then INSERT INTO new_t(rowid, c1, ...) SELECT rowid, c1, ... FROM t to PRESERVE rowids (without the explicit column list the rowid lands in the first declared column): external-content FTS5 tables join on rowid.
  3. Drop the old table, rename the new one, recreate its indexes.
  4. Recreate every trigger the dropped table owned, since dropping a table drops its triggers. There are six FTS tables (work_items, notes and documents, each in a trigram and a text form; StartupIntegrity FTS_BACKING). For work_items, 6 FTS sync triggers (work_items_fts_trigram_ai/_ad/_au, work_items_fts_text_ai/_ad/_au) plus 2 cycle triggers (work_items_cycle_check, work_items_cycle_check_update); for notes, 6 FTS sync triggers (notes_fts_trigram_ai/_ad/_au, notes_fts_text_ai/_ad/_au); for documents, 6 FTS sync triggers (documents_fts_trigram_ai/_ad/_au, documents_fts_text_ai/_ad/_au, V24). Each _au trigger uses its LATEST form, restricted to the indexed columns: notes V8, documents V24 (AFTER UPDATE OF title, body), work_items V26 (AFTER UPDATE OF title, summary, description); the two cycle triggers are also V26. Copy each body from the latest migration that creates it, not from V8. The documents FTS tables join on doc_rowid (an INTEGER PRIMARY KEY alias of documents), not on the implicit rowid.
  5. INSERT INTO <fts>(<fts>) VALUES('rebuild') for the two FTS tables (trigram and text) of the recreated table only.

Startup then verifies the trigger/FTS inventory and runs the FTS integrity-check, so a missed trigger fails startup. Never use VACUUM in a migration: it can renumber rowids.

Step 5: Rollback Considerations

Output

Compose the migration-assessment note against the guidance items (1)-(6) (items_read schema,

fields ["guidance"]); do not restate their parts. Item (6), the Docker upgrade rehearsal the

implementer owns, is written as a plan: the throwaway volumes, expected row counts, the injected

malformed row and the count log line. Reference .claude/skills/spec-quality/references/project-concerns.md for additional codebase constraints.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.