From ab8e44e133b1771bc4ea77a58ded5b1f7230a334 Mon Sep 17 00:00:00 2001 From: Carlos Cima Date: Mon, 11 Apr 2016 18:49:56 -0400 Subject: [PATCH] Fixed issue with the diff command when new tables are also included in the changed tables list. --- src/Differ.php | 4 +++- src/Model/ChangedTable.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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]); } /**