public function _migrateData(\b2db\Table $old_table)
 {
     $sqls = array();
     $tn = $this->_getTableNameSQL();
     $qc = $this->getQC();
     switch ($old_table->getVersion()) {
         case 1:
             $sqls[] = "UPDATE {$tn} SET icon = itemdata";
             $sqls[] = "UPDATE {$tn} SET {$qc}key{$qc} = NULL";
             break;
     }
     foreach ($sqls as $sql) {
         $statement = \b2db\Statement::getPreparedStatement($sql);
         $res = $statement->performQuery('update');
     }
     switch ($old_table->getVersion()) {
         case 1:
             foreach (self::getTable()->getAll() as $issuetype) {
                 // Trigger issuetype key regeneration
                 $issuetype->setKey(null);
                 $issuetype->getKey();
                 $issuetype->save();
             }
             break;
     }
 }
 public function _migrateData(\b2db\Table $old_table)
 {
     $sqls = array();
     $tn = $this->_getTableNameSQL();
     switch ($old_table->getVersion()) {
         case 1:
             $crit = $this->getCriteria();
             $crit->addWhere(self::EDITION, 0, Criteria::DB_NOT_EQUALS);
             $res = $this->doSelect($crit);
             $editions = array();
             if ($res) {
                 while ($row = $res->getNextRow()) {
                     $editions[$row->get(self::EDITION)] = 0;
                 }
             }
             $edition_projects = TBGEditionsTable::getTable()->getProjectIDsByEditionIDs(array_keys($editions));
             foreach ($edition_projects as $edition => $project) {
                 $crit = $this->getCriteria();
                 $crit->addUpdate(self::PROJECT, $project);
                 $crit->addWhere(self::EDITION, $edition);
                 $res = $this->doUpdate($crit);
             }
             break;
     }
 }
 protected function _migrateData(Table $old_users_table)
 {
     switch ($old_users_table->getVersion()) {
         case 1:
             $users = $this->getUserMigrationDetails();
             $table = TBGUserScopesTable::getTable();
             foreach ($users as $user_id => $details) {
                 $table->addUserToScope($user_id, $details['scope_id'], $details['group_id'], true);
             }
             break;
     }
 }
 public function _migrateData(\b2db\Table $old_table)
 {
     $sqls = array();
     $tn = $this->_getTableNameSQL();
     switch ($old_table->getVersion()) {
         case 1:
             $sqls[] = "UPDATE {$tn} SET owner_team = owner WHERE owner_type = 2";
             $sqls[] = "UPDATE {$tn} SET owner_user = owner WHERE owner_type = 1";
             $sqls[] = "UPDATE {$tn} SET leader_team = leader WHERE leader_type = 2";
             $sqls[] = "UPDATE {$tn} SET leader_user = leader WHERE leader_type = 1";
             $sqls[] = "UPDATE {$tn} SET qa_responsible_team = qa_responsible WHERE qa_responsible_type = 2";
             $sqls[] = "UPDATE {$tn} SET qa_responsible_user = qa_responsible WHERE qa_responsible_type = 1";
             break;
     }
     foreach ($sqls as $sql) {
         $statement = \b2db\Statement::getPreparedStatement($sql);
         $res = $statement->performQuery('update');
     }
 }
 public function _migrateData(\b2db\Table $old_table)
 {
     switch ($old_table->getVersion()) {
         case 1:
             if ($res = $old_table->doSelectAll()) {
                 $customdatatypes_table = TBGCustomDatatype::getB2DBTable();
                 $crit = $customdatatypes_table->getCriteria();
                 $crit->indexBy(TBGCustomFieldsTable::FIELD_KEY);
                 $customfields = $customdatatypes_table->select($crit);
                 while ($row = $res->getNextRow()) {
                     $key = $row->get('customfieldoptions.customfield_key');
                     $customfield = array_key_exists($key, $customfields) ? $customfields[$key] : null;
                     if ($customfield instanceof TBGCustomDatatype) {
                         $crit = $this->getCriteria();
                         $crit->addUpdate(self::CUSTOMFIELD_ID, $customfield->getID());
                         $this->doUpdateById($crit, $row->get(self::ID));
                     } else {
                         $this->doDeleteById($row->get(self::ID));
                     }
                 }
             }
             break;
     }
 }
 public function _migrateData(\b2db\Table $old_table)
 {
     switch ($old_table->getVersion()) {
         case 1:
             if ($res = $old_table->doSelectAll()) {
                 $customfields = TBGCustomDatatype::getB2DBTable()->selectAll();
                 while ($row = $res->getNextRow()) {
                     $customfield_id = $row->get(self::CUSTOMFIELDS_ID);
                     $customfield = array_key_exists($customfield_id, $customfields) ? $customfields[$customfield_id] : null;
                     if ($customfield instanceof TBGCustomDatatype && $customfield->hasCustomOptions()) {
                         $customfieldoption = TBGCustomFieldOptionsTable::getTable()->getByValueAndCustomfieldID((int) $row->get(self::OPTION_VALUE), $customfield->getID());
                         if ($customfieldoption instanceof TBGCustomDatatypeOption) {
                             $crit = $this->getCriteria();
                             $crit->addUpdate(self::CUSTOMFIELDOPTION_ID, $customfieldoption->getID());
                             $crit->addUpdate(self::OPTION_VALUE, null);
                             $this->doUpdateById($crit, $row->get(self::ID));
                         } elseif ($row->get(self::ID)) {
                             $this->doDeleteById($row->get(self::ID));
                         }
                     }
                 }
             }
             break;
     }
 }