* finish task #1893.

This commit is contained in:
wangyidong
2014-06-20 02:18:08 +00:00
parent e28cfa8efc
commit eee2645fdb
5 changed files with 85 additions and 100 deletions

View File

@@ -73,15 +73,6 @@ fi
echo $checkdb > $basePath/checkdb.sh
echo "checkdb.sh ok"
# win to unix
if [ $requestType == 'PATH_INFO' ]; then
win2Unix="$phpcli $basePath/ztcli '$pmsRoot/admin-win2Unix'";
else
win2Unix="$phpcli $basePath/ztcli '$pmsRoot/index.php?m=admin&f=win2Unix'";
fi
echo $win2Unix > $basePath/win2unix.sh
echo "win2unix.sh ok"
# syncsvn.
if [ $requestType == 'PATH_INFO' ]; then
syncsvn="$phpcli $basePath/ztcli '$pmsRoot/svn-run'";

View File

@@ -1,60 +0,0 @@
<?php
error_reporting(E_ALL);
include dirname(dirname(dirname(__FILE__))) . "/config/config.php";
$tables2Rename = array();
$tables2Rename['zt_casestep'] = 'zt_caseStep';
$tables2Rename['zt_doclib'] = 'zt_docLib';
$tables2Rename['zt_grouppriv'] = 'zt_groupPriv';
$tables2Rename['zt_productplan'] = 'zt_productPlan';
$tables2Rename['zt_projectproduct'] = 'zt_projectProduct';
$tables2Rename['zt_projectstory'] = 'zt_projectStory';
$tables2Rename['zt_storyspec'] = 'zt_storySpec';
$tables2Rename['zt_taskestimate'] = 'zt_taskEstimate';
$tables2Rename['zt_testresult'] = 'zt_testResult';
$tables2Rename['zt_testrun'] = 'zt_testRun';
$tables2Rename['zt_testtask'] = 'zt_testTask';
$tables2Rename['zt_usercontact'] = 'zt_userContact';
$tables2Rename['zt_usergroup'] = 'zt_userGroup';
$tables2Rename['zt_userquery'] = 'zt_userQuery';
$tables2Rename['zt_usertpl'] = 'zt_userTPL';
/* Zentao Pro table. */
$tables2Rename['zt_relationoftasks'] = 'zt_relationOfTasks';
$tables2Rename['zt_repohistory'] = 'zt_repoHistory';
try
{
$params = $config->db;
$dbh = new PDO("mysql:host={$params->host}; port={$params->port}; dbname={$params->name}", $params->user, $params->password);
$dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec("SET NAMES utf8");
}
catch(PDOException $e)
{
echo 'Connection failed: ' . $e->getMessage() . "\n";
die("connect to db failed.\n");
}
$tablesExists = $dbh->query('SHOW TABLES')->fetchAll();
foreach($tablesExists as $key => $table) $tablesExists[$key] = current((array)$table);
$tablesExists = array_flip($tablesExists);
foreach($tables2Rename as $oldTable => $newTable)
{
if(isset($tablesExists[$newTable]))
{
echo "Has existed table '$newTable'\n";
}
elseif(!isset($tablesExists[$oldTable]))
{
echo "No found table '$oldTable'\n";
}
else
{
$dbh->query("RENAME TABLE `$oldTable` TO `$newTable`");
echo "RENAME TABLE `$oldTable` TO `$newTable`\n";
}
}
echo "Finish!\n";

View File

