Exemplo n.º 1
0
 /**
  * Run a migration in a particular direction
  *
  * @param Migration $migration
  * @param string $direction
  * @return void
  */
 protected function run(Migration $migration, $direction = 'up')
 {
     $direction = $direction == 'down' ? 'down' : 'up';
     $this->getOutput()->writeln(sprintf(' == <info>' . $migration->getVersion() . ' ' . $migration->getName() . '</info> ' . '<comment>' . ($direction == 'up' ? 'migrating' : 'reverting') . '</comment>'));
     $start = microtime(1);
     $migration->setContainer($this->getContainer());
     $migration->init();
     $migration->{$direction}();
     $this->getAdapter()->{$direction}($migration);
     $end = microtime(1);
     $this->getOutput()->writeln(sprintf(' == <info>' . $migration->getVersion() . ' ' . $migration->getName() . '</info> ' . '<comment>' . ($direction == 'up' ? 'migrated ' : 'reverted ') . sprintf("%.4fs", $end - $start) . '</comment>'));
 }
Exemplo n.º 2
0
 /**
  * Up
  *
  * @param Migration $migration
  *
  * @return AdapterInterface
  */
 public function up(Migration $migration)
 {
     $helper = $this->helper;
     $this->db->queryExecute(sprintf('INSERT INTO %s (%s, %s) VALUES (\'%s\', \'%s\')', $helper->quote($this->tableName), $helper->quote('version'), $helper->quote('name'), $helper->forSql($migration->getVersion()), $helper->forSql($migration->getName())));
     return $this;
 }