{"record":{"id":"9248b07775e36cd9","repo":"paperclipai/paperclip","slug":"migration-journal-file-count-mismatch-journal-has","errorCode":null,"errorMessage":"Migration journal/file count mismatch: journal has ${journalFiles.length}, files have ${migrationFiles.length}","messagePattern":"Migration journal/file count mismatch: journal has (.+?), files have (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/db/src/check-migration-numbering.ts","lineNumber":50,"sourceCode":"  }\n}\n\nfunction ensureStrictlyOrdered(values: string[], label: string) {\n  const sorted = [...values].sort();\n  for (let index = 0; index < values.length; index += 1) {\n    if (values[index] !== sorted[index]) {\n      throw new Error(\n        `${label} are out of order at position ${index}: expected ${sorted[index]}, found ${values[index]}`,\n      );\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\"))","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/db/src/check-migration-numbering.ts#L32-L68","documentation":"Error \"Migration journal/file count mismatch: journal has ${journalFiles.length}, files have ${migrationFiles.length}\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/db/src/check-migration-numbering.ts:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the migration journal so it matches the migration files on disk.","Add or remove migration files so the count matches the journal."],"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"}