Commit afffd178 authored by Steve Müller's avatar Steve Müller

save one columns iteration in comparator table diff

parent 25a1cced
...@@ -190,32 +190,32 @@ class Comparator ...@@ -190,32 +190,32 @@ class Comparator
$table1Columns = $table1->getColumns(); $table1Columns = $table1->getColumns();
$table2Columns = $table2->getColumns(); $table2Columns = $table2->getColumns();
/* See if all the fields in table 1 exist in table 2 */ // See if all the fields in table 1 exist in table 2.
foreach ( $table2Columns as $columnName => $column ) { foreach ($table2Columns as $columnName => $column) {
if ( !$table1->hasColumn($columnName) ) { if ( ! $table1->hasColumn($columnName)) {
$tableDifferences->addedColumns[$columnName] = $column; $tableDifferences->addedColumns[$columnName] = $column;
$changes++; $changes++;
} }
} }
/* See if there are any removed fields in table 2 */ /* See if there are any removed fields in table 2 */
foreach ( $table1Columns as $columnName => $column ) { foreach ($table1Columns as $columnName => $column) {
if ( !$table2->hasColumn($columnName) ) { // See if column is removed in table 2.
if ( ! $table2->hasColumn($columnName)) {
$tableDifferences->removedColumns[$columnName] = $column; $tableDifferences->removedColumns[$columnName] = $column;
$changes++; $changes++;
} continue;
} }
foreach ( $table1Columns as $columnName => $column ) { // See if column has changed properties in table 2.
if ( $table2->hasColumn($columnName) ) { $changedProperties = $this->diffColumn($column, $table2->getColumn($columnName));
$changedProperties = $this->diffColumn( $column, $table2->getColumn($columnName) );
if (count($changedProperties) ) { if ( ! empty($changedProperties)) {
$columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties); $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties);
$columnDiff->fromColumn = $column; $columnDiff->fromColumn = $column;
$tableDifferences->changedColumns[$column->getName()] = $columnDiff; $tableDifferences->changedColumns[$column->getName()] = $columnDiff;
$changes++; $changes++;
} }
} }
}
$this->detectColumnRenamings($tableDifferences); $this->detectColumnRenamings($tableDifferences);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment