Example #1
0
 /**
  * Rollback the last migration operation.
  *
  * @param       $namespace
  * @param  bool $pretend
  * @return int
  */
 public function rollbackPackage($path, $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->findManyByFiles($files = $this->getMigrationFiles($path));
     $this->requireFiles($path, $files);
     if (count($migrations) == 0) {
         $this->note("<info>Nothing to rollback: {$path}</info>");
         return count($migrations);
     }
     // 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($migrations);
 }
Example #2
0
 /**
  * Rollback the last migration operation.
  *
  * @param  array|string $paths
  * @param  array        $options
  * @return array
  */
 public function rollback($paths = [], array $options = [])
 {
     $this->repository->setAddon($this->getAddon());
     return parent::rollback($paths, $options);
 }