paperclipai/paperclip · critical · Error
Database for ${configPath} is not up to date.${pending} Run
Error message
Database for ${configPath} is not up to date.${pending} Run `pnpm db:migrate` (or start Paperclip once) before using worktree merge history. What it means
Thrown by openConfiguredDb after inspectMigrations() reports the database is not 'upToDate'. Before merge-history reads/writes data, every involved DB must match the latest schema. When reason is 'pending-migrations' the message lists the pending migration names. This guards against merging into a partially-migrated database which would silently drop or mis-shape data.
Source
Thrown at cli/src/commands/worktree.ts:2278
}
const envEntries = readPaperclipEnvEntries(resolvePaperclipEnvFile(configPath));
let embeddedHandle: EmbeddedPostgresHandle | null = null;
try {
if (config.database.mode === "embedded-postgres") {
embeddedHandle = await ensureEmbeddedPostgres(
config.database.embeddedPostgresDataDir,
config.database.embeddedPostgresPort,
);
}
const connectionString = resolveSourceConnectionString(config, envEntries, embeddedHandle?.port);
const migrationState = await inspectMigrations(connectionString);
if (migrationState.status !== "upToDate") {
const pending =
migrationState.reason === "pending-migrations"
? ` Pending migrations: ${migrationState.pendingMigrations.join(", ")}.`
: "";
throw new Error(
`Database for ${configPath} is not up to date.${pending} Run \`pnpm db:migrate\` (or start Paperclip once) before using worktree merge history.`,
);
}
const db = createDb(connectionString) as ClosableDb;
return {
db,
stop: async () => {
await closeDb(db);
if (embeddedHandle?.startedByThisProcess) {
await embeddedHandle.stop();
}
},
};
} catch (error) {
if (embeddedHandle?.startedByThisProcess) {
await embeddedHandle.stop().catch(() => undefined);
}
throw error;View on GitHub (pinned to 67001ec6eb)
Solutions
- Apply migrations in the failing instance: run `pnpm db:migrate`, or simply start Paperclip once (`pnpm dev`) so auto-migration runs.
- Re-seed the worktree from an up-to-date source so its DB matches the current schema.
- For an embedded-postgres instance with a stale data dir, reset it (`rm -rf data/pglite` or the embedded dir) and restart to rebuild.
- Re-run merge-history after all listed pending migrations are applied.
Example fix
// before: pending migrations block merge-history // after cd /path/to/instance && pnpm db:migrate # or: pnpm dev (auto-migrates then stop) paperclipai worktree:merge-history
Defensive patterns
Strategy: validation
Validate before calling
const state = await inspectMigrations(connectionString);
if (state.status !== "upToDate") {
throw new Error(`DB not migrated; run pnpm db:migrate. Pending: ${state.pendingMigrations?.join(", ")}`);
} Type guard
async function dbUpToDate(conn: string): Promise<boolean> {
return (await inspectMigrations(conn)).status === "upToDate";
} Try / catch
try { await openConfiguredDb(configPath); }
catch (err) {
if (/not up to date/.test(String((err as Error).message))) {
await runMigrations(configPath); // pnpm db:migrate equivalent
await openConfiguredDb(configPath);
} else throw err;
} Prevention
- Start Paperclip once (`pnpm dev`) after pulling schema changes so auto-migration runs.
- Run `pnpm db:migrate` in each instance before merge-history.
- Reset stale embedded DB data dirs and re-seed from an up-to-date source.
When it happens
Trigger: Running merge-history against a worktree or source DB whose migrations have not been applied (fresh clone, never started); schema was updated in packages/db but `pnpm db:generate`/migrate was not run in this instance; an embedded-postgres data dir from an older schema version.
Common situations: Pulled latest main with new migrations but didn't restart Paperclip (which auto-migrates); worktree seeded from a source that was itself behind; embedded PGlite/embedded-postgres data dir out of sync after a schema change.
Related errors
- Source and target databases do not share a company id. Pass
- Could not resolve company "${selector}" in both source and t
- Multiple shared companies found. Re-run with --company <id-o
- Target company ${companyId} was not found.
- Project mapping cancelled.
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/bac8da290782d59f.
Report an issue: GitHub.