‪TYPO3CMS  11.5
TYPO3\CMS\Core\Database\Schema\SchemaMigrator Class Reference

Public Member Functions

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

Protected Member Functions

 adoptDoctrineAutoincrementDetectionForSqlite (array $tables, Connection $connection)
 

Protected Attributes

Schema[] $schema = array( )
 

Detailed Description

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

Definition at line 38 of file SchemaMigrator.php.

Member Function Documentation

◆ adoptDoctrineAutoincrementDetectionForSqlite()

TYPO3\CMS\Core\Database\Schema\SchemaMigrator::adoptDoctrineAutoincrementDetectionForSqlite ( array  $tables,
Connection  $connection 
)
protected

doctrine/dbal detects both sqlite autoincrement variants (row_id alias and autoincrement) through assumptions which have been made. TYPO3 reads the ext_tables.sql files as MySQL/MariaDB variant, thus not setting the autoincrement value to true for the row_id alias variant, which leads to an endless missmatch during database comparison. This method adopts the doctrine/dbal assumption and apply it to the meta schema to mitigate endless database compare detections in these cases.

See also
https://github.com/doctrine/dbal/commit/33555d36e7e7d07a5880e01
Parameters
Table[]$tables

Definition at line 314 of file SchemaMigrator.php.

References if.

Referenced by TYPO3\CMS\Core\Database\Schema\SchemaMigrator\getUpdateSuggestions().

◆ getSchemaDiffs()

SchemaDiff [] TYPO3\CMS\Core\Database\Schema\SchemaMigrator::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

Definition at line 92 of file SchemaMigrator.php.

References TYPO3\CMS\Core\Database\Schema\ConnectionMigrator\create(), and TYPO3\CMS\Core\Database\Schema\SchemaMigrator\parseCreateTableStatements().

◆ getUpdateSuggestions()

array [] TYPO3\CMS\Core\Database\Schema\SchemaMigrator::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$remove‪TRUE 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

Definition at line 58 of file SchemaMigrator.php.

References TYPO3\CMS\Core\Database\Schema\SchemaMigrator\adoptDoctrineAutoincrementDetectionForSqlite(), TYPO3\CMS\Core\Database\Schema\ConnectionMigrator\create(), and TYPO3\CMS\Core\Database\Schema\SchemaMigrator\parseCreateTableStatements().

Referenced by TYPO3\CMS\Core\Database\Schema\SchemaMigrator\migrate().

◆ importStaticData()

array TYPO3\CMS\Core\Database\Schema\SchemaMigrator::importStaticData ( array  $statements,
bool  $truncate = false 
)

Import static data (INSERT statements)

Parameters
array$statements
bool$truncate
Returns
‪array

Definition at line 195 of file SchemaMigrator.php.

◆ install()

array [] TYPO3\CMS\Core\Database\Schema\SchemaMigrator::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$createOnly‪Only perform changes that add fields or create tables
Returns
‪array[] Error messages for statements that occurred during the installation procedure.
Exceptions

Definition at line 169 of file SchemaMigrator.php.

References TYPO3\CMS\Core\Database\Schema\ConnectionMigrator\create(), and TYPO3\CMS\Core\Database\Schema\SchemaMigrator\parseCreateTableStatements().

◆ migrate()

array TYPO3\CMS\Core\Database\Schema\SchemaMigrator::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

Definition at line 124 of file SchemaMigrator.php.

References TYPO3\CMS\Core\Database\Schema\SchemaMigrator\getUpdateSuggestions().

◆ parseCreateTableStatements()

Table [] TYPO3\CMS\Core\Database\Schema\SchemaMigrator::parseCreateTableStatements ( array  $statements)

Parse CREATE TABLE statements into Doctrine Table objects.

Parameters
string[]$statements‪The SQL CREATE TABLE statements
Returns
‪Table[]
Exceptions

Definition at line 245 of file SchemaMigrator.php.

Referenced by TYPO3\CMS\Core\Database\Schema\SchemaMigrator\getSchemaDiffs(), TYPO3\CMS\Core\Database\Schema\SchemaMigrator\getUpdateSuggestions(), and TYPO3\CMS\Core\Database\Schema\SchemaMigrator\install().

Member Data Documentation

◆ $schema

Schema [] TYPO3\CMS\Core\Database\Schema\SchemaMigrator::$schema = array( )
protected

Definition at line 42 of file SchemaMigrator.php.