public function testPushPopLevel() { $this->assertEquals(ClearIce::OUTPUT_LEVEL_1, ClearIce::getOutputLevel()); ClearIce::pushOutputLevel(ClearIce::OUTPUT_LEVEL_3); $this->assertEquals(ClearIce::OUTPUT_LEVEL_3, ClearIce::getOutputLevel()); ClearIce::popOutputLevel(ClearIce::OUTPUT_LEVEL_1); ClearIce::pushOutputLevel(ClearIce::OUTPUT_LEVEL_3); ClearIce::pushOutputLevel(ClearIce::OUTPUT_LEVEL_2); ClearIce::resetOutputLevel(); $this->assertEquals(ClearIce::OUTPUT_LEVEL_1, ClearIce::getOutputLevel()); }
private function performOperation($method, $matches, $arguments) { try { $return = $this->driver->{$method}($arguments[0]); Yentu::announce($matches['command'], $matches['item_type'], $arguments[0]); $this->driver->setDumpQuery(false); ClearIce::pushOutputLevel(ClearIce::OUTPUT_LEVEL_0); $this->driver->query('INSERT INTO yentu_history(session, version, method, arguments, migration, default_schema) VALUES (?,?,?,?,?,?)', array($this->session, $this->version, $method, json_encode($arguments), $this->migration, self::$defaultSchema)); ClearIce::popOutputLevel(); $this->changes++; $this->driver->setDisableQuery(false); } catch (\yentu\exceptions\DatabaseManipulatorException $e) { if ($this->skipOnErrors) { ClearIce::output("E"); ClearIce::output("rror " . preg_replace("/([a-z])([A-Z])/", "\$1 \$2", $matches['item_type']) . " '" . $arguments[0]['name'] . "'\n", ClearIce::OUTPUT_LEVEL_2); } else { throw $e; } } return $return; }
public function createHistory() { try { $this->connection->describeTable('yentu_history'); } catch (\ntentan\atiaa\exceptions\TableNotFoundException $e) { ClearIce::pushOutputLevel(ClearIce::OUTPUT_LEVEL_0); $this->addTable(array('schema' => '', 'name' => 'yentu_history')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'session', 'type' => 'string')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => false, 'length' => null, 'table' => 'yentu_history', 'name' => 'version', 'type' => 'string')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'method', 'type' => 'string')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'arguments', 'type' => 'text')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'migration', 'type' => 'string')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'default_schema', 'type' => 'string')); $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'id', 'type' => 'integer')); $this->addPrimaryKey(array('schema' => '', 'table' => 'yentu_history', 'name' => 'yentu_history_pk', 'columns' => array('id'))); $this->addAutoPrimaryKey(array('schema' => '', 'table' => 'yentu_history', 'column' => 'id')); ClearIce::popOutputLevel(); } }
public function reverse() { if ($this->driver === null) { return; } ClearIce::output("Attempting to reverse all changes ... "); if ($this->getChanges() > 0) { ClearIce::pushOutputLevel(0); $rollback = new \yentu\commands\Rollback(); $rollback->run(array()); ClearIce::popOutputLevel(); } ClearIce::output("OK\n"); }