* Adjust install.

This commit is contained in:
leiyong
2020-11-24 00:17:32 +08:00
parent fa4bb5a280
commit 6f8d41b767
2 changed files with 41 additions and 33 deletions
+7 -8
View File
@@ -1222,7 +1222,6 @@ CREATE TABLE IF NOT EXISTS `zt_user` (
`type` char(30) NOT NULL default 'inside',
`dept` mediumint(8) unsigned NOT NULL default '0',
`account` char(30) NOT NULL default '',
`type` char(30) NOT NULL DEFAULT 'inside',
`password` char(32) NOT NULL default '',
`role` char(10) NOT NULL default '',
`realname` varchar(100) NOT NULL default '',
@@ -1379,14 +1378,14 @@ CREATE TABLE IF NOT EXISTS `zt_weeklyreport`(
UNIQUE KEY `week` (`PRJ`,`weekStart`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_workestimation`;
CREATE TABLE IF NOT EXISTS `zt_workestimation` (
CREATE TABLE `zt_workestimation` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`PRJ` mediumint(8) unsigned NOT NULL,
`scale` mediumint(8) unsigned NOT NULL,
`productivity` smallint(3) unsigned NOT NULL,
`duration` mediumint(8) unsigned NOT NULL,
`unitLaborCost` mediumint(8) unsigned NOT NULL,
`totalLaborCost` mediumint(8) unsigned NOT NULL,
`scale` decimal(10,2) unsigned NOT NULL,
`productivity` decimal(10,2) unsigned NOT NULL,
`duration` decimal(10,2) unsigned NOT NULL,
`unitLaborCost` decimal(10,2) unsigned NOT NULL,
`totalLaborCost` decimal(10,2) unsigned NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
@@ -1394,7 +1393,7 @@ CREATE TABLE IF NOT EXISTS `zt_workestimation` (
`assignedTo` varchar(30) NOT NULL,
`assignedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
`dayHour` float(5,2) DEFAULT NULL,
`dayHour` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `zt_log`;
+34 -25
View File
@@ -445,35 +445,44 @@ class installModel extends model
*/
public function createTable($version)
{
$this->dbh->exec("USE {$this->config->db->name}");
$dbFile = $this->app->getAppRoot() . 'db' . DS . 'zentao.sql';
$tables = explode(';', file_get_contents($dbFile));
foreach($tables as $table)
/* Add exception handling to ensure that all SQL is executed successfully. */
try
{
$table = trim($table);
if(empty($table)) continue;
$this->dbh->exec("USE {$this->config->db->name}");
if(strpos($table, 'CREATE') !== false and $version <= 4.1)
$dbFile = $this->app->getAppRoot() . 'db' . DS . 'zentao.sql';
$tables = explode(';', file_get_contents($dbFile));
foreach($tables as $table)
{
$table = str_replace('DEFAULT CHARSET=utf8', '', $table);
$table = trim($table);
if(empty($table)) continue;
if(strpos($table, 'CREATE') !== false and $version <= 4.1)
{
$table = str_replace('DEFAULT CHARSET=utf8', '', $table);
}
elseif(strpos($table, 'DROP') !== false and $this->post->clearDB != false)
{
$table = str_replace('--', '', $table);
}
$table = str_replace('__DELIMITER__', ';', $table);
$table = str_replace('__TABLE__', $this->config->db->name, $table);
/* Skip sql that is note. */
if(strpos($table, '--') === 0) continue;
$table = str_replace('`zt_', $this->config->db->name . '.`zt_', $table);
$table = str_replace('`ztv_', $this->config->db->name . '.`ztv_', $table);
$table = str_replace('zt_', $this->config->db->prefix, $table);
if(!$this->dbh->query($table)) return false;
}
elseif(strpos($table, 'DROP') !== false and $this->post->clearDB != false)
{
$table = str_replace('--', '', $table);
}
$table = str_replace('__DELIMITER__', ';', $table);
$table = str_replace('__TABLE__', $this->config->db->name, $table);
/* Skip sql that is note. */
if(strpos($table, '--') === 0) continue;
$table = str_replace('`zt_', $this->config->db->name . '.`zt_', $table);
$table = str_replace('`ztv_', $this->config->db->name . '.`ztv_', $table);
$table = str_replace('zt_', $this->config->db->prefix, $table);
if(!$this->dbh->query($table)) return false;
}
catch (PDOException $exception)
{
echo $exception->getMessage();
die();
}
return true;
}