/** * Get difference between table indexes * * @param $table */ protected function createIndexDifference($table) { $currentIndexes = $this->_currentDb->getIndexList($table); $publishedIndexes = $this->_publishedDb->getIndexList($table); foreach ($currentIndexes as $curIndex) { $indexForCompare = $this->findIndex($curIndex, $publishedIndexes); if (!$indexForCompare) { $this->up(Core_Db_Database::addIndex($curIndex)); $this->up(Core_Db_Database::addConstraint($curIndex)); $this->down(Core_Db_Database::dropConstraint($curIndex)); $this->down(Core_Db_Database::dropIndex($curIndex)); } elseif ($indexForCompare !== $curIndex) { $this->up(Core_Db_Database::dropConstraint($curIndex)); $this->up(Core_Db_Database::dropIndex($curIndex)); $this->down(Core_Db_Database::dropConstraint($curIndex)); $this->down(Core_Db_Database::dropIndex($curIndex)); $this->down(Core_Db_Database::addIndex($indexForCompare)); $this->down(Core_Db_Database::addConstraint($indexForCompare)); } } //For creating deleted indexes $deletedIndexes = $this->getDeletedIndexes($currentIndexes, $publishedIndexes); if ($deletedIndexes) { foreach ($deletedIndexes as $deletedIndex) { //Create deleted index $this->up(Core_Db_Database::dropConstraint($deletedIndex)); $this->up(Core_Db_Database::dropIndex($deletedIndex)); //Delete index $this->down(Core_Db_Database::addConstraint($deletedIndex)); $this->down(Core_Db_Database::addIndex($deletedIndex)); } } }
/** * get difference between table indexes * @param $table */ protected function createIndexDifference($table) { $currentIndexes = $this->_currentDb->getIndexList($table); $publishedIndexes = $this->_publishedDb->getIndexList($table); foreach ($currentIndexes as $curIndex) { $indexForCompare = $this->checkIndexExists($curIndex, $publishedIndexes); if (!$indexForCompare) { $this->down(Core_Db_Database::dropConstraint($curIndex)); $this->down(Core_Db_Database::dropIndex($curIndex)); $this->up(Core_Db_Database::dropConstraint($curIndex)); $this->up(Core_Db_Database::dropIndex($curIndex)); $this->up(Core_Db_Database::addIndex($curIndex)); $this->up(Core_Db_Database::addConstraint($curIndex)); } elseif ($indexForCompare === $curIndex) { continue; } else { $this->down(Core_Db_Database::dropConstraint($curIndex)); $this->down(Core_Db_Database::dropIndex($curIndex)); $this->down(Core_Db_Database::addIndex($indexForCompare)); $this->down(Core_Db_Database::addConstraint($indexForCompare)); $this->up(Core_Db_Database::dropConstraint($curIndex)); $this->up(Core_Db_Database::dropIndex($curIndex)); $this->up(Core_Db_Database::addIndex($curIndex)); $this->up(Core_Db_Database::addConstraint($curIndex)); } } }