예제 #1
0
 /**
  * Rollback the latest migration command.
  *
  * @param  array  $arguments
  * @return bool
  */
 public function rollback($arguments = array())
 {
     $migrations = $this->resolver->last();
     // If bundles supplied, filter migrations to rollback only bundles'
     // migrations.
     if (count($arguments) > 0) {
         $bundles = $arguments;
         if (!is_array($bundles)) {
             $bundles = array($bundles);
         }
         $migrations = array_filter($migrations, function ($migration) use($bundles) {
             return in_array($migration['bundle'], $bundles);
         });
     }
     if (count($migrations) == 0) {
         echo "Nothing to rollback." . PHP_EOL;
         return false;
     }
     // The "last" method on the resolver returns an array of migrations,
     // along with their bundles and names. We will iterate through each
     // migration and run the "down" method.
     foreach (array_reverse($migrations) as $migration) {
         $migration['migration']->down();
         echo 'Rolled back: ' . $this->display($migration) . PHP_EOL;
         // By only removing the migration after it has successfully rolled back,
         // we can re-run the rollback command in the event of any errors with
         // the migration and pick up where we left off.
         $this->database->delete($migration['bundle'], $migration['name']);
     }
     return true;
 }
예제 #2
0
 /**
  * Rollback the latest migration command.
  *
  * @param  array  $arguments
  * @return bool
  */
 public function rollback($arguments = array())
 {
     $migrations = $this->resolver->last();
     if (count($migrations) == 0) {
         echo "Nothing to rollback.";
         return false;
     }
     // The "last" method on the resolver returns an array of migrations,
     // along with their bundles and names. We will iterate through each
     // migration and run the "down" method, removing them from the
     // database as we go.
     foreach (array_reverse($migrations) as $migration) {
         $migration['migration']->down();
         echo 'Rolled back: ' . $this->display($migration) . PHP_EOL;
         // By only removing the migration after it has successfully rolled back,
         // we can re-run the rollback command in the event of any errors with
         // the migration. When we re-run, only the migrations that have not
         // been rolled back will still be in the database.
         $this->database->delete($migration['bundle'], $migration['name']);
     }
     return true;
 }
예제 #3
0
 /**
  * Resolve an array of the last batch of migrations.
  *
  * @return array
  */
 public function last()
 {
     return $this->resolve($this->database->last());
 }