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