Replaces whole tables with what was captured for them.
The operation for the realms a logical restore refuses: raw table rows, and anything whose
correctness depends on constraints, sequences and triggers rather than on an entity API.
The honest constraint, stated first because everything else follows from it. Strata stores
CHURN, not snapshots - that is the whole reason a year of history fits in 10 GB. So the rows it can
put back into a table are the rows it captured for that table, and nothing else. A table whose
changes were all captured restores exactly; a table that existed before capture started, or whose
drift exceeded the reconciler's per-pass bound, restores to fewer rows than it has now.
That difference is measured before anything is written, and a restore that would leave a table with
materially fewer rows than it holds REFUSES unless an operator says otherwise. Silently truncating
a table to the subset that happened to be captured is the single worst thing this code could do,
and it is exactly what a naive implementation does.
A pre-restore snapshot is forced, as it is for a logical restore, and maintenance mode is the
caller's decision: the truncate strategy needs it and the shadow-swap strategy does not, which is
why the strategy describes its own cost.
How far below the live row count a restore may land before it refuses.
A table restoring to 95% of its rows is plausibly a table with a few uncaptured rows; one
restoring to 5% is a table about to be emptied by a backup that never saw it.
TRUE to proceed when the restore would leave the table with materially fewer rows than it
holds. Off by default, because that is the case where a backup empties a table it never saw.
Every row subject the target's tree covers for this table is replayed. A subject the replay
could not complete is counted rather than half-written: a table restored from a mix of
complete and partial rows is not the table as it was at any moment.
Puts the site into maintenance mode when the strategy needs it.
Parameters
string
$strategy
The strategy id.
Returns
bool
—
TRUE when this call turned maintenance mode on, so only it turns it back off. A site already
in maintenance mode when the restore started stays in it afterwards.
leaveMaintenance()
leaveMaintenance(bool $entered) : void
Takes the site back out of maintenance mode.
Parameters
bool
$entered
Whether this restore turned it on.
Returns
void
—
snapshot()
snapshot() : string|null
Seals the site's current state so the restore can be undone.
Returns
string|null
—
The snapshot commit id, or NULL when nothing could be sealed.