Comparator
in package
Compares two Schemas and return an instance of SchemaDiff.
Tags
Table of Contents
- compare() : SchemaDiff
- Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
- compareSchemas() : SchemaDiff
- diffColumn() : array<string|int, mixed>
- Returns the difference between the fields $field1 and $field2.
- diffForeignKey() : bool
- diffIndex() : bool
- Finds the difference between the indexes $index1 and $index2.
- diffSequence() : bool
- diffTable() : bool|TableDiff
- Returns the difference between the tables $table1 and $table2.
- detectColumnRenamings() : void
- Try to find columns that only changed their name, rename operations maybe cheaper than add/drop however ambiguities between different possibilities should not lead to renaming at all.
- detectIndexRenamings() : void
- Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop however ambiguities between different possibilities should not lead to renaming at all.
- isAutoIncrementSequenceInSchema() : bool
Methods
compare()
Returns a SchemaDiff object containing the differences between the schemas $fromSchema and $toSchema.
public
compare(Schema $fromSchema, Schema $toSchema) : SchemaDiff
The returned differences are returned in such a way that they contain the operations to change the schema stored in $fromSchema to the schema that is stored in $toSchema.
Parameters
Return values
SchemaDiff —compareSchemas()
public
static compareSchemas(Schema $fromSchema, Schema $toSchema) : SchemaDiff
Parameters
Return values
SchemaDiff —diffColumn()
Returns the difference between the fields $field1 and $field2.
public
diffColumn(Column $column1, Column $column2) : array<string|int, mixed>
If there are differences this method returns $field2, otherwise the boolean false.
Parameters
Return values
array<string|int, mixed> —diffForeignKey()
public
diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2) : bool
Parameters
- $key1 : ForeignKeyConstraint
- $key2 : ForeignKeyConstraint
Return values
bool —diffIndex()
Finds the difference between the indexes $index1 and $index2.
public
diffIndex(Index $index1, Index $index2) : bool
Compares $index1 with $index2 and returns $index2 if there are any differences or false in case there are no differences.
Parameters
Return values
bool —diffSequence()
public
diffSequence(Sequence $sequence1, Sequence $sequence2) : bool
Parameters
Return values
bool —diffTable()
Returns the difference between the tables $table1 and $table2.
public
diffTable(Table $table1, Table $table2) : bool|TableDiff
If there are no differences this method returns the boolean false.
Parameters
Return values
bool|TableDiff —detectColumnRenamings()
Try to find columns that only changed their name, rename operations maybe cheaper than add/drop however ambiguities between different possibilities should not lead to renaming at all.
private
detectColumnRenamings(TableDiff $tableDifferences) : void
Parameters
- $tableDifferences : TableDiff
Return values
void —detectIndexRenamings()
Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop however ambiguities between different possibilities should not lead to renaming at all.
private
detectIndexRenamings(TableDiff $tableDifferences) : void
Parameters
- $tableDifferences : TableDiff
Return values
void —isAutoIncrementSequenceInSchema()
private
isAutoIncrementSequenceInSchema(Schema $schema, Sequence $sequence) : bool