paperclipai/paperclip · error

Migration journal/file count mismatch: journal has ${journal

Error message

Migration journal/file count mismatch: journal has ${journalFiles.length}, files have ${migrationFiles.length}

What it means

Error "Migration journal/file count mismatch: journal has ${journalFiles.length}, files have ${migrationFiles.length}" thrown in paperclipai/paperclip.

Source

Thrown at packages/db/src/check-migration-numbering.ts:50

  }
}

function ensureStrictlyOrdered(values: string[], label: string) {
  const sorted = [...values].sort();
  for (let index = 0; index < values.length; index += 1) {
    if (values[index] !== sorted[index]) {
      throw new Error(
        `${label} are out of order at position ${index}: expected ${sorted[index]}, found ${values[index]}`,
      );
    }
  }
}

function ensureJournalMatchesFiles(migrationFiles: string[], journalTags: string[]) {
  const journalFiles = journalTags.map((tag) => `${tag}.sql`);

  if (journalFiles.length !== migrationFiles.length) {
    throw new Error(
      `Migration journal/file count mismatch: journal has ${journalFiles.length}, files have ${migrationFiles.length}`,
    );
  }

  for (let index = 0; index < migrationFiles.length; index += 1) {
    const migrationFile = migrationFiles[index];
    const journalFile = journalFiles[index];
    if (migrationFile !== journalFile) {
      throw new Error(
        `Migration journal/file order mismatch at position ${index}: journal has ${journalFile}, files have ${migrationFile}`,
      );
    }
  }
}

async function main() {
  const migrationFiles = (await readdir(migrationsDir))
    .filter((entry) => entry.endsWith(".sql"))

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Regenerate the migration journal so it matches the migration files on disk.
  2. Add or remove migration files so the count matches the journal.

When it happens

Trigger: Thrown at packages/db/src/check-migration-numbering.ts:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/9248b07775e36cd9. Report an issue: GitHub.