Conditions | 6 |
Paths | 5 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
28 | public function execute() |
||
29 | { |
||
30 | $untilMigrationId = $this->input->getArgument('until'); |
||
31 | |||
32 | /** @var \Wandu\Migrator\FileMigrationInformation[] $migrations */ |
||
33 | $migrations = array_reverse($this->manager->getMigrationInformations()); |
||
34 | |||
35 | if (!count($migrations)) { |
||
36 | $this->output->writeln("<comment>there is no migration to rollback.</comment>"); |
||
37 | return 2; |
||
38 | } |
||
39 | foreach ($migrations as $migration) { |
||
40 | if (!$this->manager->isApplied($migration)) { |
||
41 | continue; |
||
42 | } |
||
43 | $this->manager->down($migration->getId()); |
||
44 | $this->output->writeln(sprintf("<info>down</info> %s", $migration->getId())); |
||
45 | if ($migration->getId() === $untilMigrationId || !$untilMigrationId) { |
||
46 | break; |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 |