{"record":{"id":"06a9a2943856aa81","repo":"paperclipai/paperclip","slug":"failed-to-bootstrap-migrations-bootstrappedstat","errorCode":null,"errorMessage":"Failed to bootstrap migrations: ${bootstrappedState.pendingMigrations.join(\", \")}","messagePattern":"Failed to bootstrap migrations: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/db/src/client.ts","lineNumber":830,"sourceCode":"  const rows = await sql.unsafe<{ id: number }[]>(`SELECT id FROM ${qualifiedTable} ORDER BY id`);\n  const journalMigrationFiles = await listJournalMigrationFiles();\n  const appliedFromIds = rows\n    .map((row) => journalMigrationFiles[row.id - 1])\n    .filter((name): name is string => Boolean(name));\n  if (appliedFromIds.length > 0) return appliedFromIds;\n\n  return availableMigrations.slice(0, Math.max(0, rows.length));\n}\n\nexport type MigrationHistoryReconcileResult = {\n  repairedMigrations: string[];\n  remainingMigrations: string[];\n};\n\nexport async function reconcilePendingMigrationHistory(\n  url: string,\n): Promise<MigrationHistoryReconcileResult> {\n  const state = await inspectMigrations(url);\n  if (state.status !== \"needsMigrations\" || state.reason !== \"pending-migrations\") {\n    return { repairedMigrations: [], remainingMigrations: [] };\n  }\n\n  const sql = createUtilitySql(url);\n  const repairedMigrations: string[] = [];\n\n  try {\n    const journalEntries = await listJournalMigrationEntries();\n    const folderMillisByFile = new Map(journalEntries.map((entry) => [entry.fileName, entry.folderMillis]));\n    const migrationTableSchema = await discoverMigrationTableSchema(sql);\n    if (!migrationTableSchema) {\n      return { repairedMigrations, remainingMigrations: state.pendingMigrations };\n    }\n\n    const columnNames = await getMigrationTableColumnNames(sql, migrationTableSchema);\n    const qualifiedTable = `${quoteIdentifier(migrationTableSchema)}.${quoteIdentifier(DRIZZLE_MIGRATIONS_TABLE)}`;\n","sourceCodeStart":812,"sourceCodeEnd":848,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/db/src/client.ts#L812-L848","documentation":"Terminal failure of the migration bootstrap path on an embedded/test database: after running migrations and attempting pending-history reconciliation, some migrations are still recorded as pending (named in the message), so the bootstrap gives up rather than looping.","triggerScenarios":"Thrown at packages/db/src/client.ts:750 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect why the listed migrations failed to bootstrap and fix them.","Run `pnpm db:migrate` and check migration logs."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}