SchemaMigrator

class \TYPO3\CMS\Core\Database\Schema\SchemaMigrator

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

Table of Contents

Properties

$schema  : Schema[]

Methods

getSchemaDiffs()  : SchemaDiff[]
Return the raw Doctrine SchemaDiff objects for each connection. This diff contains all changes without any pre-processing.
getUpdateSuggestions()  : array[]
Compare current and expected schema definitions and provide updates suggestions in the form of SQL statements.
importStaticData()  : array
Import static data (INSERT statements)
install()  : array[]
Perform add/change/create operations on tables and fields in an optimized, non-interactive, mode using the original doctrine SchemaManager ->toSaveSql() method.
migrate()  : array
This method executes statements from the update suggestions, or a subset of them filtered by the statements hashes, one by one.
parseCreateTableStatements()  : Table[]
Parse CREATE TABLE statements into Doctrine Table objects.
adoptDoctrineAutoincrementDetectionForSqlite()  : void
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.

Properties

Methods

getSchemaDiffs()

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

public getSchemaDiffs(array $statements) : SchemaDiff[]

Parameters

$statements : array

Tags

throws
Exception
throws
SchemaException
throws
InvalidArgumentException
throws
RuntimeException
throws
UnexpectedSignalReturnValueTypeException
throws
StatementException

Return values

SchemaDiff[]

getUpdateSuggestions()

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

public getUpdateSuggestions(string[] $statements[, bool $remove = false ]) : array[]

Parameters

$statements : string[]

The CREATE TABLE statements

$remove : bool = false

TRUE for RENAME/DROP table and column suggestions, FALSE for ADD/CHANGE suggestions

Tags

throws
Exception
throws
SchemaException
throws
InvalidArgumentException
throws
RuntimeException
throws
UnexpectedSignalReturnValueTypeException
throws
StatementException

Return values

array[] —

SQL statements to migrate the database to the expected schema, indexed by performed operation

importStaticData()

Import static data (INSERT statements)

public importStaticData(array $statements[, bool $truncate = false ]) : array

Parameters

$statements : array
$truncate : bool = false

Return values

array

install()

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

public install(string[] $statements[, bool $createOnly = false ]) : array[]

Parameters

$statements : string[]

The CREATE TABLE statements

$createOnly : bool = false

Only perform changes that add fields or create tables

Tags

throws
Exception
throws
SchemaException
throws
InvalidArgumentException
throws
RuntimeException
throws
UnexpectedSignalReturnValueTypeException
throws
StatementException

Return values

array[] —

Error messages for statements that occurred during the installation procedure.

migrate()

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

public migrate(string[] $statements, string[] $selectedStatements) : array

Parameters

$statements : string[]

The CREATE TABLE statements

$selectedStatements : string[]

The hashes of the update suggestions to execute

Tags

throws
Exception
throws
SchemaException
throws
InvalidArgumentException
throws
UnexpectedSignalReturnValueTypeException
throws
StatementException
throws
RuntimeException

Return values

array

parseCreateTableStatements()

Parse CREATE TABLE statements into Doctrine Table objects.

public parseCreateTableStatements(string[] $statements) : Table[]

Parameters

$statements : string[]

The SQL CREATE TABLE statements

Tags

throws
SchemaException
throws
InvalidArgumentException
throws
RuntimeException
throws
StatementException
throws
UnexpectedSignalReturnValueTypeException

Return values

Table[]

adoptDoctrineAutoincrementDetectionForSqlite()

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.

protected adoptDoctrineAutoincrementDetectionForSqlite(Table[] $tables, Connection $connection) : void

Parameters

$tables : Table[]
$connection : Connection

Tags

see
https://github.com/doctrine/dbal/commit/33555d36e7e7d07a5880e01
On this page