public function migrateDb()
 {
     $sm = $this->connection->getSchemaManager();
     $queryBuilder = $this->connection->createQueryBuilder();
     $queryBuilder->select('m.modelid', 'm.modeluri')->from('models', 'm');
     // modelid
     $result = $this->connection->executeQuery($queryBuilder->getSql());
     $namespaces = array();
     $newNs = array();
     while ($row = $result->fetch()) {
         $id = $row['modelid'];
         $uri = $row['modeluri'];
         if (substr($uri, -1) != '#') {
             $uri .= '#';
         }
         $namespaces[$id] = $uri;
         $newNs[$this->modelid[$id]] = $uri;
     }
     ksort($newNs);
     $query = 'ALTER TABLE statements CHANGE ' . $this->connection->quoteIdentifier('modelID') . ' ' . $this->connection->quoteIdentifier('modelid') . ' INT( 11 )';
     $result = $this->connection->executeUpdate($query);
     $schema = $sm->createSchema();
     $newSchema = clone $schema;
     $newSchema->dropTable('models');
     $sql = $schema->getMigrateToSql($newSchema, $this->connection->getDatabasePlatform());
     foreach ($sql as $q) {
         $result = $this->connection->executeUpdate($q);
     }
     $schema = $sm->createSchema();
     $newSchema = clone $schema;
     $table = $newSchema->createTable("models");
     $table->addColumn('modelid', "integer", array("notnull" => true));
     $table->addColumn('modeluri', "string", array("length" => 255, "default" => null));
     $table->addOption('engine', 'MyISAM');
     $table->setPrimaryKey(array('modelid'));
     $table->addIndex(array('modeluri'), "idx_models_modeluri");
     $sql = $schema->getMigrateToSql($newSchema, $this->connection->getDatabasePlatform());
     foreach ($sql as $q) {
         $result = $this->connection->executeUpdate($q);
     }
     foreach ($newNs as $id => $ns) {
         $result = $this->connection->insert('models', array('modelid' => $id, 'modeluri' => $ns));
     }
     $orderId = $this->modelid;
     asort($orderId);
     $sanatyCheck = array();
     foreach ($orderId as $old => $new) {
         $tmpvalue = 100 + $new;
         $query = 'update statements set modelid = ' . $tmpvalue . ' where modelid=' . $old;
         $result = $this->connection->executeUpdate($query);
         $sanatyCheck[$newNs[$new]]['first'] = $result;
     }
     for ($i = 101; $i < 120; $i++) {
         $tmpvalue = $i - 100;
         $query = 'update statements set modelid = ' . $tmpvalue . ' where modelid=' . $i;
         $result = $this->connection->executeUpdate($query);
         if (isset($newNs[$tmpvalue])) {
             $sanatyCheck[$newNs[$tmpvalue]]['second'] = $result;
         }
     }
     // var_dump($sanatyCheck);
     Logger::d('Update database completed');
     // echo 'plop';
 }
 /**
  *
  * @access
  * @author "Lionel Lecaque, <*****@*****.**>"
  * @param unknown $ext
  * @return boolean
  */
 public function unShield($ext)
 {
     $releaseManifest = $this->getReleaseManifest();
     $extFolder = $releaseManifest['old_root_path'] . $ext;
     if (!is_file($extFolder . '/htaccess.1')) {
         Logger::d('Previous lock, htaccess.1 do not exits something new extension');
         return true;
     }
     if (unlink($extFolder . '/.htaccess')) {
         return File::move($extFolder . '/htaccess.1', $extFolder . '/.htaccess', false);
     } else {
         Logger::e('Fail to remove htaccess in ' . $ext . ' . You may copy by hand file htaccess.1');
         return false;
     }
 }