コード例 #1
0
 public function execute()
 {
     $id = $this->input->getArgument('id');
     try {
         $this->manager->down($id);
     } catch (RuntimeException $e) {
         throw new ConsoleException("<error>Error</error> {$e->getMessage()}");
     }
     $this->output->writeln("<info>rollback</info> {$id}");
 }
コード例 #2
0
 public function execute()
 {
     $untilMigrationId = $this->input->getArgument('until');
     /** @var \Wandu\Database\Migrator\MigrationContainer[] $migrations */
     $migrations = array_reverse($this->manager->getMigrations());
     if (!count($migrations)) {
         $this->output->writeln("<comment>there is no migration to rollback.</comment>");
         return 2;
     }
     foreach ($migrations as $migration) {
         if (!$migration->isApplied()) {
             continue;
         }
         $this->manager->down($migration->getId());
         if ($migration->getId() === $untilMigrationId || !$untilMigrationId) {
             break;
         }
     }
 }