|
@@ 310-331 (lines=22) @@
|
| 307 |
|
* @return array A tuple containing the list of actions without actions for dropping the index |
| 308 |
|
* and a list of drop index actions that were removed. |
| 309 |
|
*/ |
| 310 |
|
protected function forgetDropIndex(Table $table, array $columns, array $actions) |
| 311 |
|
{ |
| 312 |
|
$dropIndexActions = new ArrayObject(); |
| 313 |
|
$indexes = array_map(function ($alter) use ($table, $columns, $dropIndexActions) { |
| 314 |
|
if ($alter->getTable()->getName() !== $table->getName()) { |
| 315 |
|
return $alter; |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
$newAlter = new AlterTable($table); |
| 319 |
|
foreach ($alter->getActions() as $action) { |
| 320 |
|
if ($action instanceof DropIndex && $action->getIndex()->getColumns() === $columns) { |
| 321 |
|
$dropIndexActions->append($action); |
| 322 |
|
} else { |
| 323 |
|
$newAlter->addAction($action); |
| 324 |
|
} |
| 325 |
|
} |
| 326 |
|
|
| 327 |
|
return $newAlter; |
| 328 |
|
}, $actions); |
| 329 |
|
|
| 330 |
|
return [$indexes, $dropIndexActions->getArrayCopy()]; |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
/** |
| 334 |
|
* Deletes any RemoveColumn actions for the given table and exact columns |
|
@@ 343-364 (lines=22) @@
|
| 340 |
|
* @return array A tuple containing the list of actions without actions for removing the column |
| 341 |
|
* and a list of remove column actions that were removed. |
| 342 |
|
*/ |
| 343 |
|
protected function forgetRemoveColumn(Table $table, array $columns, array $actions) |
| 344 |
|
{ |
| 345 |
|
$removeColumnActions = new ArrayObject(); |
| 346 |
|
$indexes = array_map(function ($alter) use ($table, $columns, $removeColumnActions) { |
| 347 |
|
if ($alter->getTable()->getName() !== $table->getName()) { |
| 348 |
|
return $alter; |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
$newAlter = new AlterTable($table); |
| 352 |
|
foreach ($alter->getActions() as $action) { |
| 353 |
|
if ($action instanceof RemoveColumn && in_array($action->getColumn()->getName(), $columns, true)) { |
| 354 |
|
$removeColumnActions->append($action); |
| 355 |
|
} else { |
| 356 |
|
$newAlter->addAction($action); |
| 357 |
|
} |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
return $newAlter; |
| 361 |
|
}, $actions); |
| 362 |
|
|
| 363 |
|
return [$indexes, $removeColumnActions->getArrayCopy()]; |
| 364 |
|
} |
| 365 |
|
|
| 366 |
|
/** |
| 367 |
|
* Collects all table creation actions from the given intent |