@@ -119,8 +119,8 @@ CREATE TABLE IF NOT EXISTS `zt_case` (
`lastRunResult` char(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_caseStep`;
CREATE TABLE IF NOT EXISTS `zt_caseStep` (
-- DROP TABLE IF EXISTS `zt_casestep`;
CREATE TABLE IF NOT EXISTS `zt_casestep` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`case` mediumint(8) unsigned NOT NULL default '0',
`version` smallint(3) unsigned NOT NULL default '0',
@@ -201,8 +201,8 @@ CREATE TABLE IF NOT EXISTS `zt_doc` (
`deleted` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_docLib`;
CREATE TABLE IF NOT EXISTS `zt_docLib` (
-- DROP TABLE IF EXISTS `zt_doclib`;
CREATE TABLE IF NOT EXISTS `zt_doclib` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL,
`deleted` enum('0','1') NOT NULL default '0',
@@ -270,8 +270,8 @@ CREATE TABLE IF NOT EXISTS `zt_group` (
`desc` char(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_groupPriv`;
CREATE TABLE IF NOT EXISTS `zt_groupPriv` (
-- DROP TABLE IF EXISTS `zt_grouppriv`;
CREATE TABLE IF NOT EXISTS `zt_grouppriv` (
`group` mediumint(8) unsigned NOT NULL default '0',
`module` char(30) NOT NULL default '',
`method` char(30) NOT NULL default '',
@@ -318,8 +318,8 @@ CREATE TABLE IF NOT EXISTS `zt_product` (
`deleted` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_productPlan`;
CREATE TABLE IF NOT EXISTS `zt_productPlan` (
-- DROP TABLE IF EXISTS `zt_productplan`;
CREATE TABLE IF NOT EXISTS `zt_productplan` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`product` mediumint(8) unsigned NOT NULL,
`title` varchar(90) NOT NULL,
@@ -363,14 +363,14 @@ CREATE TABLE IF NOT EXISTS `zt_project` (
PRIMARY KEY (`id`),
KEY `project` (`type`,`parent`,`begin`,`end`,`status`,`statge`,`pri`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_projectProduct`;
CREATE TABLE IF NOT EXISTS `zt_projectProduct` (
-- DROP TABLE IF EXISTS `zt_projectproduct`;
CREATE TABLE IF NOT EXISTS `zt_projectproduct` (
`project` mediumint(8) unsigned NOT NULL,
`product` mediumint(8) unsigned NOT NULL,
PRIMARY KEY (`project`,`product`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_projectStory`;
CREATE TABLE IF NOT EXISTS `zt_projectStory` (
-- DROP TABLE IF EXISTS `zt_projectstory`;
CREATE TABLE IF NOT EXISTS `zt_projectstory` (
`project` mediumint(8) unsigned NOT NULL default '0',
`product` mediumint(8) unsigned NOT NULL,
`story` mediumint(8) unsigned NOT NULL default '0',
@@ -428,8 +428,8 @@ CREATE TABLE IF NOT EXISTS `zt_story` (
KEY `product` (`product`,`module`,`plan`,`type`,`pri`),
KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_storySpec`;
CREATE TABLE IF NOT EXISTS `zt_storySpec` (
-- DROP TABLE IF EXISTS `zt_storyspec`;
CREATE TABLE IF NOT EXISTS `zt_storyspec` (
`story` mediumint(9) NOT NULL,
`version` smallint(6) NOT NULL,
`title` varchar(90) NOT NULL,
@@ -476,8 +476,8 @@ CREATE TABLE IF NOT EXISTS `zt_task` (
KEY `statusOrder` (`statusCustom`),
KEY `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_taskEstimate`;
CREATE TABLE IF NOT EXISTS `zt_taskEstimate` (
-- DROP TABLE IF EXISTS `zt_taskestimate`;
CREATE TABLE IF NOT EXISTS `zt_taskestimate` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`task` mediumint(8) unsigned NOT NULL default '0',
`date` date NOT NULL,
@@ -498,8 +498,8 @@ CREATE TABLE IF NOT EXISTS `zt_team` (
`hours` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`project`,`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_testResult`;
CREATE TABLE IF NOT EXISTS `zt_testResult` (
-- DROP TABLE IF EXISTS `zt_testresult`;
CREATE TABLE IF NOT EXISTS `zt_testresult` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`run` mediumint(8) unsigned NOT NULL,
`case` mediumint(8) unsigned NOT NULL,
@@ -512,8 +512,8 @@ CREATE TABLE IF NOT EXISTS `zt_testResult` (
KEY `run` (`run`),
KEY `case` (`case`,`version`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_testRun`;
CREATE TABLE IF NOT EXISTS `zt_testRun` (
-- DROP TABLE IF EXISTS `zt_testrun`;
CREATE TABLE IF NOT EXISTS `zt_testrun` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`task` mediumint(8) unsigned NOT NULL default '0',
`case` mediumint(8) unsigned NOT NULL default '0',
@@ -526,8 +526,8 @@ CREATE TABLE IF NOT EXISTS `zt_testRun` (
PRIMARY KEY (`id`),
UNIQUE KEY `task` (`task`,`case`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_testTask`;
CREATE TABLE IF NOT EXISTS `zt_testTask` (
-- DROP TABLE IF EXISTS `zt_testtask`;
CREATE TABLE IF NOT EXISTS `zt_testtask` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`name` char(90) NOT NULL,
`product` mediumint(8) unsigned NOT NULL,
@@ -594,22 +594,22 @@ CREATE TABLE IF NOT EXISTS `zt_user` (
UNIQUE KEY `account` (`account`),
KEY `dept` (`dept`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_userContact`;
CREATE TABLE IF NOT EXISTS `zt_userContact` (
-- DROP TABLE IF EXISTS `zt_usercontact`;
CREATE TABLE IF NOT EXISTS `zt_usercontact` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`account` char(30) NOT NULL,
`listName` varchar(60) NOT NULL,
`userList` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_userGroup`;
CREATE TABLE IF NOT EXISTS `zt_userGroup` (
-- DROP TABLE IF EXISTS `zt_usergroup`;
CREATE TABLE IF NOT EXISTS `zt_usergroup` (
`account` char(30) NOT NULL default '',
`group` mediumint(8) unsigned NOT NULL default '0',
UNIQUE KEY `account` (`account`,`group`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_userQuery`;
CREATE TABLE IF NOT EXISTS `zt_userQuery` (
-- DROP TABLE IF EXISTS `zt_userquery`;
CREATE TABLE IF NOT EXISTS `zt_userquery` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`account` char(30) NOT NULL,
`module` varchar(30) NOT NULL,
@@ -620,8 +620,8 @@ CREATE TABLE IF NOT EXISTS `zt_userQuery` (
KEY `account` (`account`),
KEY `module` (`module`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_userTPL`;
CREATE TABLE IF NOT EXISTS `zt_userTPL` (
-- DROP TABLE IF EXISTS `zt_usertpl`;
CREATE TABLE IF NOT EXISTS `zt_usertpl` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`account` char(30) NOT NULL,
`type` char(30) NOT NULL,
@@ -644,7 +644,7 @@ INSERT INTO `zt_group` (`id`, `name`, `role`, `desc`) VALUES
(10, 'OTHERS', '', 'for others.'),
(11, 'guest', 'guest', 'For guest');
INSERT INTO `zt_groupPriv` (`group`, `module`, `method`) VALUES
INSERT INTO `zt_grouppriv` (`group`, `module`, `method`) VALUES
(1, 'action', 'hideAll'),
(1, 'action', 'hideOne'),
(1, 'action', 'trash'),

17
module/upgrade/config.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
$config->upgrade->lowerTables = array();
$config->upgrade->lowerTables['zt_caseStep'] = 'zt_casestep';
$config->upgrade->lowerTables['zt_docLib'] = 'zt_doclib';
$config->upgrade->lowerTables['zt_groupPriv'] = 'zt_grouppriv';
$config->upgrade->lowerTables['zt_productPlan'] = 'zt_productplan';
$config->upgrade->lowerTables['zt_projectProduct'] = 'zt_projectproduct';
$config->upgrade->lowerTables['zt_projectStory'] = 'zt_projectstory';
$config->upgrade->lowerTables['zt_storySpec'] = 'zt_storyspec';
$config->upgrade->lowerTables['zt_taskEstimate'] = 'zt_taskestimate';
$config->upgrade->lowerTables['zt_testResult'] = 'zt_testresult';
$config->upgrade->lowerTables['zt_testRun'] = 'zt_testrun';
$config->upgrade->lowerTables['zt_testTask'] = 'zt_testtask';
$config->upgrade->lowerTables['zt_userContact'] = 'zt_usercontact';
$config->upgrade->lowerTables['zt_userGroup'] = 'zt_usergroup';
$config->upgrade->lowerTables['zt_userQuery'] = 'zt_userquery';
$config->upgrade->lowerTables['zt_userTPL'] = 'zt_usertpl';

View File

@@ -710,6 +710,43 @@ class upgradeModel extends model
return true;
}
public function toLowerTable($build = 'basic')
{
$results = $this->dbh->query("show Variables like '%table_names'")->fetchAll();
$hasLowered = false;
foreach($results as $result)
{
if(strtolower($result->Variable_name) == 'lower_case_table_names' and $result->Value == 1)
{
$hasLowered = true;
break;
}
}
if($hasLowered) return true;
if($build == 'basic') $tables2Rename = $this->config->upgrade->lowerTables;
if(!isset($tables2Rename)) return false;
$tablesExists = $this->dbh->query('SHOW TABLES')->fetchAll();
foreach($tablesExists as $key => $table) $tablesExists[$key] = current((array)$table);
$tablesExists = array_flip($tablesExists);
foreach($tables2Rename as $oldTable => $newTable)
{
if(!isset($tablesExists[$oldTable])) continue;
$upgradebak = $newTable . '_othertablebak';
if(isset($tablesExists[$upgradebak])) $this->dbh->query("DROP TABLE `$upgradebak`");
if(isset($tablesExists[$newTable])) $this->dbh->query("RENAME TABLE `$newTable` TO `$upgradebak`");
$tempTable = $oldTable . '_zentaotmp';
$this->dbh->query("RENAME TABLE `$oldTable` TO `$tempTable`");
$this->dbh->query("RENAME TABLE `$tempTable` TO `$newTable`");
}
return true;
}
/**
* Process finishedBy and finishedDate of task.
*