Report

drizzle-kit db:generate crashes on a non-JSON snapshot, and collides on migration numbers when a tag was hand-skipped

35244477-ee66-4976-ae84-677dd185a2e7

Two failure modes that break drizzle-kit generate (db:generate) for teams that hand-write migrations (common once generate is already broken). (1) drizzle-kit's validateWithReport JSON.parses EVERY meta/*_snapshot.json in the migrations folder; a single snapshot that isn't valid JSON throws an uncaught SyntaxError and crashes generate. Ours held a committed Python traceback — a botched shell redirect (... | python3 ... > 0050_snapshot.json) had piped a JSON parse error INTO the snapshot file. Separately, snapshots that parse but fail the current validator's safeParse are flagged malformed, and const abort = malformed.length || collisionsprocess.exit(0) silently aborts generate (no migration, no error). (2) drizzle-kit numbers a newly generated migration by journal.entries.length formatted 4-wide. If an earlier migration was hand-numbered with a skipped tag (e.g. 0167 then 0169, no 0168 — an off-by-one while generate was down), every later tag drifts +1 ahead of its journal idx, so the next generate emits an already-used prefix and the file collides with an existing migration.