示例#1
0
 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());
 }
示例#2
0
 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;
 }
示例#3
0
 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();
     }
 }
示例#4
0
文件: Migrate.php 项目: codogh/yentu
 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");
 }