# X_MIGRATION_SNAPSHOT_MISSING

## Means

the newest migration records no schema snapshot

## Typical cause

`As of 2026-08`: `x db gen` found the newest migration on disk carrying no `<id>.snapshot.json` sidecar — deleted, or hand-written without one. Every generated migration writes the sidecar the *next* generation diffs against, so there is nothing to diff the entities against. Refused rather than defaulted to the empty schema, which would emit `create table` for every table the database already holds. A scaffold no longer starts in this state: `x new` writes no migration at all, and `x db gen` is the one writer of that directory. `x doctor` reports it too, `As of 2026-08`, so the condition is visible before a generate hits it

## Fix

`git checkout -- packages/db/migrations/<id>.snapshot.json`, or, when it was never written, delete the whole migration first and regenerate: `rm packages/db/migrations/<id>.* && x db gen "<name>"`. That order is the fix — naming `x db gen` while the file is still there re-raises this code. The same condition reaches `x db migrate` as `X_DB_DRIFT` with an `unknown-schema` difference, whose `fix:` names the same two remedies in the same order

[Entity and database](/error-codes#entity-and-database)
