diff --git a/db/zentao.sql b/db/zentao.sql index adcd98dcc6..0a01d6be19 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -669,7 +669,7 @@ CREATE TABLE IF NOT EXISTS `zt_doc` ( `from` mediumint(8) unsigned NOT NULL DEFAULT '0', `fromVersion` smallint(6) NOT NULL DEFAULT '1', `draft` longtext NOT NULL, - `collector` text NULL, + `collects` smallint(5) unsigned NOT NULL DEFAULT '0', `addedBy` varchar(30) NOT NULL, `addedDate` datetime NOT NULL, `assignedTo` varchar(30) NOT NULL DEFAULT '', diff --git a/module/doc/model.php b/module/doc/model.php index b20f3b21ec..1665c2bb4a 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -3271,7 +3271,7 @@ class docModel extends model if($action == 'collect') { $collectCount = $this->dao->select('count(*) as count')->from(TABLE_DOCACTION)->where('doc')->eq($docID)->andWhere('action')->eq('collect')->fetch('count'); - $this->dao->update(TABLE_DOC)->set('collector')->eq($collectCount)->where('id')->eq($docID)->exec(); + $this->dao->update(TABLE_DOC)->set('collects')->eq($collectCount)->where('id')->eq($docID)->exec(); } return $actionID; @@ -3307,7 +3307,7 @@ class docModel extends model if($action->action == 'collect') { $collectCount = $this->dao->select('count(*) as count')->from(TABLE_DOCACTION)->where('doc')->eq($action->doc)->andWhere('action')->eq('collect')->fetch('count'); - $this->dao->update(TABLE_DOC)->set('collector')->eq($collectCount)->where('id')->eq($action->doc)->exec(); + $this->dao->update(TABLE_DOC)->set('collects')->eq($collectCount)->where('id')->eq($action->doc)->exec(); } } diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 879e69d4cc..dc661007d5 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -9062,6 +9062,16 @@ class upgradeModel extends model */ public function convertDocCollect() { + $this->saveLogs('Run Method ' . __FUNCTION__); + $desc = $this->dao->query('DESC ' . TABLE_DOC)->fetchAll(); + $fields = array(); + foreach($desc as $field) + { + $fieldName = $field->Field; + $fields[$fieldName] = $fieldName; + } + if(!isset($fields['collector'])) return true; + $this->loadModel('doc'); $users = $this->dao->select('account')->from(TABLE_USER)->fetchPairs('account', 'account'); @@ -9078,7 +9088,7 @@ class upgradeModel extends model } $this->dao->update(TABLE_DOC)->set('collector')->eq(0)->where('collector')->eq('')->exec(); - $this->dao->exec("ALTER TABLE " . TABLE_DOC . " CHANGE `collector` `collector` smallint NOT NULL DEFAULT '0'"); + $this->dao->exec("ALTER TABLE " . TABLE_DOC . " CHANGE `collector` `collects` smallint unsigned NOT NULL DEFAULT '0'"); return true; }