| @@ 284-301 (lines=18) @@ | ||
| 281 | * @param \Phinx\Db\Action\Action[] $actions The actions to parse |
|
| 282 | * @return void |
|
| 283 | */ |
|
| 284 | protected function gatherTableMoves($actions) |
|
| 285 | { |
|
| 286 | collection($actions) |
|
| 287 | ->filter(function ($action) { |
|
| 288 | return $action instanceof DropTable |
|
| 289 | || $action instanceof RenameTable; |
|
| 290 | }) |
|
| 291 | ->each(function ($action) { |
|
| 292 | $table = $action->getTable(); |
|
| 293 | $name = $table->getName(); |
|
| 294 | ||
| 295 | if (!isset($this->tableMoves[$name])) { |
|
| 296 | $this->tableMoves[$name] = new AlterTable($table); |
|
| 297 | } |
|
| 298 | ||
| 299 | $this->tableMoves[$name]->addAction($action); |
|
| 300 | }); |
|
| 301 | } |
|
| 302 | ||
| 303 | /** |
|
| 304 | * Collects all index creation and drops from the given intent |
|
| @@ 339-356 (lines=18) @@ | ||
| 336 | * @param \Phinx\Db\Action\Action[] $actions The actions to parse |
|
| 337 | * @return void |
|
| 338 | */ |
|
| 339 | protected function gatherConstraints($actions) |
|
| 340 | { |
|
| 341 | collection($actions) |
|
| 342 | ->filter(function ($action) { |
|
| 343 | return $action instanceof AddForeignKey |
|
| 344 | || $action instanceof DropForeignKey; |
|
| 345 | }) |
|
| 346 | ->each(function ($action) { |
|
| 347 | $table = $action->getTable(); |
|
| 348 | $name = $table->getName(); |
|
| 349 | ||
| 350 | if (!isset($this->constraints[$name])) { |
|
| 351 | $this->constraints[$name] = new AlterTable($table); |
|
| 352 | } |
|
| 353 | ||
| 354 | $this->constraints[$name]->addAction($action); |
|
| 355 | }); |
|
| 356 | } |
|
| 357 | } |
|
| 358 | ||