public function run()
 {
     $this->processArguments();
     $this->printHeader();
     $this->registerGroups();
     $this->runner->run($this->mode);
 }
예제 #2
0
 public function invoke(Container $container, Context $db)
 {
     $driver = new PostgreSqlNetteDbDriver($db, 'migrations');
     $printer = new Console();
     $runner = new Runner($driver, $printer);
     if ($this->in->getOption('init')) {
         ob_start();
         $runner->run($runner::MODE_INIT);
         $sql = ob_get_clean();
         $db->query($sql);
         $this->out->writeln('<info>Migrations table created</info>');
         return;
     }
     $g = new Group();
     $g->directory = __DIR__ . '/../../../migrations/struct';
     $g->dependencies = [];
     $g->enabled = TRUE;
     $g->name = 'struct';
     $runner->addGroup($g);
     $runner->addExtensionHandler('sql', new Extensions\NetteDbSql($db));
     $runner->addExtensionHandler('php', new PhpClass(['db' => $db], $container));
     try {
         $runner->run();
         return;
     } catch (\PDOException $e) {
         if ($e->getCode() !== '42S02') {
             throw $e;
         }
         // lets hope locale is english
         if (!preg_match("~Table '.*?\\.migrations' doesn't exist~", $e->getMessage())) {
             throw $e;
         }
         $this->out->writeln('<error>Migrations table does not exist, init migrations first</error>');
     }
 }
 /**
  * @param  string $mode Runner::MODE_*
  * @param  bool   $withDummy include dummy data?
  * @return void
  */
 protected function runMigrations($mode, $withDummy)
 {
     $printer = $this->getPrinter();
     $runner = new Runner($this->driver, $printer);
     foreach ($this->getGroups($withDummy) as $group) {
         $runner->addGroup($group);
     }
     foreach ($this->getExtensionHandlers() as $ext => $handler) {
         $runner->addExtensionHandler($ext, $handler);
     }
     $runner->run($mode);
 }
예제 #4
0
 /**
  * @param  string         $mode Runner::MODE_*
  * @param  IConfiguration $config
  * @return void
  */
 protected function runMigrations($mode, $config)
 {
     $printer = new Console();
     $runner = new Runner($this->driver, $printer);
     $runner->run($mode, $config);
 }