From f28a05f25b5f4645bd1dafde2cc902a0984f5847 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Fri, 12 Aug 2022 16:40:51 +0800 Subject: [PATCH] * Add the xuanxuan update sql to standard sql. --- db/standard/zentao17.5.sql | 3 +++ module/upgrade/model.php | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/db/standard/zentao17.5.sql b/db/standard/zentao17.5.sql index 71e49578e5..2473991ba5 100644 --- a/db/standard/zentao17.5.sql +++ b/db/standard/zentao17.5.sql @@ -1182,11 +1182,14 @@ CREATE TABLE `zt_im_chat` ( `ownedBy` varchar(30) NOT NULL DEFAULT '', `editedBy` varchar(30) NOT NULL DEFAULT '', `editedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `mergedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `lastActiveTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `lastMessage` int(11) unsigned NOT NULL DEFAULT '0', `lastMessageIndex` int(11) unsigned NOT NULL DEFAULT 0, `dismissDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `pinnedMessages` text NOT NULL, + `mergedChats` text NOT NULL DEFAULT '', + `adminInvite` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `gid` (`gid`), KEY `name` (`name`), diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 5346f4ee33..54595796c7 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -535,8 +535,8 @@ class upgradeModel extends model if(!$executedXuanxuan) { $table = $this->config->db->prefix . 'im_chat'; - $result = $this->checkFieldsExists($table, 'adminInvite'); - if($result->rowCount() == 0) + $exists = $this->checkFieldsExists($table, 'adminInvite'); + if(!$exists) { $this->dbh->query("ALTER TABLE $table ADD `adminInvite` enum('0','1') NOT NULL DEFAULT '0' AFTER `mergedChats`"); } @@ -7052,10 +7052,12 @@ class upgradeModel extends model * @param string $table * @param string $field * @access public - * @return object + * @return bool */ public function checkFieldsExists($table, $field) { - return $this->dbh->query("show columns from `$table` like '$field'"); + $result = $this->dbh->query("show columns from `$table` like '$field'"); + + return $result->rowCount() > 0; } }