KMP PHP API Reference

BackupRestoreCompatibilityService
in package
uses LocatorAwareTrait

Reconciles current-version derived/config data after a logical restore.

Schema migrations cannot safely be rerun after restoring old rows into a newer schema because Phinx sees the target schema as already migrated. This service keeps idempotent data repair steps close to restore instead.

Table of Contents

Constants

AWARDS_APPROVAL_NODE_ID  : mixed = 'award-approval-gate'
AWARDS_EXISTING_RECOMMENDATION_WORKFLOW_SLUG  : mixed = 'awards-existing-recommendation-approval'
AWARDS_RECOMMENDATION_ENTITY_TYPE  : mixed = 'Awards.Recommendations'
PRINCIPALITY_AWARD_DOMAIN_ID  : mixed = 11
RESTORE_MIGRATION_MARKER  : mixed = 'BackupRestoreCompatibilityService'

Properties

$container  : ContainerInterface|null

Methods

__construct()  : mixed
reconcile()  : array<string, int>
backfillBestowalReasonSummaries()  : array{bestowal_reason_summaries_backfilled: int}
backfillBestowalsFromRecommendations()  : array{bestowals_backfilled: int, bestowal_recommendation_links_backfilled: int}
backfillBestowalSpecialties()  : array{bestowal_specialties_backfilled: int}
backfillSubmittedRecommendationApprovalWorkflows()  : array{award_approval_workflows_backfilled: int}
Recreate current approval workflow state for restored baseline recommendations that were still awaiting award approval.
backfillWarrantRosterApprovalWorkflows()  : array{warrant_roster_approval_workflows_backfilled: int}
Recreate workflow approval rows for legacy warrant roster approvals.
countBackupMigrationLogTables()  : int
countLegacyBackupTables()  : int
countRows()  : int
Count rows in a trusted application table.
createApplicationContainer()  : ContainerInterface
Build the minimal application service container and workflow registries needed during restore.
createWorkflowExecutionLog()  : WorkflowExecutionLog
Create one workflow execution log row for a rebuilt approval workflow.
createWorkflowTriggerDispatcher()  : TriggerDispatcher
Create a workflow trigger dispatcher for restore-time lifecycle replays.
currentWorkflowVersionMatches()  : bool
filterColumns()  : array<string, mixed>
formatAwardRecommendationLifecycleErrors()  : string
Build a concise sample of record-level lifecycle migration failures.
hasColumns()  : bool
hasTables()  : bool
isMigrationLogTable()  : bool
Return true for core/plugin migration log tables.
lookupOptionalId()  : int|null
nextWorkflowVersionNumber()  : int
Return the next publishable workflow version number.
normalizeBool()  : bool
Normalize database boolean representations.
payloadHasAnyTables()  : bool
replaceAwardApprovalProcessSteps()  : void
reportProgress()  : void
rewriteWorkflowInstanceEntityType()  : void
Rewrite restored workflow entity metadata without invalidating active uniqueness keys.
runAwardRecommendationLifecycleMigration()  : array<string, int>
Mirror the dev seeded reset lifecycle migration after restore.
seedBaselineAwardApprovalProcesses()  : array{award_approval_processes_seeded: int}
Replay default award approval-process seed data for baseline backups that predate those tables. Backups that contain approval-process tables stay authoritative, even when they intentionally contain no process rows.
seedBestowalReferenceData()  : array{bestowal_reference_seeded: int}
syncWorkflowDefinitions()  : array{workflow_definitions_created: int, workflow_versions_published: int}
Ensure workflow definitions point at current JSON definitions.
tableColumns()  : array<int, string>
upsertAwardApprovalProcess()  : int
Insert or reactivate one default award approval process.
workflowDefinitionId()  : int|null
Find a workflow definition by slug.
workflowVersionId()  : int|null
Find a workflow version by definition and version number.

Constants

AWARDS_EXISTING_RECOMMENDATION_WORKFLOW_SLUG

private mixed AWARDS_EXISTING_RECOMMENDATION_WORKFLOW_SLUG = 'awards-existing-recommendation-approval'

Properties

Methods

__construct()

public __construct([ContainerInterface|null $container = null ]) : mixed
Parameters
$container : ContainerInterface|null = null

Optional container for restore-time workflow execution.

reconcile()

