SchemaMigrator

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

Internal

Table of Contents

Methods

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

Methods

getSchemaDiffs()

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

public getSchemaDiffs(array<string|int, mixed> $statements) : array<string, SchemaDiff>
Parameters
$statements : array<string|int, mixed>
Tags
throws
Exception
throws
SchemaException
throws
InvalidArgumentException
throws
RuntimeException
throws
UnexpectedSignalReturnValueTypeException
throws
StatementException
Return values
array<string, SchemaDiff>

getUpdateSuggestions()

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

public getUpdateSuggestions(array<string|int, string> $statements[, bool $remove = false ]) : array<string, array<string|int, mixed>>
Parameters
$statements : array<string|int, 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<string, array<string|int, mixed>>

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

importStaticData()

Import static data (INSERT statements)

public importStaticData(array<string|int, mixed> $statements[, bool $truncate = false ]) : array<string|int, mixed>
Parameters
$statements : array<string|int, mixed>
$truncate : bool = false
Return values
array<string|int, mixed>

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(array<string|int, string> $statements[, bool $createOnly = false ]) : array<string, string>
Parameters
$statements : array<string|int, 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<string, string>

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(array<string|int, string> $statements, array<string|int, string> $selectedStatements) : array<string|int, mixed>
Parameters
$statements : array<string|int, string>

The CREATE TABLE statements

$selectedStatements : array<string|int, 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<string|int, mixed>

parseCreateTableStatements()

Parse CREATE TABLE statements into Doctrine Table objects.

public parseCreateTableStatements(array<string|int, string> $statements) : array<string|int, Table>
Parameters
$statements : array<string|int, string>

The SQL CREATE TABLE statements

Tags
throws
SchemaException
throws
InvalidArgumentException
throws
RuntimeException
throws
StatementException
throws
UnexpectedSignalReturnValueTypeException
Return values
array<string|int, 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(array<string|int, Table$tables, Connection $connection) : void
Parameters
$tables : array<string|int, Table>
$connection : Connection
Tags
see
https://github.com/doctrine/dbal/commit/33555d36e7e7d07a5880e01

        
On this page

Search results