Пример #1
0
 /**
  * Migrates up from current Step to given Step (defaults to last Step)
  *
  * @param string $to Name of the Step class that should become the current Step
  * @param Console $console [] <-
  */
 public function doExecute($to = null, Console $console)
 {
     $console->out->writeLine('Starting migration' . ($to ? ' to [' . $to . ']' : ''));
     $this->migrater->on(MigrateUpEvent::$CLASS, function (MigrateEvent $e) use($console) {
         $console->out->writeLine('Migrating up [' . $e->getStepName() . ']');
     });
     $this->migrater->on(MigrateDownEvent::$CLASS, function (MigrateEvent $e) use($console) {
         $console->out->writeLine('Migrating down [' . $e->getStepName() . ']');
     });
     if ($to == 'down') {
         $this->migrater->migrateDown();
     } else {
         $this->migrater->migrate($to);
     }
 }
Пример #2
0
 private function whenIStartTheMigrationTo($target)
 {
     $migrater = new Migrater($this->step->firstStep, $this->state);
     $that = $this;
     $migrater->on(MigrationCompletedEvent::$CLASS, function (MigrationCompletedEvent $e) use($that) {
         $that->state = $e->getNewState();
     });
     $migrater->migrate($target);
 }