@cleocode/cleo 2026.4.44 → 2026.4.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -11467,16 +11467,27 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable, logSubsyst
11467
11467
  const localMigrations = readMigrationFiles({ migrationsFolder });
11468
11468
  const localHashes = new Set(localMigrations.map((m2) => m2.hash));
11469
11469
  const dbEntries = nativeDb.prepare('SELECT hash FROM "__drizzle_migrations"').all();
11470
- const hasOrphanedEntries = dbEntries.some((e) => !localHashes.has(e.hash));
11470
+ const orphanedEntries = dbEntries.filter((e) => !localHashes.has(e.hash));
11471
+ const hasOrphanedEntries = orphanedEntries.length > 0;
11471
11472
  if (hasOrphanedEntries) {
11472
- const log12 = getLogger(logSubsystem);
11473
- log12.warn(
11474
- { orphaned: dbEntries.filter((e) => !localHashes.has(e.hash)).length },
11475
- `Detected stale migration journal entries from a previous CLEO version. Reconciling.`
11476
- );
11477
- nativeDb.exec('DELETE FROM "__drizzle_migrations"');
11478
- for (const m2 of localMigrations) {
11479
- insertJournalEntry(nativeDb, m2.hash, m2.folderMillis, m2.name ?? "");
11473
+ const dbHashes = new Set(dbEntries.map((e) => e.hash));
11474
+ const allLocalHashesPresentInDb = localMigrations.every((m2) => dbHashes.has(m2.hash));
11475
+ if (allLocalHashesPresentInDb) {
11476
+ const log12 = getLogger(logSubsystem);
11477
+ log12.debug(
11478
+ { extra: orphanedEntries.length },
11479
+ `Migration journal has ${orphanedEntries.length} entries for migrations not known to this install (DB is ahead). Skipping reconciliation.`
11480
+ );
11481
+ } else {
11482
+ const log12 = getLogger(logSubsystem);
11483
+ log12.warn(
11484
+ { orphaned: orphanedEntries.length },
11485
+ `Detected stale migration journal entries from a previous CLEO version. Reconciling.`
11486
+ );
11487
+ nativeDb.exec('DELETE FROM "__drizzle_migrations"');
11488
+ for (const m2 of localMigrations) {
11489
+ insertJournalEntry(nativeDb, m2.hash, m2.folderMillis, m2.name ?? "");
11490
+ }
11480
11491
  }
11481
11492
  }
11482
11493
  }