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;
     }
 }
Example #4
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addVarchar(self::IDENTITY, 300);
     parent::_addVarchar(self::IDENTITY_HASH, 300);
     parent::_addVarchar(self::EMAIL, 300);
     parent::_addVarchar(self::TYPE, 300);
     parent::_addForeignKeyColumn(self::UID, Users::getTable(), Users::ID);
 }
 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');
     }
 }
Example #6
0
 protected function _migrateData(\b2db\Table $old_table)
 {
     $crit = $old_table->getCriteria();
     $old_table->doDelete($crit);
     //            foreach (array(self::TYPE_USER, self::TYPE_PROJECT) as $target_type)
     //            {
     //                $crit = $this->getCriteria();
     //                $crit->addSelectionColumn('dashboard_views.tid', 'target_id', Criteria::DB_DISTINCT);
     //                $crit->addSelectionColumn('dashboard_views.scope');
     //                $crit->addWhere('dashboard_views.target_type', $target_type);
     //                $res = $this->doSelect($crit, 'none');
     //                $views = array();
     //                if ($res)
     //                {
     //                    while ($row = $res->getNextRow())
     //                    {
     //                        $dashboard = new Dashboard();
     //                        $dashboard->setName('Dashboard');
     //                        $dashboard->setIsDefault(true);
     //                        if ($target_type == self::TYPE_USER)
     //                            $dashboard->setUser($row['target_id']);
     //                        elseif ($target_type == self::TYPE_PROJECT)
     //                            $dashboard->setProject($row['target_id']);
     //
     //                        $dashboard->setScope($row['dashboard_views.scope']);
     //                        $dashboard->save();
     //
     //                        $views[$dashboard->getID()] = array('target_id' => $row['target_id'], 'scope_id' => $row['dashboard_views.scope']);
     //                    }
     //
     //                    foreach ($views as $dashboard_id => $target)
     //                    {
     //                        $crit = $this->getCriteria();
     //                        $crit->addUpdate('dashboard_views.dashboard_id', $dashboard_id);
     //                        $crit->addWhere('dashboard_views.tid', $target['target_id']);
     //                        $crit->addWhere('dashboard_views.target_type', $target_type);
     //                        $crit->addWhere('dashboard_views.scope', $target['scope_id']);
     //                        $this->doUpdate($crit);
     //                    }
     //                }
     //            }
 }
 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;
     }
 }
Example #8
0
 protected function _initialize()
 {
     parent::_setup(self::B2DBNAME, self::ID);
     parent::_addVarchar(self::UNAME, 50);
     parent::_addVarchar(self::PASSWORD, 100);
     parent::_addVarchar(self::BUDDYNAME, 50);
     parent::_addVarchar(self::REALNAME, 100);
     parent::_addVarchar(self::EMAIL, 200);
     parent::_addInteger(self::USERSTATE, 10);
     parent::_addBoolean(self::CUSTOMSTATE);
     parent::_addVarchar(self::HOMEPAGE, 250, '');
     parent::_addVarchar(self::LANGUAGE, 100, '');
     parent::_addInteger(self::LASTSEEN, 10);
     parent::_addInteger(self::QUOTA);
     parent::_addBoolean(self::ACTIVATED);
     parent::_addBoolean(self::ENABLED);
     parent::_addBoolean(self::DELETED);
     parent::_addVarchar(self::AVATAR, 30, '');
     parent::_addBoolean(self::USE_GRAVATAR, true);
     parent::_addBoolean(self::PRIVATE_EMAIL);
     parent::_addBoolean(self::OPENID_LOCKED);
     parent::_addInteger(self::JOINED, 10);
 }
 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;
     }
 }
Example #10
0
 protected function _setup($b2db_name, $id_column)
 {
     parent::_setup($b2db_name, $id_column);
     parent::_addForeignKeyColumn(static::SCOPE, \thebuggenie\core\entities\tables\Scopes::getTable(), \thebuggenie\core\entities\tables\Scopes::ID);
 }
Example #11
0
 private function _fixNonUserDependentTimezone($offsets, \b2db\Table $table, $correctionfield, $scope, $testfield = null)
 {
     $crit = $table->getCriteria();
     $crit->addWhere($table::SCOPE, $scope->getID());
     $res = $table->doSelect($crit);
     if (is_null($res)) {
         return;
         // nothing to update
     }
     while ($row = $res->getNextRow()) {
         if ($testfield !== null) {
             if ($row->get($testfield) != 1) {
                 continue;
             }
         }
         $offset = $offsets['system'];
         $crit2 = $table->getCriteria();
         if (!is_array($correctionfield)) {
             $correctionfield = array($correctionfield);
         }
         $added = 0;
         foreach ($correctionfield as $field) {
             // If the timestamp is 0, don't correct as it is unset
             if ($row->get($field) == 0) {
                 continue;
             }
             $crit2->addUpdate($field, (int) $row->get($field) + $offset);
             $added = 1;
             // Mark that we have actually added something
         }
         // Don't update if no addUpdate calls made
         if ($added == 1) {
             $crit2->addWhere($table::ID, $row->get($table::ID));
             $table->doUpdate($crit2);
         }
     }
 }