{"record":{"id":"8f5b9c21086277e0","repo":"paperclipai/paperclip","slug":"migration-journal-file-order-mismatch-at-position","errorCode":null,"errorMessage":"Migration journal/file order mismatch at position ${index}: journal has ${journalFile}, files have ${migrationFile}","messagePattern":"Migration journal/file order mismatch at position (.+?): journal has (.+?), files have (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/db/src/check-migration-numbering.ts","lineNumber":59,"sourceCode":"      );\n    }\n  }\n}\n\nfunction ensureJournalMatchesFiles(migrationFiles: string[], journalTags: string[]) {\n  const journalFiles = journalTags.map((tag) => `${tag}.sql`);\n\n  if (journalFiles.length !== migrationFiles.length) {\n    throw new Error(\n      `Migration journal/file count mismatch: journal has ${journalFiles.length}, files have ${migrationFiles.length}`,\n    );\n  }\n\n  for (let index = 0; index < migrationFiles.length; index += 1) {\n    const migrationFile = migrationFiles[index];\n    const journalFile = journalFiles[index];\n    if (migrationFile !== journalFile) {\n      throw new Error(\n        `Migration journal/file order mismatch at position ${index}: journal has ${journalFile}, files have ${migrationFile}`,\n      );\n    }\n  }\n}\n\nasync function main() {\n  const migrationFiles = (await readdir(migrationsDir))\n    .filter((entry) => entry.endsWith(\".sql\"))\n    .sort();\n\n  ensureNoDuplicates(migrationFiles, \"migration files\");\n  ensureStrictlyOrdered(migrationFiles, \"migration files\");\n\n  const rawJournal = await readFile(journalPath, \"utf8\");\n  const journal = JSON.parse(rawJournal) as JournalFile;\n  const journalTags = (journal.entries ?? [])\n    .map((entry, index) => {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/db/src/check-migration-numbering.ts#L41-L77","documentation":"Error \"Migration journal/file order mismatch at position ${index}: journal has ${journalFile}, files have ${migrationFile}\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/db/src/check-migration-numbering.ts:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the journal entry order/tag to match the migration file at that position."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}