paperclipai/paperclip · error · Error

Migration journal is not current (${migrationState.pendingMi

Error message

Migration journal is not current (${migrationState.pendingMigrations.length} pending migration(s)).

What it means

Second rule of resolveWorktreeSeedMigrationRevision(): with requirement 'upToDate', migrationState.status must be 'upToDate' — zero pending migrations. Seed paths that snapshot or adopt a database require its journal to be fully migrated so the cloned copy is current. The message reports how many migrations are still pending.

Source

Thrown at cli/src/commands/worktree.ts:1482

export function resolveWorktreeSeedMigrationRevision(
  migrationState: Awaited<ReturnType<typeof inspectMigrations>>,
  requirement: "sourcePrefix" | "upToDate",
): string {
  const expectedAppliedPrefix = migrationState.availableMigrations.slice(
    0,
    migrationState.appliedMigrations.length,
  );
  const appliedMigrationNames = new Set(migrationState.appliedMigrations);
  if (
    appliedMigrationNames.size !== expectedAppliedPrefix.length ||
    expectedAppliedPrefix.some((migration) => !appliedMigrationNames.has(migration))
  ) {
    throw new Error("Migration journal is not a prefix of this Paperclip checkout's migration journal.");
  }

  if (requirement === "upToDate" && migrationState.status !== "upToDate") {
    throw new Error(
      `Migration journal is not current (${migrationState.pendingMigrations.length} pending migration(s)).`,
    );
  }

  const migrationRevision = expectedAppliedPrefix.at(-1);
  if (!migrationRevision) {
    throw new Error("Migration journal has no applied revision.");
  }
  return migrationRevision;
}

/**
 * Markerless worktrees predate the versioned seed manifest. Adopt one only
 * after proving that its configured database already has a compatible
 * migration journal and the core Paperclip tables. The physical PG_VERSION
 * check prevents this read-only probe from initializing a missing embedded
 * database and then mistaking that empty cluster for legacy evidence.
 */

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Bring the source database fully up to date (start the Paperclip service or run the migrate step) until inspectMigrations reports upToDate, then retry the seed
  2. Update or re-seed the source instance so its schema matches its checkout
  3. If the source cannot be migrated, pass an explicit source config whose database is current
Defensive patterns

Strategy: validation

Validate before calling

const state = await inspectMigrations(/* source connection */);
if (state.status !== 'upToDate') {
  await applyPendingMigrations(state.pendingMigrations); // or start the source service first
}

Prevention

When it happens

Trigger: resolveWorktreeSeedMigrationRevision(state, 'upToDate') when the source or target database has pending migrations — e.g. the checkout gained new drizzle migrations but the database was never migrated (service not restarted, migrations generated but not applied).

Common situations: Pulling new code with fresh migrations without restarting the source service; running db:generate without applying; using an old source worktree as seed origin after the main checkout moved forward.

Related errors


AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-21). Data as JSON: /api/errors/fcdda35ea2d18761. Report an issue: GitHub.