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