Contentserv PHP API

CSMigration
in package

Tags

Table of Contents

EXCEPTION_DUPLICATE_SCRIPT_WITH_TYPE  = 60000
Defines the error codes for migration exceptions.
EXCEPTION_INVALID_PARAMETER  = 60001
EXECUTION_TYPE_AFTER_UPDATE_DATA_MODEL  = 1
EXECUTION_TYPE_BEFORE_UPDATE_DATA_MODEL  = 0
Defines the available execution types of migration scripts.
RESULT_TYPE_FAILURE  = 1
RESULT_TYPE_SUCCESS  = 0
Defines the possible result types of the migration result.
createResult()  : CSMigrationResult
Create the migration result object, which have to be returned after the execution of the migration logic.
createScript()  : CSMigrationScript
Initializes a migration script.
deleteScriptExecutions()  : void
Deletes entries of script executions for the given version and class id.
deleteScriptExecutionsForScript()  : void
Deletes entries of script executions for the given migration script.
getScripts()  : array<string|int, CSMigrationScript>
Returns all available migration scripts for all modules.
getScriptsForModule()  : array<string|int, CSMigrationScript>
Returns all migration scripts for the given module.
getScriptsForModuleName()  : array<string|int, CSMigrationScript>
Returns all migration scripts for the given module name.
hasScriptExecution()  : bool
Checks if a migration script has been already executed.
setScriptExecution()  : void
Sets the new script execution for the given migration script.
throwError()  : void
Throws an exception for the migration handling.

Constants

EXCEPTION_DUPLICATE_SCRIPT_WITH_TYPE

Defines the error codes for migration exceptions.

public int EXCEPTION_DUPLICATE_SCRIPT_WITH_TYPE = 60000
Tags

EXCEPTION_INVALID_PARAMETER

public mixed EXCEPTION_INVALID_PARAMETER = 60001
Tags

EXECUTION_TYPE_AFTER_UPDATE_DATA_MODEL

public mixed EXECUTION_TYPE_AFTER_UPDATE_DATA_MODEL = 1
Tags

EXECUTION_TYPE_BEFORE_UPDATE_DATA_MODEL

Defines the available execution types of migration scripts.

public int EXECUTION_TYPE_BEFORE_UPDATE_DATA_MODEL = 0
Tags

RESULT_TYPE_FAILURE

public mixed RESULT_TYPE_FAILURE = 1
Tags

RESULT_TYPE_SUCCESS

Defines the possible result types of the migration result.

public int RESULT_TYPE_SUCCESS = 0
Tags

Methods

createResult()

Create the migration result object, which have to be returned after the execution of the migration logic.

public static createResult(int $iResultType) : CSMigrationResult
Parameters
$iResultType : int

The return type of the migration result. Please use the constants CSMigration::RESULT_TYPE_*

Tags
Return values
CSMigrationResult

createScript()

Initializes a migration script.

public static createScript(string $sMigrationName, array<string|int, mixed> $aTargetRecordNames[, int $iExecutionType = CSMigration::EXECUTION_TYPE_AFTER_UPDATE_DATA_MODEL ]) : CSMigrationScript
Parameters
$sMigrationName : string

The unique name of the migration script.

$aTargetRecordNames : array<string|int, mixed>

The target record class names of the migration script. These record class names are used to store the script execution in the database.

$iExecutionType : int = CSMigration::EXECUTION_TYPE_AFTER_UPDATE_DATA_MODEL

The target execution type of the migration script. Please use the constants CSMigration::EXECUTION_TYPE_*

Tags
Return values
CSMigrationScript

deleteScriptExecutions()

Deletes entries of script executions for the given version and class id.

public static deleteScriptExecutions(string $sVersion[, int|null $iClassId = null ]) : void

It deletes entries with a higher version number and the same class id.

Parameters
$sVersion : string

The target version (e.g. CS22.6)

$iClassId : int|null = null

The target class id

Tags
Return values
void

deleteScriptExecutionsForScript()

Deletes entries of script executions for the given migration script.

public static deleteScriptExecutionsForScript(CSMigrationScript $oMigrationScript) : void

@param CSMigrationScript $oMigrationScript

Parameters
$oMigrationScript : CSMigrationScript
Tags
Return values
void

getScripts()

Returns all available migration scripts for all modules.

public static getScripts() : array<string|int, CSMigrationScript>
Tags
throws
CSException

if duplicate script with the same name occurs.

Return values
array<string|int, CSMigrationScript>

getScriptsForModule()

Returns all migration scripts for the given module.

public static getScriptsForModule(CSModule $oModule) : array<string|int, CSMigrationScript>
Parameters
$oModule : CSModule

The target module to receive all the migration scripts of this module.

Tags
throws
CSException

if duplicate script with the same name occurs.

Return values
array<string|int, CSMigrationScript>

getScriptsForModuleName()

Returns all migration scripts for the given module name.

public static getScriptsForModuleName(string $sModuleName) : array<string|int, CSMigrationScript>
Parameters
$sModuleName : string

The target module name to receive all the migration scripts of this module.

Tags
throws
CSException

if duplicate script with the same name occurs.

Return values
array<string|int, CSMigrationScript>

hasScriptExecution()

Checks if a migration script has been already executed.

public static hasScriptExecution(CSMigrationScript $oMigrationScript) : bool

Only if all defined target record names of the migration script have been executed, the method returns true.

Parameters
$oMigrationScript : CSMigrationScript

The migration script, which should be checked for the execution.

Tags
Return values
bool

setScriptExecution()

Sets the new script execution for the given migration script.

public static setScriptExecution(CSMigrationScript $oMigrationScript) : void

It generates for each target record name in the migration script a separate entry.

Parameters
$oMigrationScript : CSMigrationScript

The migration script, which should be used to set the script execution.

Tags
Return values
void

throwError()

Throws an exception for the migration handling.

public static throwError(string $sMessage, int $iCode) : void
Parameters
$sMessage : string

The message of the exception

$iCode : int

The code of the exception.

Tags
throws
CSException
Return values
void

        

Search results