pub async fn established_pending_through(
pool: &PgPool,
tracking_table: &TrackingTable,
files: &BTreeMap<(u64, bool), Vec<MigrationSection>>,
established: &BTreeSet<String>,
through_version: u64,
) -> Result<Vec<u64>>Expand description
Migration versions ≤ through_version whose base/established-module
sections are NOT yet applied on the target — i.e. versions the established
set still needs before it is caught up to through_version. An empty
result means caught up.
Adopting a module from a baseline at version V writes a tracking row that
claims coverage through V. That claim is only honest if the target’s other
modules are actually at V, so adoption checks this first and refuses when
it isn’t — rolling an established (possibly-destructive) module forward is
an explicit apply, never a side effect of adopting a different module.
Migrations at or below a fully-completed baseline the target already holds are covered and excluded (the honest applied-baseline watermark, distinct from the crossing watermark — a crashed baseline, with a non-completed section, does not count).