Comparator

class \TYPO3\CMS\Core\Database\Schema\Comparator

Extends
Comparator

Compares two Schemas and returns an instance of SchemaDiff.

Table of Contents

Properties

$databasePlatform  : AbstractPlatform|null

Methods

__construct()  : mixed
Comparator constructor.
columnsEqual()  : bool
compareSchemas()  : SchemaDiff
Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
diffColumn()  : array
Returns the difference between the columns $column1 and $column2 by first checking the doctrine diffColumn. Extend the Doctrine method by taking into account MySQL TINY/MEDIUM/LONG type variants.
diffTable()  : false|TableDiff|TableDiff
Returns the difference between the tables $fromTable and $toTable.

Properties

$databasePlatform

protected AbstractPlatform|null $databasePlatform

Methods

__construct()

Comparator constructor.

public __construct([AbstractPlatform|null $platform = null ]) : mixed

Parameters

$platform : AbstractPlatform|null = null

columnsEqual()

public columnsEqual(Column $column1, Column $column2) : bool

Parameters

$column1 : Column
$column2 : Column

Tags

todo

TYPO3 v13 needs to properly handle the columnsEqual way, so we use the old column comparison here to avoid noisy and incorrect comparison for now leading to endless loop.

Return values

bool

compareSchemas()

Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.

public static compareSchemas(Schema $fromSchema, Schema $toSchema[, AbstractPlatform|null $platform = null ]) : SchemaDiff

This method should be called non-statically since it will be declared as non-static in the next doctrine/dbal major release.

doctrine/dbal uses new self() in this method, which instantiate the doctrine Comparator class and not our extended class, thus not calling our overridden methods 'diffTable()' and 'diffColum()' and breaking core table engine support, which is tested in core functional tests explicity. See corresponding test TYPO3\CMS\Core\Tests\Functional\Database\Schema\SchemaMigratorTest->changeTableEngine()

Parameters

$fromSchema : Schema
$toSchema : Schema
$platform : AbstractPlatform|null = null

Tags

throws
SchemaException
todo

Create PR for doctrine/dbal to change to late binding 'new static()', so our override is working correctly and remove this method after min package raise, if PR was accepted and merged. Also remove 'isAutoIncrementSequenceInSchema()'.

Return values

SchemaDiff

diffColumn()

Returns the difference between the columns $column1 and $column2 by first checking the doctrine diffColumn. Extend the Doctrine method by taking into account MySQL TINY/MEDIUM/LONG type variants.

public diffColumn(Column $column1, Column $column2) : array

Parameters

$column1 : Column
$column2 : Column

Return values

array

diffTable()

Returns the difference between the tables $fromTable and $toTable.

public diffTable(Table $fromTable, Table $toTable) : false|TableDiff|TableDiff

If there are no differences this method returns the boolean false.

Parameters

$fromTable : Table
$toTable : Table

Tags

throws
InvalidArgumentException

Return values

false|TableDiff|TableDiff
On this page