com\setasign\SetaFramework\Database\Manager
TableSchemaBuilder Class TableSchemaBuilder
File: /SetaFramework/src/Database/Manager/TableSchemaBuilder.php
Class hierarchy
Implements
- \Psr\Log\LoggerAwareInterface
Summary
Properties
$dbManager
$eventManager
$logger
$runningBuild
Methods
__construct()
?\com\setasign\SetaFramework\EventManager\EventManager $eventManager = null
TableSchemaBuilder constructor.
Parameters
- $dbManager : AbstractManager
- $eventManager : ?\com\setasign\SetaFramework\EventManager\EventManager
build()
Creates/Updates a table by $expectedColumns.
This method will not delete any column instead it will add an underscore (or multiple if necessary) to the column, remove all indexes for the column, set allow_null = true and set default to null.
If the type of one column will change the method will set mysql to non-strict mode and mysql will try to soft type change the columns.
Be careful when you call this method. Changes to tables can't be in transactions and can't roll back. You have to ensure yourself that only one php process use this method on the same table at the same time.
Parameters
- $expectedTableSchema : TableSchema
Autosync must be off!
Exceptions
Throws TableSchemaBuilderException
checkAutoIncrementValues()
string $columnName
Parameters
- $tableName : string
- $columnName : string
Exceptions
Throws TableSchemaBuilderException
checkSchemaCollation()
Check if the collation exists for the used database.
We check this to prevent infinite change loops in the table schema when setting a collation which is an alias.
Parameters
- $tableSchema : TableSchema
copyAlterColumns()
array $alterColumns,
Column\AbstractColumn[] $expectedColumns,
bool $simulationMode
Parameters
- $actualSchema : TableSchema
- $alterColumns : array
- $expectedColumns : Column\AbstractColumn[]
- $simulationMode : bool
findChanges()
Parameters
- $actualSchema : TableSchema
- $expectedSchema : TableSchema
Exceptions
Throws TableSchemaBuilderException
markColumnAsDeleted()
Will not really be deleted, just set allowNull = true and default = null and all indexes will be deleted
Parameters
- $column : Column\AbstractColumn
registerMigrationGenerator()
Parameters
- $migrationGenerator : \com\setasign\SetaFramework\Database\Migration\MigrationGenerator
reoderColumns()
Parameters
- $actualSchema : TableSchema
- $expectedColumns : Column\AbstractColumn[]
runBuild()
TableSchema $expectedSchema,
?TableSchema $originalSchema,
TableSchemaBuilderChangeData $changes
Parameters
- $actualSchema : TableSchema
- $expectedSchema : TableSchema
- $originalSchema : ?TableSchema
If is null we are in simulation mode no query will be executed and all queries are added as down-queries.
- $changes : TableSchemaBuilderChangeData
Exceptions
Throws TableSchemaBuilderException
searchNewColumnName()
Parameters
- $expectedColumns : Column\AbstractColumn[]
- $columnName : string
setIndexes()
array<string, Column\AbstractColumn> $expectedColumns,
bool $simulationMode
Parameters
- $actualSchema : TableSchema
- $expectedColumns : array<string, Column\AbstractColumn>
- $simulationMode : bool
updateTableSchema()
TableSchemaBuilderChangeData $changes,
Column\AbstractColumn[] $expectedColumns
Parameters
- $actualSchema : TableSchema
- $changes : TableSchemaBuilderChangeData
- $expectedColumns : Column\AbstractColumn[]
Return Values
Whether something was changed.
