\Drupal\strata\Restore PhysicalPlan

What replacing one table's contents would actually leave behind.

The number this exists for is the comparison between the rows the table holds now and the rows Strata captured for it. Those two are equal on a table whose whole life was captured and unequal on a table that predates capture, and the difference is how many rows a restore would silently delete.

A confirm form that printed "restore 4,120 rows" without printing "the table currently holds 51,880" would be describing the same operation in a way that hides its cost. So both numbers are here, and the plan carries the warning rather than leaving the caller to work it out.

Summary

Methods
Properties
Constants
__construct
refuse
coverage
rowsLost
wouldLoseRows
rowLossWarning
isActionable
summary
asRestorePlan
jsonSerialize
table
target
liveRows
capturedRows
columns
unreadable
refused
seconds
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$table

$table : string

Type

string

$target

$target : string

Type

string

$liveRows

$liveRows : int

Type

int

$capturedRows

$capturedRows : int

Type

int

$columns

$columns : array

Type

array<string|int, mixed>

$unreadable

$unreadable : int

Type

int

$refused

$refused : ?string

Type

string|null

$seconds

$seconds : float

Type

float

Methods

__construct()

__construct(string  $table, string  $target, int  $liveRows = 0, int  $capturedRows = 0, list  $columns = [], int  $unreadable = 0, string|null  $refused = null, float  $seconds = 0.0) : mixed

Constructs a plan.

Parameters

string $table

The table.

string $target

Commit id the restore targets.

int $liveRows

Rows the table holds now.

int $capturedRows

Rows Strata captured for it at the target.

list $columns

The union of columns those rows carry.

int $unreadable

Captured rows that could not be replayed completely.

string|null $refused

Why the plan cannot proceed at all, or NULL.

float $seconds

How long planning took.

Returns

mixed —

refuse()

refuse(string  $table, string  $target, string  $reason, float  $seconds = 0.0) : self

A plan that cannot proceed.

Parameters

string $table

The table.

string $target

Commit id.

string $reason

Why.

float $seconds

How long deciding took.

Returns

self —

The plan.

coverage()

coverage() : float

How much of the live table the capture covers.

Returns

float —

Captured rows divided by live rows, or 1.0 when the table is empty - restoring an empty table to empty loses nothing.

rowsLost()

rowsLost() : int

How many rows the restore would remove.

Returns

int —

The difference, never below zero. A capture holding MORE rows than the table does is a restore that adds rows back, which is what a restore is for.

wouldLoseRows()

wouldLoseRows() : bool

Whether the restore would leave the table materially smaller.

Returns

bool —

TRUE when coverage falls below the floor.

rowLossWarning()

rowLossWarning() : string

The warning a confirm form prints, and the reason a restore refuses without an override.

Returns

string —

One sentence naming both numbers.

isActionable()

isActionable() : bool

Whether this plan would write anything.

Returns

bool —

TRUE when it can proceed and has rows or an empty target to write.

summary()

summary() : string

A one-line summary for a log entry or a command's output.

Returns

string —

The summary.

asRestorePlan()

asRestorePlan() : \Drupal\strata\Restore\RestorePlan

The same plan in the shape the audit log records.

The audit table is shared with logical restores, so a physical plan presents itself as one subject - the table - with the coverage carried in the detail.

Returns

\Drupal\strata\Restore\RestorePlan —

The plan.

jsonSerialize()

jsonSerialize() : array<string,mixed>

{@inheritdoc}

Returns

array

The plan as a plain array.