DatabaseSchemaResetService
in package
Recreates the database schema from a backup schema manifest.
Table of Contents
Methods
- reset() : void
- buildResetPlan() : array<string, array<int, mixed>>
- columnSql() : string
- columnsSql() : string
- columnTypeSql() : string
- createTableSql() : string
- decimalTypeSql() : string
- defaultSql() : string
- Format a column default expression for the target database.
- dropExistingTables() : void
- Drop all existing base tables from the current schema/database.
- foreignKeySql() : array<int, string>
- indexedColumns() : array<int, string>
- Return columns that need an index-compatible MySQL representation.
- indexIdentifier() : string
- Return an engine-safe index identifier unique to the table.
- indexPredicateSql() : string
- indexSql() : array<int, string>
- normalizeMysqlStringLiteralDefault() : string
- Strip MySQL character-set introducers captured by schema manifests.
- referentialActionSql() : string
- Validate and normalize a foreign key referential action.
- report() : void
Methods
reset()
public
reset(array<string, mixed> $manifest[, callable(array<string, mixed>): void|null $progressReporter = null ]) : void
Parameters
- $manifest : array<string, mixed>
- $progressReporter : callable(array<string, mixed>): void|null = null
buildResetPlan()
private
buildResetPlan(Mysql|Postgres $driver, array<string, mixed> $tables) : array<string, array<int, mixed>>
Parameters
- $driver : Mysql|Postgres
- $tables : array<string, mixed>
Return values
array<string, array<int, mixed>>columnSql()
private
columnSql(Mysql|Postgres $driver, string $columnName, array<string, mixed> $definition, bool $indexed) : string
Parameters
- $driver : Mysql|Postgres
- $columnName : string
- $definition : array<string, mixed>
- $indexed : bool
Return values
stringcolumnsSql()
private
columnsSql(Mysql|Postgres $driver, array<int, string> $columns) : string
Parameters
- $driver : Mysql|Postgres
- $columns : array<int, string>
Return values
stringcolumnTypeSql()
private
columnTypeSql(Mysql|Postgres $driver, string $type, array<string, mixed> $definition, bool $autoIncrement[, bool $indexed = false ]) : string
Parameters
- $driver : Mysql|Postgres
- $type : string
- $definition : array<string, mixed>
- $autoIncrement : bool
- $indexed : bool = false
Return values
stringcreateTableSql()
private
createTableSql(Mysql|Postgres $driver, string $tableName, array<string, mixed> $tableSpec) : string
Parameters
- $driver : Mysql|Postgres
- $tableName : string
- $tableSpec : array<string, mixed>
Return values
stringdecimalTypeSql()
private
decimalTypeSql(array<string, mixed> $definition) : string
Parameters
- $definition : array<string, mixed>
Return values
stringdefaultSql()
Format a column default expression for the target database.
private
defaultSql(Mysql|Postgres $driver, mixed $default, string $type) : string
Parameters
- $driver : Mysql|Postgres
- $default : mixed
- $type : string
Return values
stringdropExistingTables()
Drop all existing base tables from the current schema/database.
private
dropExistingTables(mixed $connection, Mysql|Postgres $driver) : void
Parameters
- $connection : mixed
-
Database connection
- $driver : Mysql|Postgres
foreignKeySql()
private
foreignKeySql(Mysql|Postgres $driver, array<string, mixed> $tables) : array<int, string>
Parameters
- $driver : Mysql|Postgres
- $tables : array<string, mixed>
Return values
array<int, string>indexedColumns()
Return columns that need an index-compatible MySQL representation.
private
indexedColumns(array<string, mixed> $tableSpec) : array<int, string>
PostgreSQL's unbounded CITEXT type does not retain the source varchar limit in Cake's schema manifest. Indexed CITEXT columns therefore use a conservative VARCHAR(255) during cross-engine MySQL restores, while unindexed values remain unbounded TEXT.
Parameters
- $tableSpec : array<string, mixed>
Return values
array<int, string>indexIdentifier()
Return an engine-safe index identifier unique to the table.
private
indexIdentifier(Mysql|Postgres $driver, string $tableName, string $indexName) : string
Parameters
- $driver : Mysql|Postgres
- $tableName : string
- $indexName : string
Return values
stringindexPredicateSql()
private
indexPredicateSql(Mysql|Postgres $driver, array<string, mixed> $index) : string
Parameters
- $driver : Mysql|Postgres
- $index : array<string, mixed>
Return values
stringindexSql()
private
indexSql(Mysql|Postgres $driver, array<string, mixed> $tables) : array<int, string>
Parameters
- $driver : Mysql|Postgres
- $tables : array<string, mixed>
Return values
array<int, string>normalizeMysqlStringLiteralDefault()
Strip MySQL character-set introducers captured by schema manifests.
private
normalizeMysqlStringLiteralDefault(string $default) : string
Parameters
- $default : string
Return values
stringreferentialActionSql()
Validate and normalize a foreign key referential action.
private
referentialActionSql(mixed $action) : string
Parameters
- $action : mixed
Return values
stringreport()
private
report(callable(array<string, mixed>): void|null $progressReporter, string $phase, string $message[, array<string, mixed> $context = [] ]) : void
Parameters
- $progressReporter : callable(array<string, mixed>): void|null
- $phase : string
- $message : string
- $context : array<string, mixed> = []