Example #1
0
 /**
  * @param Table $target
  * @param array $parts
  * @return array
  */
 protected function purgeFields(Table $target, array $parts = [])
 {
     $fieldNames = array_keys($this->fields);
     foreach ($fieldNames as $name) {
         if (!$target->hasField($name)) {
             $parts[] = sprintf('DROP COLUMN `%s`', $name);
             //remove field
             unset($this->fields[$name]);
             //drop all affected indexes
             $indexes = $this->getIndexesWithField($name, true);
             foreach ($indexes as $idx) {
                 unset($this->indexes[$idx]);
                 $parts[] = sprintf('DROP INDEX `%s`', $idx);
             }
         }
     }
     return $parts;
 }