Skip to main content

try_count_pending_migrations

Function try_count_pending_migrations 

Source
pub fn try_count_pending_migrations(
    data_dir: &Path,
) -> Result<usize, PendingCountError>
Expand description

Number of REGISTRY migrations not yet applied, or why that could not be determined.

Opens stores read-write (SQLite has no read-only open for WAL mode); this may create objects.db if it does not exist. data_dir must be the wave data dir (parent of db/), not the db dir itself.

WHY THIS EXISTS ALONGSIDE count_pending_migrations. That function reports 0 on every error, which is the right default for its caller: the migration run is still ahead of it, so a bad count costs nothing. It is the wrong default for a caller using the count to decide whether the schema is current — there, a transient open failure reading as “nothing pending” means proceeding against a store that may be one or many migrations behind. SPEC_FAST_STARTUP_UPGRADE_OWNS_MIGRATIONS_AND_UPDATES_2026_09_15.md §4.1 (invariant S1b) requires that gate to fail closed, which it cannot do without a fallible check to fail closed on.