CRM_Upgrade_Snapshot
in package
Provide helpers for recording data snapshots during an upgrade.
Table of Contents
Properties
- $cleanupAfter : int
- How long should we retain old snapshots?
- $pageSize : mixed
- $activationIssues : array<string|int, mixed>|null
- List of reasons why the snapshots are not running.
Methods
- cleanupTask() : bool
- Cleanup any old snapshot tables.
- createSingleTask() : array<string|int, string>
- Generate the query/queries for storing a snapshot (if the local policy supports snapshotting).
- createTableName() : string
- Create the name of a MySQL snapshot table.
- createTasks() : iterable<string|int, mixed>
- Build a set of queueable tasks which will store a snapshot.
- getActivationIssues() : array<string|int, mixed>
- Get a list of reasons why the snapshots should not run.
- insertSnapshotTask() : bool
Properties
$cleanupAfter
How long should we retain old snapshots?
public
static int
$cleanupAfter
= 4
Time is measured in terms of MINOR versions - eg "4" means "retain for 4 MINOR versions". Thus, on v5.60, you could delete any snapshots predating 5.56.
$pageSize
public
static mixed
$pageSize
= 50 * 1000
$activationIssues
List of reasons why the snapshots are not running.
private
static array<string|int, mixed>|null
$activationIssues
Methods
cleanupTask()
Cleanup any old snapshot tables.
public
static cleanupTask([CRM_Queue_TaskContext|null $ctx = NULL ][, string $owner = 'civicrm' ][, string|null $version = NULL ][, int|null $cleanupAfter = NULL ]) : bool
Parameters
- $ctx : CRM_Queue_TaskContext|null = NULL
- $owner : string = 'civicrm'
-
Ex: 'civicrm', 'sequentialcreditnotes', 'oauth_client'
- $version : string|null = NULL
-
The current version of CiviCRM.
- $cleanupAfter : int|null = NULL
-
How long should we retain old snapshots? Time is measured in terms of MINOR versions - eg "4" means "retain for 4 MINOR versions". Thus, on v5.60, you could delete any snapshots predating 5.56.
Tags
Return values
boolcreateSingleTask()
Generate the query/queries for storing a snapshot (if the local policy supports snapshotting).
public
static createSingleTask(string $owner, string $version, string $name, string $select) : array<string|int, string>
This method does all updates in one go. It is suitable for small/moderate data-sets. If you need to support larger data-sets, use createTasks() instead.
Parameters
- $owner : string
-
Name of the component/module/extension that owns the snapshot. Ex: 'civicrm'
- $version : string
-
Ex: '5.50'
- $name : string
- $select : string
-
Raw SQL SELECT for finding data.
Tags
Return values
array<string|int, string> —SQL statements to execute. May be array if there no statements to execute.
createTableName()
Create the name of a MySQL snapshot table.
public
static createTableName(string $owner, string $version, string $name) : string
Parameters
- $owner : string
-
Name of the component/module/extension that owns the snapshot. Ex: 'civicrm', 'sequentialcreditnotes', 'oauth_client'
- $version : string
-
Ex: '5.50'
- $name : string
-
Ex: 'dates'
Tags
Return values
string —Ex: 'snap_civicrm_v5_50_dates'
createTasks()
Build a set of queueable tasks which will store a snapshot.
public
static createTasks(string $owner, string $version, string $name, CRM_Utils_SQL_Select $select) : iterable<string|int, mixed>
Parameters
- $owner : string
-
Name of the component/module/extension that owns the snapshot. Ex: 'civicrm', 'sequentialcreditnotes', 'oauth_client'
- $version : string
-
Ex: '5.50'
- $name : string
- $select : CRM_Utils_SQL_Select
Tags
Return values
iterable<string|int, mixed>getActivationIssues()
Get a list of reasons why the snapshots should not run.
public
static getActivationIssues() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of printable messages.
insertSnapshotTask()
public
static insertSnapshotTask(CRM_Queue_TaskContext $ctx, string $sql) : bool
Parameters
- $ctx : CRM_Queue_TaskContext
- $sql : string