TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
SchemaMigrator Class Reference

Public Member Functions

 getUpdateSuggestions (array $statements, bool $remove=false)
 
 getSchemaDiffs (array $statements)
 
 migrate (array $statements, array $selectedStatements)
 
 install (array $statements, bool $createOnly=false)
 
 importStaticData (array $statements, bool $truncate=false)
 
 parseCreateTableStatements (array $statements)
 

Protected Attributes

 $schema = []
 

Detailed Description

Helper methods to handle SQL files and transform them into individual statements for further processing.

Definition at line 33 of file SchemaMigrator.php.

Member Function Documentation

getSchemaDiffs ( array  $statements)

Return the raw Doctrine SchemaDiff objects for each connection. This diff contains all changes without any pre-processing.

Parameters
array$statements
Returns
SchemaDiff[]
Exceptions
Doctrine
Doctrine
InvalidArgumentException
RuntimeException
TYPO3
TYPO3
TYPO3
StatementException

Definition at line 91 of file SchemaMigrator.php.

References ConnectionMigrator\create(), GeneralUtility\makeInstance(), and SchemaMigrator\parseCreateTableStatements().

getUpdateSuggestions ( array  $statements,
bool  $remove = false 
)

Compare current and expected schema definitions and provide updates suggestions in the form of SQL statements.

Parameters
string[]$statements The CREATE TABLE statements
bool$removeTRUE for RENAME/DROP table and column suggestions, FALSE for ADD/CHANGE suggestions
Returns
array[] SQL statements to migrate the database to the expected schema, indexed by performed operation
Exceptions
Doctrine
Doctrine
InvalidArgumentException
RuntimeException
TYPO3
TYPO3
TYPO3
StatementException

Definition at line 56 of file SchemaMigrator.php.

References ConnectionMigrator\create(), GeneralUtility\makeInstance(), and SchemaMigrator\parseCreateTableStatements().

Referenced by SchemaMigrator\migrate().

importStaticData ( array  $statements,
bool  $truncate = false 
)

Import static data (INSERT statements)

Parameters
array$statements
bool$truncate
Returns
array

Definition at line 198 of file SchemaMigrator.php.

References GeneralUtility\makeInstance().

install ( array  $statements,
bool  $createOnly = false 
)

Perform add/change/create operations on tables and fields in an optimized, non-interactive, mode using the original doctrine SchemaManager ->toSaveSql() method.

Parameters
string[]$statements The CREATE TABLE statements
bool$createOnlyOnly perform changes that add fields or create tables
Returns
array[] Error messages for statements that occurred during the installation procedure.
Exceptions
Doctrine
Doctrine
InvalidArgumentException
RuntimeException
TYPO3
TYPO3
TYPO3
StatementException

Definition at line 172 of file SchemaMigrator.php.

References ConnectionMigrator\create(), GeneralUtility\makeInstance(), and SchemaMigrator\parseCreateTableStatements().

migrate ( array  $statements,
array  $selectedStatements 
)

This method executes statements from the update suggestions, or a subset of them filtered by the statements hashes, one by one.

Parameters
string[]$statements The CREATE TABLE statements
string[]$selectedStatements The hashes of the update suggestions to execute
Returns
array
Exceptions
Doctrine
Doctrine
InvalidArgumentException
TYPO3
TYPO3
TYPO3
StatementException
RuntimeException

Definition at line 125 of file SchemaMigrator.php.

References SchemaMigrator\getUpdateSuggestions(), and GeneralUtility\makeInstance().

parseCreateTableStatements ( array  $statements)

Parse CREATE TABLE statements into Doctrine Table objects.

Parameters
string[]$statements The SQL CREATE TABLE statements
Returns
Table[]
Exceptions
Doctrine
InvalidArgumentException
RuntimeException
TYPO3
TYPO3
TYPO3
TYPO3

Definition at line 250 of file SchemaMigrator.php.

References GeneralUtility\makeInstance().

Referenced by SchemaMigrator\getSchemaDiffs(), SchemaMigrator\getUpdateSuggestions(), and SchemaMigrator\install().

Member Data Documentation

$schema = []
protected

Definition at line 38 of file SchemaMigrator.php.