public reconcile(Connection $connection, array<string, mixed> $payload[, callable(array<string, mixed>): void|null $progressReporter = null ]) : array<string, int>
Parameters
$connection : Connection
$payload : array<string, mixed>

Decoded backup payload.

$progressReporter : callable(array<string, mixed>): void|null = null
Return values
array<string, int>

backfillBestowalReasonSummaries()

private backfillBestowalReasonSummaries(Connection $connection) : array{bestowal_reason_summaries_backfilled: int}
Parameters
$connection : Connection
Return values
array{bestowal_reason_summaries_backfilled: int}

backfillBestowalsFromRecommendations()

private backfillBestowalsFromRecommendations(Connection $connection) : array{bestowals_backfilled: int, bestowal_recommendation_links_backfilled: int}
Parameters
$connection : Connection
Return values
array{bestowals_backfilled: int, bestowal_recommendation_links_backfilled: int}

backfillBestowalSpecialties()

private backfillBestowalSpecialties(Connection $connection) : array{bestowal_specialties_backfilled: int}
Parameters
$connection : Connection
Return values
array{bestowal_specialties_backfilled: int}

backfillSubmittedRecommendationApprovalWorkflows()

Recreate current approval workflow state for restored baseline recommendations that were still awaiting award approval.

private backfillSubmittedRecommendationApprovalWorkflows(Connection $connection) : array{award_approval_workflows_backfilled: int}
Parameters
$connection : Connection
Return values
array{award_approval_workflows_backfilled: int}

backfillWarrantRosterApprovalWorkflows()

Recreate workflow approval rows for legacy warrant roster approvals.

private backfillWarrantRosterApprovalWorkflows(Connection $connection) : array{warrant_roster_approval_workflows_backfilled: int}

The original migration drops warrant_roster_approvals after copying it to workflow tables. During logical restore, Phinx can see the migration as already applied while the restored payload still contains the legacy source table, so restore must replay the data move idempotently.

Parameters
$connection : Connection
Return values
array{warrant_roster_approval_workflows_backfilled: int}

countBackupMigrationLogTables()

private countBackupMigrationLogTables(array<string, mixed> $payload) : int
Parameters
$payload : array<string, mixed>

Decoded backup payload.

Return values
int

countLegacyBackupTables()

private countLegacyBackupTables(Connection $connection, array<string, mixed> $payload) : int
Parameters
$connection : Connection
$payload : array<string, mixed>

Decoded backup payload.

Return values
int

countRows()

Count rows in a trusted application table.

private countRows(Connection $connection, string $tableName) : int
Parameters
$connection : Connection
$tableName : string
Return values
int

createApplicationContainer()

Build the minimal application service container and workflow registries needed during restore.

private createApplicationContainer() : ContainerInterface
Return values
ContainerInterface

createWorkflowExecutionLog()

Create one workflow execution log row for a rebuilt approval workflow.

private createWorkflowExecutionLog(Table $logs, int $workflowInstanceId, string $nodeId, string $nodeType, string $status, mixed $inputData, mixed $outputData, DateTime $startedAt, DateTime|null $completedAt) : WorkflowExecutionLog
Parameters
$logs : Table
$workflowInstanceId : int
$nodeId : string
$nodeType : string
$status : string
$inputData : mixed
$outputData : mixed
$startedAt : DateTime
$completedAt : DateTime|null
Return values
WorkflowExecutionLog

currentWorkflowVersionMatches()

private currentWorkflowVersionMatches(Connection $connection, int $definitionId, array<string, mixed> $definition, array<string, mixed> $meta) : bool
Parameters
$connection : Connection
$definitionId : int
$definition : array<string, mixed>
$meta : array<string, mixed>
Return values
bool

filterColumns()

private filterColumns(array<string, mixed> $values, array<int, string> $columns) : array<string, mixed>
Parameters
$values : array<string, mixed>
$columns : array<int, string>
Return values
array<string, mixed>

formatAwardRecommendationLifecycleErrors()

Build a concise sample of record-level lifecycle migration failures.

private formatAwardRecommendationLifecycleErrors(Connection $connection, int $runId) : string
Parameters
$connection : Connection
$runId : int
Return values
string

hasColumns()

private hasColumns(Connection $connection, string $tableName, array<int, string> $columnNames) : bool
Parameters
$connection : Connection
$tableName : string
$columnNames : array<int, string>
Return values
bool

hasTables()

