SchemaMigrator
Helper methods to handle SQL files and transform them into individual statements for further processing.
not part of public core API.
Table of Contents
Methods
- __construct() : mixed
- 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.
- 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.
- enrichTablesFromDefaultTCASchema() : array<non-empty-string, Table>
- ensureDefaultTCAFieldsAreOrdered() : array<non-empty-string, Table>
- Ensure the default TCA fields are ordered.
- ensureTableDefinitionForAllTCAManagedTables() : array<string|int, Table>
- Ensure we have a table definition for all tables within TCA, add missing ones as "empty" tables without columns. This is needed for DefaultTcaSchema: It goes through TCA to add columns automatically, but needs a table definition of all TCA tables. We're not doing this in DefaultTcaSchema to not introduce a dependency to the Parser class in there, which we have here so conveniently already.
- flushDatabaseSchemaCache() : void
- getPrioritizedFieldNames() : array<string|int, string>
- Have fields triggered by 'ctrl' settings first in the list. This is done for cosmetic reasons to improve readability of db schema when opening tables in a database browser.
- parseCreateTableStatements() : array<non-empty-string, Table>
- Parse CREATE TABLE statements into Doctrine Table objects.
- prepareTablesFromStatements() : array<string|int, Table>
Methods
__construct()
public
__construct(ConnectionPool $connectionPool, Parser $parser, DefaultTcaSchema $defaultTcaSchema) : mixed
Parameters
- $connectionPool : ConnectionPool
- $parser : Parser
- $defaultTcaSchema : DefaultTcaSchema
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
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
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.
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
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
Return values
array<string|int, mixed>enrichTablesFromDefaultTCASchema()
protected
enrichTablesFromDefaultTCASchema(array<non-empty-string, Table> $tables) : array<non-empty-string, Table>
Parameters
- $tables : array<non-empty-string, Table>
Return values
array<non-empty-string, Table>ensureDefaultTCAFieldsAreOrdered()
Ensure the default TCA fields are ordered.
protected
ensureDefaultTCAFieldsAreOrdered(array<non-empty-string, Table> $tables) : array<non-empty-string, Table>
Parameters
- $tables : array<non-empty-string, Table>
Return values
array<non-empty-string, Table>ensureTableDefinitionForAllTCAManagedTables()
Ensure we have a table definition for all tables within TCA, add missing ones as "empty" tables without columns. This is needed for DefaultTcaSchema: It goes through TCA to add columns automatically, but needs a table definition of all TCA tables. We're not doing this in DefaultTcaSchema to not introduce a dependency to the Parser class in there, which we have here so conveniently already.
protected
ensureTableDefinitionForAllTCAManagedTables(array<string|int, Table> $tables) : array<string|int, Table>
Parameters
- $tables : array<string|int, Table>
Tags
Return values
array<string|int, Table>flushDatabaseSchemaCache()
protected
flushDatabaseSchemaCache() : void
getPrioritizedFieldNames()
Have fields triggered by 'ctrl' settings first in the list. This is done for cosmetic reasons to improve readability of db schema when opening tables in a database browser.
protected
getPrioritizedFieldNames(string $tableName) : array<string|int, string>
Parameters
- $tableName : string
Return values
array<string|int, string>parseCreateTableStatements()
Parse CREATE TABLE statements into Doctrine Table objects.
protected
parseCreateTableStatements(array<string|int, string> $statements) : array<non-empty-string, Table>
Parameters
- $statements : array<string|int, string>
-
The SQL CREATE TABLE statements
Tags
Return values
array<non-empty-string, Table>prepareTablesFromStatements()
protected
prepareTablesFromStatements(array<string|int, string> $statements) : array<string|int, Table>
Parameters
- $statements : array<string|int, string>