| @@ 331-367 (lines=37) @@ | ||
| 328 | * @return array A tuple containing the list of actions without actions for dropping the index |
|
| 329 | * and a list of drop index actions that were removed. |
|
| 330 | */ |
|
| 331 | protected function forgetDropIndex(Table $table, array $columns, array $actions) |
|
| 332 | { |
|
| 333 | $dropIndexActions = new ArrayObject(); |
|
| 334 | $indexes = collection($actions) |
|
| 335 | ->map(function ($alter) use ($table, $columns, $dropIndexActions) { |
|
| 336 | if ($alter->getTable()->getName() !== $table->getName()) { |
|
| 337 | return $alter; |
|
| 338 | } |
|
| 339 | ||
| 340 | $newAlter = new AlterTable($table); |
|
| 341 | collection($alter->getActions()) |
|
| 342 | ->map(function ($action) use ($columns) { |
|
| 343 | if (!$action instanceof DropIndex) { |
|
| 344 | return [$action, null]; |
|
| 345 | } |
|
| 346 | if ($action->getIndex()->getColumns() === $columns) { |
|
| 347 | return [null, $action]; |
|
| 348 | } |
|
| 349 | ||
| 350 | return [$action, null]; |
|
| 351 | }) |
|
| 352 | ->each(function ($tuple) use ($newAlter, $dropIndexActions) { |
|
| 353 | list($action, $dropIndex) = $tuple; |
|
| 354 | if ($action) { |
|
| 355 | $newAlter->addAction($action); |
|
| 356 | } |
|
| 357 | if ($dropIndex) { |
|
| 358 | $dropIndexActions->append($dropIndex); |
|
| 359 | } |
|
| 360 | }); |
|
| 361 | ||
| 362 | return $newAlter; |
|
| 363 | }) |
|
| 364 | ->toArray(); |
|
| 365 | ||
| 366 | return [$indexes, $dropIndexActions->getArrayCopy()]; |
|
| 367 | } |
|
| 368 | ||
| 369 | /** |
|
| 370 | * Deletes any RemoveColumn actions for the given table and exact columns |
|
| @@ 378-413 (lines=36) @@ | ||
| 375 | * @return array A tuple containing the list of actions without actions for removing the column |
|
| 376 | * and a list of remove column actions that were removed. |
|
| 377 | */ |
|
| 378 | protected function forgetRemoveColumn(Table $table, array $columns, array $actions) |
|
| 379 | { |
|
| 380 | $removeColumnActions = new ArrayObject(); |
|
| 381 | $indexes = collection($actions) |
|
| 382 | ->map(function ($alter) use ($table, $columns, $removeColumnActions) { |
|
| 383 | if ($alter->getTable()->getName() !== $table->getName()) { |
|
| 384 | return $alter; |
|
| 385 | } |
|
| 386 | ||
| 387 | $newAlter = new AlterTable($table); |
|
| 388 | collection($alter->getActions()) |
|
| 389 | ->map(function ($action) use ($columns) { |
|
| 390 | if (!$action instanceof RemoveColumn) { |
|
| 391 | return [$action, null]; |
|
| 392 | } |
|
| 393 | if (in_array($action->getColumn(), $columns)) { |
|
| 394 | return [null, $action]; |
|
| 395 | } |
|
| 396 | ||
| 397 | return [$action, null]; |
|
| 398 | }) |
|
| 399 | ->each(function ($tuple) use ($newAlter, $removeColumnActions) { |
|
| 400 | list($action, $removeColumn) = $tuple; |
|
| 401 | if ($action) { |
|
| 402 | $newAlter->addAction($action); |
|
| 403 | } |
|
| 404 | if ($removeColumn) { |
|
| 405 | $removeColumnActions->append($removeColumn); |
|
| 406 | } |
|
| 407 | }); |
|
| 408 | ||
| 409 | return $newAlter; |
|
| 410 | }) |
|
| 411 | ->toArray(); |
|
| 412 | ||
| 413 | return [$indexes, $removeColumnActions->getArrayCopy()]; |
|
| 414 | } |
|
| 415 | ||
| 416 | /** |
|