run-migration

Executes forward-only Drift/SQLite schema migrations with snapshot backup and content verification tests.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/zakariaf/NearlyStop --skill run-migration-zakariaf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: run-migration
Source: https://github.com/zakariaf/NearlyStop/tree/main/.claude/skills/run-migration
Command: npx skills add https://github.com/zakariaf/NearlyStop --skill run-migration-zakariaf

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? In an offline-first app, the on-device SQLite database is the only copy of user data, and a bad schema migration silently destroys rows that exist nowhere else. This Skill enforces a strict, ordered migration ritual for Drift databases so schema changes never corrupt or lose user records. ## Core Features & Use Cases - Snapshot-before-open guard: Takes a file-level backup of the database and its WAL/SHM sidecars before any connection opens, and restores it automatically if the migration throws. - Append-only stepwise migrations: Enforces bumping schemaVersion by exactly one, adding new fromNToM steps without ever editing shipped steps or writing down migrations. - Content-level verification: Requires tests covering every from-to version path, write-at-v(n)/read-at-v(n+1) content checks with hostile fixtures, PRAGMA integrity_check and foreign_key_check, and a forced mid-migration throw that proves snapshot restore works. - Use Case: When adding a new column to a Drift table in a Flutter app, run this workflow to bump the schema version, generate the committed schema snapshot, write the forward step, and prove with tests that existing user data survives the upgrade byte-for-byte. ## Quick Start Ask the AI to run the migration workflow to add a new column to the Drift database and verify the upgrade preserves all existing rows.

Frequently Asked Questions about run-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a Drift schema migration in Flutter safely?

Take a file snapshot of the database and its WAL/SHM sidecars before opening it, bump schemaVersion by exactly one, add an append-only fromNToM step, regenerate code, and run migration tests covering every version path. Restore the snapshot if the open throws.

How do I test SQLite migrations across multiple schema versions?

Use Drift's SchemaVerifier with a nested loop covering every from-to pair up to the latest version, including multi-version skips. Add a content test that writes rows with era-correct classes at v(n), migrates, and reads them back at v(n+1).

Can I write a down migration in SQLite or Drift?

No. SQLite has no true down migration, and this workflow forbids writing one. The only rollback mechanism is restoring the file snapshot taken before the database was opened.

Why does migrateAndValidate pass even when migration loses data?

migrateAndValidate only compares CREATE statements and never reads a row, so a migration that rebuilds a table but copies zero rows still passes. A content test asserting actual row data is required to catch silent data loss.

Why is PRAGMA foreign_keys ignored during my migration?

The pragma is ignored once a transaction is open, so it must be set at the top of onUpgrade before the migration transaction starts. It is also per-connection, not persisted, so re-enable it in beforeOpen on every open.

What happens if I change the schema without bumping schemaVersion?

No migration runs on the user's device at all, and the code and schema silently diverge. A CI gate comparing the committed schema snapshot against the live schema should catch this before release.