diff --git a/module/upgrade/model.php b/module/upgrade/model.php index f9621fe23f..bb731d51b6 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -8771,6 +8771,7 @@ class upgradeModel extends model } /** + * 为喧喧表添加adminInvite字段。 * Add adminInvite field for xuanxuan. * * @access public @@ -8780,7 +8781,7 @@ class upgradeModel extends model { $table = $this->config->db->prefix . 'im_chat'; $exists = $this->checkFieldsExists($table, 'adminInvite'); - if(!$exists) $this->dbh->exec("ALTER TABLE $table ADD `adminInvite` enum('0','1') NOT NULL DEFAULT '0' AFTER `mergedChats`"); + if(!$exists) $this->dbh->exec("ALTER TABLE {$table} ADD `adminInvite` enum('0','1') NOT NULL DEFAULT '0' AFTER `mergedChats`"); } /** diff --git a/module/upgrade/test/model/addadmininvitefield.php b/module/upgrade/test/model/addadmininvitefield.php new file mode 100644 index 0000000000..dca5e091f0 --- /dev/null +++ b/module/upgrade/test/model/addadmininvitefield.php @@ -0,0 +1,34 @@ +#!/usr/bin/env php +hasConsistencyError(); +cid=1 + +- 修改后,im_chart表中存在adminInvite字段 @adminInvite + +**/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/upgrade.class.php'; +zdTable('user')->gen(1); +su('admin'); + +$upgrade = new upgradeTest(); + +$checkExistSql = "show columns from `%s` like '%s'"; +$dropSql = "Alter table `%s` drop column `%s`"; + +global $config, $tester; +$table = $config->db->prefix . 'im_chat'; +$column = 'adminInvite'; + +$result = $tester->dbh->query(sprintf($checkExistSql, $table, $column))->fetch(); +if($result) $deleteAction = $tester->dbh->exec(sprintf($dropSql, $table, $column)); //检测到adminInvite字段存在,删除该字段 + +$upgrade->addAdminInviteField(); +$result2 = $tester->dbh->query(sprintf($checkExistSql, $table, $column))->fetch(); + +r($result2) && p('Field') && e('adminInvite'); //修改后,im_chart表中存在adminInvite字段 diff --git a/module/upgrade/test/model/hasconsistencyerror.php b/module/upgrade/test/model/hasconsistencyerror.php index 0d054a12ab..076d036291 100644 --- a/module/upgrade/test/model/hasconsistencyerror.php +++ b/module/upgrade/test/model/hasconsistencyerror.php @@ -17,7 +17,6 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/upgrade.class.php'; global $app; - $path = $app->getTmpRoot() . 'log/'; $filename = 'consistency.%s.log.php';