paperclipai/paperclip · warning

${label} has existing tables but no migration journal. Run m

Error message

${label} has existing tables but no migration journal. Run migrations manually to sync schema.

What it means

The target database has tables but no drizzle migration journal — the schema was created outside the migration system. The server warns, then either auto-applies migrations (PAPERCLIP_MIGRATION_AUTO_APPLY=true), prompts interactively, or — if you decline — refuses to start against a possibly stale schema. The warning itself is the pre-prompt notice; declining escalates to a thrown error.

Source

Thrown at server/src/index.ts:218

    label: string,
    opts?: EnsureMigrationsOptions,
  ): Promise<MigrationSummary> {
    const autoApply = opts?.autoApply === true;
    let state = await inspectMigrations(connectionString);
    if (state.status === "needsMigrations" && state.reason === "pending-migrations") {
      const repair = await reconcilePendingMigrationHistory(connectionString);
      if (repair.repairedMigrations.length > 0) {
        logger.warn(
          { repairedMigrations: repair.repairedMigrations },
          `${label} had drifted migration history; repaired migration journal entries from existing schema state.`,
        );
        state = await inspectMigrations(connectionString);
        if (state.status === "upToDate") return "already applied";
      }
    }
    if (state.status === "upToDate") return "already applied";
    if (state.status === "needsMigrations" && state.reason === "no-migration-journal-non-empty-db") {
      logger.warn(
        { tableCount: state.tableCount },
        `${label} has existing tables but no migration journal. Run migrations manually to sync schema.`,
      );
      const apply = autoApply ? true : await promptApplyMigrations(state.pendingMigrations);
      if (!apply) {
        throw new 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.",
        );
      }
  
      logger.info({ pendingMigrations: state.pendingMigrations }, `Applying ${state.pendingMigrations.length} pending migrations for ${label}`);
      await applyPendingMigrations(connectionString);
      return "applied (pending migrations)";
    }
  
    const apply = autoApply ? true : await promptApplyMigrations(state.pendingMigrations);
    if (!apply) {

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Confirm the database is genuinely meant to be Paperclip's; if it is a stranger DB, fix the connection string first.
  2. Let migrations apply: answer yes at the prompt or set PAPERCLIP_MIGRATION_AUTO_APPLY=true.
  3. Baseline manually by running `pnpm db:migrate` against the database to sync schema and journal.
  4. Never run Paperclip against an unrelated shared database.

Example fix

# before (interactive prompt blocks deploys)
# after
export PAPERCLIP_MIGRATION_AUTO_APPLY=true
Defensive patterns

Strategy: validation

Validate before calling

// Refuse to boot against a journal-less non-empty database by accident.
const r = await db.execute(sql`select count(*)::int as n from information_schema.tables
  where table_schema = 'public' and table_name = '__drizzle_migrations'`);
const hasJournal = r.rows[0].n > 0;
if (!hasJournal) {
  throw new Error('Target DB has no migration journal; baseline it deliberately (pnpm db:migrate) or point at the right DB');
}

Prevention

When it happens

Trigger: Pointing the server at a manually-created database, a schema-only restored dump, or a DB provisioned by external tooling that never ran drizzle migrations — inspectMigrations returns reason 'no-migration-journal-non-empty-db'.

Common situations: Adopting a legacy database into Paperclip; staging copies made without the journal table; DBA-provisioned schemas; connecting to the wrong (non-Paperclip) shared database.

Related errors


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