{"id":"57ea2c03233bbd5f","repo":"drizzle-team/drizzle-orm","slug":"missing-migration-journalentry-tag","errorCode":null,"errorMessage":"Missing migration: ${journalEntry.tag}","messagePattern":"Missing migration: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"drizzle-orm/src/durable-sqlite/migrator.ts","lineNumber":19,"sourceCode":"import type { MigrationMeta } from '~/migrator.ts';\nimport { sql } from '~/sql/index.ts';\nimport type { DrizzleSqliteDODatabase } from './driver.ts';\n\ninterface MigrationConfig {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}\n\nfunction readMigrationFiles({ journal, migrations }: MigrationConfig): MigrationMeta[] {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor (const journalEntry of journal.entries) {\n\t\tconst query = migrations[`m${journalEntry.idx.toString().padStart(4, '0')}`];\n\n\t\tif (!query) {\n\t\t\tthrow new Error(`Missing migration: ${journalEntry.tag}`);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = query.split('--> statement-breakpoint').map((it) => {\n\t\t\t\treturn it;\n\t\t\t});\n\n\t\t\tmigrationQueries.push({\n\t\t\t\tsql: result,\n\t\t\t\tbps: journalEntry.breakpoints,\n\t\t\t\tfolderMillis: journalEntry.when,\n\t\t\t\thash: '',\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new Error(`Failed to parse migration: ${journalEntry.tag}`);\n\t\t}\n\t}\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-orm/src/durable-sqlite/migrator.ts#L1-L37","documentation":"The durable-sqlite (Durable Object SQLite) migrator reads `journal.entries` and looks up each migration SQL by `m<idx padded to 4>`. If that key is absent from the `migrations` map, the migration file for that journal entry is missing from the bundle and drizzle cannot continue. This halts migration before any statements run.","triggerScenarios":"Calling `migrate(db, { journal, migrations })` for Cloudflare Durable Objects where the `migrations` record is missing one of the `m0000..mNNNN` files referenced by `meta/_journal.json`. Common when the import map/bundler did not include a generated migration file.","commonSituations":"Forgetting to re-run `drizzle-kit generate` after schema changes and shipping a stale migrations folder, or a glob/import that drops a file (e.g. `.sql` vs no extension mismatch), or referencing a different migrations directory than the one generated.","solutions":["Regenerate migrations (`drizzle-kit generate`) and confirm every `meta/_journal.json` entry has a matching `m0000`-style file in the migrations folder.","Ensure the `migrations` record passed to `migrate()` is built from the correct folder with all files imported.","If a migration was removed intentionally, also remove its entry from `_journal.json`."],"exampleFix":"// before\nmigrate(db, { journal, migrations }); // migrations missing m0003\n// after - import all generated files\nimport * as migrations from './drizzle/migrations/*.sql';\nmigrate(db, { journal, migrations });","handlingStrategy":"validation","validationCode":"// Verify every journal entry has a matching migration before migrate()\nfunction assertMigrationsComplete(journal: { entries: { idx: number; tag: string }[] }, migrations: Record<string, string>) {\n  for (const e of journal.entries) {\n    const key = `m${e.idx.toString().padStart(4, '0')}`;\n    if (!migrations[key]) throw new Error(`Missing migration file ${key} (${e.tag})`);\n  }\n}","typeGuard":"function isMigrationBundle(j: unknown, m: unknown): j is { entries: { idx: number; tag: string }[] } {\n  return !!j && Array.isArray((j as any).entries) && typeof m === 'object' && m !== null;\n}","tryCatchPattern":"try {\n  await migrate(db, { journal, migrations });\n} catch (e) {\n  const m = (e as Error).message.match(/Missing migration: (.+)/);\n  if (m) console.error(`Regenerate or import the file for ${m[1]}`);\n  throw e;\n}","preventionTips":["Import every generated migration file into the bundle (use a glob import).","Re-run `drizzle-kit generate` whenever the schema changes and commit the whole folder.","Validate the journal/migrations parity before calling migrate()."],"tags":["drizzle-orm","durable-sqlite","migrations","cloudflare"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}