Exemplo n.º 1
0
 public function testMigrateWithVersionDown()
 {
     $versions = [['version' => 33, 'class' => 'T4web\\MigrationsTest\\Assets\\VersionX', 'description' => 'Some description', 'applied' => false], ['version' => 22, 'class' => 'Some\\Class_22', 'description' => 'Some description', 'applied' => true], ['version' => 77, 'class' => 'T4web\\MigrationsTest\\Assets\\Version_1', 'description' => 'Some description', 'applied' => false]];
     $this->resolver->getAll(true)->willReturn(new \ArrayIterator($versions));
     $this->table->getCurrentVersion()->willReturn(33);
     $this->console->writeLine(Argument::type('string'))->willReturn(null);
     $this->table->delete(77)->willReturn(null);
     $this->migration->migrate('77', true, true);
 }
Exemplo n.º 2
0
 public function onDispatch(MvcEvent $e)
 {
     if (!$e->getRequest() instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console!');
     }
     $version = $e->getRequest()->getParam('version');
     $force = $e->getRequest()->getParam('force');
     $down = $e->getRequest()->getParam('down');
     if (is_null($version) && $force) {
         $response = "Can't force migration apply without migration version explicitly set.\n";
         $e->setResult($response);
         return $response;
     }
     $this->migration->migrate($version, $force, $down);
     $response = "Migrations applied!\n";
     $e->setResult($response);
     return $response;
 }