private hasTables(Connection $connection, array<int, string> $tableNames) : bool
Parameters
$connection : Connection
$tableNames : array<int, string>
Return values
bool

isMigrationLogTable()

Return true for core/plugin migration log tables.

private isMigrationLogTable(string $tableName) : bool
Parameters
$tableName : string
Return values
bool

lookupOptionalId()

private lookupOptionalId(Connection $connection, string $sql, array<int, mixed> $params) : int|null
Parameters
$connection : Connection
$sql : string
$params : array<int, mixed>
Return values
int|null

nextWorkflowVersionNumber()

Return the next publishable workflow version number.

private nextWorkflowVersionNumber(Connection $connection, int $definitionId) : int
Parameters
$connection : Connection
$definitionId : int
Return values
int

normalizeBool()

Normalize database boolean representations.

private normalizeBool(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

payloadHasAnyTables()

private payloadHasAnyTables(array<string, mixed> $payload, array<int, string> $tableNames) : bool
Parameters
$payload : array<string, mixed>

Decoded backup payload.

$tableNames : array<int, string>
Return values
bool

replaceAwardApprovalProcessSteps()

private replaceAwardApprovalProcessSteps(Connection $connection, int $processId, array<int, array<string, mixed>> $steps) : void
Parameters
$connection : Connection
$processId : int
$steps : array<int, array<string, mixed>>

reportProgress()

private reportProgress(callable(array<string, mixed>): void|null $progressReporter, string $phase, string $message[, array<string, mixed> $context = [] ]) : void
Parameters
$progressReporter : callable(array<string, mixed>): void|null
$phase : string
$message : string
$context : array<string, mixed> = []

rewriteWorkflowInstanceEntityType()

Rewrite restored workflow entity metadata without invalidating active uniqueness keys.

private rewriteWorkflowInstanceEntityType(Connection $connection, string $workflowSlug, string $oldEntityType, string $newEntityType) : void
Parameters
$connection : Connection
$workflowSlug : string
$oldEntityType : string
$newEntityType : string

runAwardRecommendationLifecycleMigration()

Mirror the dev seeded reset lifecycle migration after restore.

private runAwardRecommendationLifecycleMigration(Connection $connection) : array<string, int>

This replays awards migrate_award_recommendations --apply --allow-open-manual-review so restored legacy recommendations are moved into closed, bestowal, approval-workflow, or manual-review ownership even when that work was originally captured outside a Phinx migration.

Parameters
$connection : Connection
Return values
array<string, int>

seedBaselineAwardApprovalProcesses()

Replay default award approval-process seed data for baseline backups that predate those tables. Backups that contain approval-process tables stay authoritative, even when they intentionally contain no process rows.

private seedBaselineAwardApprovalProcesses(Connection $connection, array<string, mixed> $payload) : array{award_approval_processes_seeded: int}
Parameters
$connection : Connection
$payload : array<string, mixed>

Decoded backup payload.

Return values
array{award_approval_processes_seeded: int}

seedBestowalReferenceData()

private seedBestowalReferenceData(Connection $connection) : array{bestowal_reference_seeded: int}
Parameters
$connection : Connection
Return values
array{bestowal_reference_seeded: int}

syncWorkflowDefinitions()

Ensure workflow definitions point at current JSON definitions.

private syncWorkflowDefinitions(Connection $connection) : array{workflow_definitions_created: int, workflow_versions_published: int}
Parameters
$connection : Connection
Return values
array{workflow_definitions_created: int, workflow_versions_published: int}

tableColumns()

private tableColumns(Connection $connection, string $tableName) : array<int, string>
Parameters
$connection : Connection
$tableName : string
Return values
array<int, string>

upsertAwardApprovalProcess()

Insert or reactivate one default award approval process.

private upsertAwardApprovalProcess(Connection $connection, string $name, string $description) : int
Parameters
$connection : Connection
$name : string
$description : string
Return values
int

workflowDefinitionId()

Find a workflow definition by slug.

private workflowDefinitionId(Connection $connection, string $slug) : int|null
Parameters
$connection : Connection
$slug : string
Return values
int|null

workflowVersionId()

Find a workflow version by definition and version number.

private workflowVersionId(Connection $connection, int $definitionId, int $versionNumber) : int|null
Parameters
$connection : Connection
$definitionId : int
$versionNumber : int
Return values
int|null
On this page

Search results