diff --git a/src/Differ.php b/src/Differ.php index c73c802..8b35c92 100644 --- a/src/Differ.php +++ b/src/Differ.php @@ -101,7 +101,9 @@ private function diffColumns(ChangedTable $changedTable) */ private function addChangedColumn(ChangedTable $changedTable, Column $column) { - $changedTable->addChangedColumn($column); + if (!$changedTable->hasNewColumn($column->getName())) { + $changedTable->addChangedColumn($column); + } if (!$column->getNextColumn()) { return; diff --git a/src/Model/ChangedTable.php b/src/Model/ChangedTable.php index 89e28d3..6ef0ce8 100644 --- a/src/Model/ChangedTable.php +++ b/src/Model/ChangedTable.php @@ -117,6 +117,20 @@ public function getNewColumns() public function addNewColumn(Column $newColumn) { $this->newColumns[$newColumn->getName()] = $newColumn; + + if (isset($this->changedColumns[$newColumn->getName()])) { + unset($this->changedColumns[$newColumn->getName()]); + } + } + + /** + * @param $columnName + * + * @return bool + */ + public function hasNewColumn($columnName) + { + return isset($this->newColumns[$columnName]); } /**