{"record":{"id":"1f0d8597a8f07431","repo":"paperclipai/paperclip","slug":"label-has-pending-migrations-formatpendingmi","errorCode":null,"errorMessage":"${label} has pending migrations (${formatPendingMigrationSummary(state.pendingMigrations)}). Refusing to start against a stale schema. Run pnpm db:migrate or set PAPERCLIP_MIGRATION_AUTO_APPLY=true.","messagePattern":"(.+?) has pending migrations \\((.+?)\\)\\. Refusing to start against a stale schema\\. Run pnpm db:migrate or set PAPERCLIP_MIGRATION_AUTO_APPLY=true\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/index.ts","lineNumber":275,"sourceCode":"  async function ensureMigrations(\n    connectionString: string,\n    label: string,\n    opts?: EnsureMigrationsOptions,\n  ): Promise<MigrationSummary> {\n    const autoApply = opts?.autoApply === true;\n    let state = await inspectMigrations(connectionString);\n    if (state.status === \"needsMigrations\" && state.reason === \"pending-migrations\") {\n      const repair = await reconcilePendingMigrationHistory(connectionString);\n      if (repair.repairedMigrations.length > 0) {\n        logger.warn(\n          { repairedMigrations: repair.repairedMigrations },\n          `${label} had drifted migration history; repaired migration journal entries from existing schema state.`,\n        );\n        state = await inspectMigrations(connectionString);\n        if (state.status === \"upToDate\") return \"already applied\";\n      }\n    }\n    if (state.status === \"upToDate\") return \"already applied\";\n    if (state.status === \"needsMigrations\" && state.reason === \"no-migration-journal-non-empty-db\") {\n      logger.warn(\n        { tableCount: state.tableCount },\n        `${label} has existing tables but no migration journal. Run migrations manually to sync schema.`,\n      );\n      const apply = autoApply ? true : await promptApplyMigrations(state.pendingMigrations);\n      if (!apply) {\n        throw new Error(\n          `${label} has pending migrations (${formatPendingMigrationSummary(state.pendingMigrations)}). ` +\n            \"Refusing to start against a stale schema. Run pnpm db:migrate or set PAPERCLIP_MIGRATION_AUTO_APPLY=true.\",\n        );\n      }\n  \n      logger.info({ pendingMigrations: state.pendingMigrations }, `Applying ${state.pendingMigrations.length} pending migrations for ${label}`);\n      await applyPendingMigrations(connectionString);\n      return \"applied (pending migrations)\";\n    }\n  ","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/index.ts#L257-L293","documentation":"Error \"${label} has pending migrations (${formatPendingMigrationSummary(state.pendingMigrations)}). Refusing to start against a stale schema. Run pnpm db:migrate or set PAPERCLIP_MIGRATION_AUTO_APPLY=true.\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at server/src/index.ts:217 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run pnpm db:migrate to apply the pending migrations.","Set PAPERCLIP_MIGRATION_AUTO_APPLY=true to apply migrations automatically on startup."],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}