Exemplo n.º 1
0
 /**
  * Rollback the last migration operation.
  *
  * @param  bool  $pretend
  * @return int
  */
 public function rollback($pretend = false)
 {
     $this->notes = [];
     // We want to pull in the last batch of migrations that ran on the previous
     // migration operation. We'll then reverse those migrations and run each
     // of them "down" to reverse the last migration "operation" which ran.
     $migrations = $this->repository->getLast();
     $count = count($migrations);
     if ($count === 0) {
         $this->note('<info>Nothing to rollback.</info>');
     } else {
         // We need to reverse these migrations so that they are "downed" in reverse
         // to what they run on "up". It lets us backtrack through the migrations
         // and properly reverse the entire database schema operation that ran.
         foreach ($migrations as $migration) {
             $this->runDown((object) $migration, $pretend);
         }
     }
     return $count;
 }