SchemaMigrator
Helper methods to handle SQL files and transform them into individual statements for further processing.
Table of Contents
Properties
- $schema : array<string|int, Schema>
Methods
- getSchemaDiffs() : array<string|int, SchemaDiff>
- Return the raw Doctrine SchemaDiff objects for each connection. This diff contains all changes without any pre-processing.
- getUpdateSuggestions() : array<string|int, 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|int, array<string|int, mixed>>
- 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.
Properties
$schema
protected
array<string|int, Schema>
$schema
= []
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|int, SchemaDiff>
Parameters
- $statements : array<string|int, mixed>
Tags
Return values
array<string|int, 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|int, 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
Return values
array<string|int, 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|int, array<string|int, mixed>>
Parameters
- $statements : array<string|int, string>
-
The CREATE TABLE statements
- $createOnly : bool = false
-
Only perform changes that add fields or create tables
Tags
Return values
array<string|int, array<string|int, mixed>> —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
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
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