← ClaudeAtlas

mycovault-schema-migrationlisted

Use this skill whenever you need to add, modify, or remove tables, columns, or indexes in the Myco vault SQLite schema — even if the user just asks to "add a column" or "create a new table." The vault uses a versioned createSchema migration chain where each schema version is a numbered step that builds on the previous one. Because user vaults accumulate real data across machines, any schema change that breaks the migration chain can corrupt or destroy vault data. This skill covers how to add a new version to the chain, write safe migration SQL, handle backfill steps, bump the schema version constant, keep the dormant team-sync worker's D1 mirror parity-test-clean if your table is in the synced-table set, and verify the migration works end-to-end before shipping.
goondocks-co/myco · ★ 13 · API & Backend · score 79
Install: claude install-skill goondocks-co/myco
# Safely Versioning the Myco Vault SQLite Schema The Myco vault is a SQLite database at `.myco/myco.db`. Its schema evolves through a numbered migration chain — each version is an incremental step applied on top of the previous one. This matters because vaults are long-lived: users have real sessions, spores, and graph data that must survive every upgrade. Breaking the chain means breaking their data. ## Prerequisites - Know which schema version is current. Check `SCHEMA_VERSION` in `packages/myco/src/db/schema.ts`. - Know the migration chain itself — the `MIGRATIONS` registry array and every `migrateVXToVY` function — lives in a *separate* file, `packages/myco/src/db/migrations.ts` (~4,400 lines). `schema.ts` only owns the version constant, the fresh-install DDL application, and `createSchema()`'s driver loop. - Know exactly what you're adding — table name, column names and types, constraints, indexes. - Understand whether the change needs a **backfill** (populating existing rows after adding a column) or is append-only. ## Steps ### 1. Find the schema files and the current version ```bash grep -n "SCHEMA_VERSION = " packages/myco/src/db/schema.ts ``` `createSchema()` (in `schema.ts`) is the driver, not the chain itself: ```ts export function createSchema(db: Database, machineId: string = DEFAULT_MACHINE_ID): void { if (hasSchemaVersionTable(db)) { // existing vault: run any migrations the vault hasn't reached yet for (const migration of MIGRATIONS) {