* adjust for change table engine in upgrade.

This commit is contained in:
wangyidong
2022-08-08 14:05:50 +08:00
parent 0e7fde7030
commit 660c82b46e
8 changed files with 261 additions and 118 deletions
-4
View File
@@ -2,10 +2,6 @@ ALTER TABLE `zt_task` ADD `order` mediumint(8) NOT NULL DEFAULT 0 AFTER `activat
ALTER TABLE `zt_task` ADD INDEX `order` (`order`);
ALTER TABLE `zt_story` ADD COLUMN `linkRequirements` varchar(255) NOT NULL AFTER `linkStories`;
ALTER TABLE `zt_searchindex` ADD FULLTEXT `title_content` (`title`, `content`);
ALTER TABLE `zt_searchindex` DROP INDEX `title`;
ALTER TABLE `zt_searchindex` DROP INDEX `content`;
ALTER TABLE `zt_productplan` ADD `createdBy` varchar(30) NOT NULL AFTER `closedReason`;
ALTER TABLE `zt_productplan` ADD `createdDate` datetime NOT NULL AFTER `createdBy`;
+63
View File
@@ -906,6 +906,69 @@ class upgrade extends control
echo $this->dao->select('status')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch('status');
}
/**
* Ajax change table engine.
*
* @access public
* @return void
*/
public function ajaxChangeTableEngine()
{
$response = array();
$response['result'] = 'continue';
$response['message'] = '';
$response['nextMessage'] = '';
$stmt = $this->dao->query("SHOW TABLE STATUS WHERE `Engine` is not null AND `Engine` = 'MyISAM'");
$table = $stmt->fetch();
if(empty($table))
{
$response['result'] = 'finished';
$response['message'] = $this->lang->upgrade->finishedChange;
return print(json_encode($response));
}
$nextTable = $stmt->fetch();
if(stripos($nextTable->Name, 'searchindex') !== false)
{
$mysqlVersion = $this->loadModel('install')->getMysqlVersion();
if($mysqlVersion < 5.6) return print(json_encode($response));
$nextTable = $stmt->fetch();
}
$tableName = $table->Name;
$response['table'] = $tableName;
$response['next'] = $nextTable->Name;
if($response['next']) $response['nextMessage'] = sprintf($this->lang->upgrade->changingTable, $response['next']);
if(stripos($tableName, 'searchindex') !== false)
{
$stmt = $this->dao->query("show index from `$tableName`");
$indexes = array();
while($index = $stmt->fetch())
{
if($index->Index_type != 'FULLTEXT') continue;
$indexes[$index->Key_name] = $index->Key_name;
}
if(!isset($indexes['title_content'])) $this->dao->exec( "ALTER TABLE `{$tableName}` ADD FULLTEXT `title_content` (`title`, `content`)");
if(isset($indexes['title'])) $this->dao->exec( "ALTER TABLE `{$tableName}` DROP INDEX `title`");
if(isset($indexes['content'])) $this->dao->exec( "ALTER TABLE `{$tableName}` DROP INDEX `content`");
$mysqlVersion = $this->loadModel('install')->getMysqlVersion();
if($mysqlVersion < 5.6) return print(json_encode($response));
}
$sql = "ALTER TABLE `$tableName` ENGINE='InnoDB'";
$this->dao->exec($sql);
$response['message'] = sprintf($this->lang->upgrade->finishedTable, $tableName);
return print(json_encode($response));
}
/**
* Move Extent files.
*
+23 -19
View File
@@ -41,25 +41,29 @@ $lang->upgrade->setStatusFile = '<h4>Please complete the following actions<
</ul>
<p><strong style="color:red">I have read and done as instructed above. <a href="upgrade.php">Continue upgrading.</a></strong></p>';
$lang->upgrade->selectVersion = 'Version auswählen';
$lang->upgrade->continue = 'Weiter';
$lang->upgrade->noteVersion = "Wählen Sie eine kompatible Version oder es droht Datenverlust.";
$lang->upgrade->fromVersion = 'Von Version';
$lang->upgrade->toVersion = 'Upgrade nach Version';
$lang->upgrade->confirm = 'SQL Bestätigen';
$lang->upgrade->sureExecute = 'Ausführen';
$lang->upgrade->upgradingTips = 'The upgrade is in progress, please be patient. Do not refresh the page, blackout, or turn off your computer!';
$lang->upgrade->forbiddenExt = 'Die Erweiterung ist nicht kompatibel mit der Upgradeversion. Sie wurde deaktiviert:';
$lang->upgrade->updateFile = 'Updateinformation wurden hinzugefügt.';
$lang->upgrade->noticeSQL = 'Your database is inconsistent with the standard and it failed to fix it. Please run the following SQL and refresh.';
$lang->upgrade->afterDeleted = 'File is not deleted. Please refresh after you delete it.';
$lang->upgrade->mergeProgram = 'Data Merge';
$lang->upgrade->mergeTips = 'Data Migration Tips';
$lang->upgrade->toPMS15Guide = 'ZenTao open source version 15 upgrade';
$lang->upgrade->toPRO10Guide = 'ZenTao profession version 10 upgrade';
$lang->upgrade->toBIZ5Guide = 'ZenTao enterprise version 5 upgrade';
$lang->upgrade->toMAXGuide = 'ZenTao ultimate version upgrade';
$lang->upgrade->to15Desc = <<<EOD
$lang->upgrade->selectVersion = 'Version auswählen';
$lang->upgrade->continue = 'Weiter';
$lang->upgrade->noteVersion = "Wählen Sie eine kompatible Version oder es droht Datenverlust.";
$lang->upgrade->fromVersion = 'Von Version';
$lang->upgrade->toVersion = 'Upgrade nach Version';
$lang->upgrade->confirm = 'SQL Bestätigen';
$lang->upgrade->sureExecute = 'Ausführen';
$lang->upgrade->upgradingTips = 'The upgrade is in progress, please be patient. Do not refresh the page, blackout, or turn off your computer!';
$lang->upgrade->forbiddenExt = 'Die Erweiterung ist nicht kompatibel mit der Upgradeversion. Sie wurde deaktiviert:';
$lang->upgrade->updateFile = 'Updateinformation wurden hinzugefügt.';
$lang->upgrade->changeEngine = 'The database engine needs to be modified.';
$lang->upgrade->changingTable = 'Replacing data table %s engine...';
$lang->upgrade->finishedTable = 'The data table %s engine has been changed to InnoDB.';
$lang->upgrade->finishedChange = 'The replacement of the database engine is completed.';
$lang->upgrade->noticeSQL = 'Your database is inconsistent with the standard and it failed to fix it. Please run the following SQL and refresh.';
$lang->upgrade->afterDeleted = 'File is not deleted. Please refresh after you delete it.';
$lang->upgrade->mergeProgram = 'Data Merge';
$lang->upgrade->mergeTips = 'Data Migration Tips';
$lang->upgrade->toPMS15Guide = 'ZenTao open source version 15 upgrade';
$lang->upgrade->toPRO10Guide = 'ZenTao profession version 10 upgrade';
$lang->upgrade->toBIZ5Guide = 'ZenTao enterprise version 5 upgrade';
$lang->upgrade->toMAXGuide = 'ZenTao ultimate version upgrade';
$lang->upgrade->to15Desc = <<<EOD
<p>ZenTao version 15.0 has major upgrade of features, including:</p>
<p><strong>1. Add the concept of Program</strong></p>
<p>A program is a collection of interrelated and coordinated projects. It is at the highest level and belongs to the concept of a strategic level. It has multi-level project management, helping managers to form strategic directions and allocate resources at a macro level.</p>
+23 -19
View File
@@ -41,25 +41,29 @@ $lang->upgrade->setStatusFile = '<h4>Please complete the following actions<
</ul>
<p><strong style="color:red">I have read and done as instructed above. <a href="upgrade.php">Continue upgrading.</a></strong></p>';
$lang->upgrade->selectVersion = 'Version';
$lang->upgrade->continue = 'Continue';
$lang->upgrade->noteVersion = "Select the compatible version, or it might cause data loss.";
$lang->upgrade->fromVersion = 'From';
$lang->upgrade->toVersion = 'To';
$lang->upgrade->confirm = 'Confirm SQL';
$lang->upgrade->sureExecute = 'Execute';
$lang->upgrade->upgradingTips = 'The upgrade is in progress, please be patient. Do not refresh the page, blackout, or turn off your computer!';
$lang->upgrade->forbiddenExt = 'The extension is incompatible with the version. It has been deactivated:';
$lang->upgrade->updateFile = 'File information has to be updated.';
$lang->upgrade->noticeSQL = 'Your database is inconsistent with the standard and it failed to fix it. Please run the following SQL and refresh.';
$lang->upgrade->afterDeleted = 'Please execute commands to delete the files. Please refresh after you delete them.';
$lang->upgrade->mergeProgram = 'Data Merge';
$lang->upgrade->mergeTips = 'Data Migration Tips';
$lang->upgrade->toPMS15Guide = 'ZenTao open source version 15 upgrade';
$lang->upgrade->toPRO10Guide = 'ZenTao profession version 10 upgrade';
$lang->upgrade->toBIZ5Guide = 'ZenTao enterprise version 5 upgrade';
$lang->upgrade->toMAXGuide = 'ZenTao ultimate version upgrade';
$lang->upgrade->to15Desc = <<<EOD
$lang->upgrade->selectVersion = 'Version';
$lang->upgrade->continue = 'Continue';
$lang->upgrade->noteVersion = "Select the compatible version, or it might cause data loss.";
$lang->upgrade->fromVersion = 'From';
$lang->upgrade->toVersion = 'To';
$lang->upgrade->confirm = 'Confirm SQL';
$lang->upgrade->sureExecute = 'Execute';
$lang->upgrade->upgradingTips = 'The upgrade is in progress, please be patient. Do not refresh the page, blackout, or turn off your computer!';
$lang->upgrade->forbiddenExt = 'The extension is incompatible with the version. It has been deactivated:';
$lang->upgrade->updateFile = 'File information has to be updated.';
$lang->upgrade->changeEngine = 'The database engine needs to be modified.';
$lang->upgrade->changingTable = 'Replacing data table %s engine...';
$lang->upgrade->finishedTable = 'The data table %s engine has been changed to InnoDB.';
$lang->upgrade->finishedChange = 'The replacement of the database engine is completed.';
$lang->upgrade->noticeSQL = 'Your database is inconsistent with the standard and it failed to fix it. Please run the following SQL and refresh.';
$lang->upgrade->afterDeleted = 'Please execute commands to delete the files. Please refresh after you delete them.';
$lang->upgrade->mergeProgram = 'Data Merge';
$lang->upgrade->mergeTips = 'Data Migration Tips';
$lang->upgrade->toPMS15Guide = 'ZenTao open source version 15 upgrade';
$lang->upgrade->toPRO10Guide = 'ZenTao profession version 10 upgrade';
$lang->upgrade->toBIZ5Guide = 'ZenTao enterprise version 5 upgrade';
$lang->upgrade->toMAXGuide = 'ZenTao ultimate version upgrade';
$lang->upgrade->to15Desc = <<<EOD
<p>ZenTao version 15.0 has major upgrade of features, including:</p>
<p><strong>1. Add the concept of Program</strong></p>
<p>A program is a collection of interrelated and coordinated projects. It is at the highest level and belongs to the concept of a strategic level. It has multi-level project management, helping managers to form strategic directions and allocate resources at a macro level.</p>
+23 -19
View File
@@ -41,25 +41,29 @@ $lang->upgrade->setStatusFile = '<h4>Please complete the following actions<
</ul>
<p><strong style="color:red">I have read and done as instructed above. <a href="upgrade.php">Continue upgrading.</a></strong></p>';
$lang->upgrade->selectVersion = 'Version';
$lang->upgrade->continue = 'Continuer';
$lang->upgrade->noteVersion = "Sélectionnez une version compatible où vous pourriez perdre des données.";
$lang->upgrade->fromVersion = 'De';
$lang->upgrade->toVersion = 'à';
$lang->upgrade->confirm = 'Confirmez SQL';
$lang->upgrade->sureExecute = 'Executez';
$lang->upgrade->upgradingTips = 'La mise à jour est en cours, veuillez être patient. Ne pas actualiser la page ou éteindre votre ordinateur!';
$lang->upgrade->forbiddenExt = 'Cette extension est incompatible avec la version. Elle a été désactivée :';
$lang->upgrade->updateFile = "Le fichier information a besoin d'une mise à jour.";
$lang->upgrade->noticeSQL = 'Votre base de donnée est inconsistente avec le standard et il y a eu un échec pour la corriger. Exécutez la commande SQL suivante et rafraichissez.';
$lang->upgrade->afterDeleted = "Le fichier n'est pas supprimé. Recommencez après l'avoir supprimé.";
$lang->upgrade->mergeProgram = 'Data Merge';
$lang->upgrade->mergeTips = 'Data Migration Tips';
$lang->upgrade->toPMS15Guide = 'ZenTao open source version 15 upgrade';
$lang->upgrade->toPRO10Guide = 'ZenTao profession version 10 upgrade';
$lang->upgrade->toBIZ5Guide = 'ZenTao enterprise version 5 upgrade';
$lang->upgrade->toMAXGuide = 'ZenTao ultimate version upgrade';
$lang->upgrade->to15Desc = <<<EOD
$lang->upgrade->selectVersion = 'Version';
$lang->upgrade->continue = 'Continuer';
$lang->upgrade->noteVersion = "Sélectionnez une version compatible où vous pourriez perdre des données.";
$lang->upgrade->fromVersion = 'De';
$lang->upgrade->toVersion = 'à';
$lang->upgrade->confirm = 'Confirmez SQL';
$lang->upgrade->sureExecute = 'Executez';
$lang->upgrade->upgradingTips = 'La mise à jour est en cours, veuillez être patient. Ne pas actualiser la page ou éteindre votre ordinateur!';
$lang->upgrade->forbiddenExt = 'Cette extension est incompatible avec la version. Elle a été désactivée :';
$lang->upgrade->updateFile = "Le fichier information a besoin d'une mise à jour.";
$lang->upgrade->changeEngine = 'The database engine needs to be modified.';
$lang->upgrade->changingTable = 'Replacing data table %s engine...';
$lang->upgrade->finishedTable = 'The data table %s engine has been changed to InnoDB.';
$lang->upgrade->finishedChange = 'The replacement of the database engine is completed.';
$lang->upgrade->noticeSQL = 'Votre base de donnée est inconsistente avec le standard et il y a eu un échec pour la corriger. Exécutez la commande SQL suivante et rafraichissez.';
$lang->upgrade->afterDeleted = "Le fichier n'est pas supprimé. Recommencez après l'avoir supprimé.";
$lang->upgrade->mergeProgram = 'Data Merge';
$lang->upgrade->mergeTips = 'Data Migration Tips';
$lang->upgrade->toPMS15Guide = 'ZenTao open source version 15 upgrade';
$lang->upgrade->toPRO10Guide = 'ZenTao profession version 10 upgrade';
$lang->upgrade->toBIZ5Guide = 'ZenTao enterprise version 5 upgrade';
$lang->upgrade->toMAXGuide = 'ZenTao ultimate version upgrade';
$lang->upgrade->to15Desc = <<<EOD
<p>ZenTao version 15.0 has major upgrade of features, including:</p>
<p><strong>1. Add the concept of Program</strong></p>
<p>A program is a collection of interrelated and coordinated projects. It is at the highest level and belongs to the concept of a strategic level. It has multi-level project management, helping managers to form strategic directions and allocate resources at a macro level.</p>
+4
View File
@@ -51,6 +51,10 @@ $lang->upgrade->sureExecute = '确认执行';
$lang->upgrade->upgradingTips = '正在升级中,请耐心等待,切勿刷新页面、断电、关机!';
$lang->upgrade->forbiddenExt = '以下插件与新版本不兼容,已经自动禁用:';
$lang->upgrade->updateFile = '需要更新附件信息。';
$lang->upgrade->changeEngine = '需要修改数据库引擎。';
$lang->upgrade->changingTable = '正在更换数据表%s引擎...';
$lang->upgrade->finishedTable = '已经更换数据表%s引擎为InnoDB。';
$lang->upgrade->finishedChange = '更换数据库引擎结束。';
$lang->upgrade->noticeSQL = '检查到你的数据库跟标准不一致,尝试修复失败。请执行以下SQL语句,再刷新页面检查。';
$lang->upgrade->afterDeleted = '请执行上面命令删除文件, 删除后刷新!';
$lang->upgrade->mergeProgram = '数据迁移';
+32 -25
View File
@@ -83,14 +83,13 @@ class upgradeModel extends model
if(!isset($this->app->user)) $this->loadModel('user')->su();
$editions = array('p' => 'pro', 'b' => 'biz', 'm' => 'max');
$fromEdition = is_numeric($fromVersion[0]) ? 'open' : $editions[$fromVersion[0]];
$fromEdition = $this->getEditionByVersion($fromVersion);
/* If the 'current openVersion' is not equal the 'from openVersion', must update structure. */
$currentVersion = str_replace('.', '_', $this->config->version);
/* Execute. */
$fromOpenVersion = is_numeric($fromVersion[0]) ? $fromVersion : $this->config->upgrade->{$fromEdition . 'Version'}[$fromVersion];
$fromOpenVersion = $this->getOpenVersion($fromVersion);
$versions = $this->getVersionsToUpdate($fromOpenVersion, $fromEdition);
foreach($versions as $openVersion => $chargedVersions)
{
@@ -532,7 +531,6 @@ class upgradeModel extends model
$this->processBugLinkBug();
break;
case '17_4':
$this->changeTableEngine();
$this->processCreatedInfo();
$this->processCreatedBy();
$this->updateApproval();
@@ -1207,6 +1205,32 @@ class upgradeModel extends model
return $confirmContent;
}
/**
* Get edition by version.
*
* @param string $version
* @access public
* @return string
*/
public function getEditionByVersion($version)
{
$editions = array('p' => 'pro', 'b' => 'biz', 'm' => 'max');
return is_numeric($version[0]) ? 'open' : $editions[$version[0]];
}
/**
* Get openVersion
*
* @param int $version.
* @access public
* @return string
*/
public function getOpenVersion($version)
{
$edition = $this->getEditionByVersion($version);
return is_numeric($version[0]) ? $version : zget($this->config->upgrade{$edition . 'Version'}, $version);
}
/**
* Update company field.
*
@@ -3186,6 +3210,10 @@ class upgradeModel extends model
$needProcess['search'] = true;
}
}
$openVersion = $this->getOpenVersion($fromVersion);
if(version_compare($open, '17_4', '<=')) $needProcess['changeEngine'] = true;
return $needProcess;
}
@@ -6748,27 +6776,6 @@ class upgradeModel extends model
return !dao::isError();
}
/**
* Change search table engine.
*
* @access public
* @return void
*/
public function changeTableEngine()
{
$mysqlVersion = $this->loadModel('install')->getMysqlVersion();
$tables = $this->dao->query("SHOW TABLE STATUS WHERE `Engine` is not null AND `Engine` = 'MyISAM'")->fetchAll();
foreach($tables as $table)
{
$tableName = $table->Name;
$sql = "ALTER TABLE `$tableName` ENGINE='InnoDB'";
if(stripos($tableName, 'searchindex') !== false and $mysqlVersion < 5.6) continue;
$this->dao->exec($sql);
}
return true;
}
/**
* Process created information.
*
+93 -32
View File
@@ -23,24 +23,6 @@
<div><?php echo html::a('index.php', $lang->upgrade->tohome, '', "class='btn btn-primary btn-wide' id='tohome'")?></div>
</div>
</div>
<!--
<div class='divider'></div>
<div class='col-md-6'>
<div class='panel adbox'>
<div class='panel-heading'><strong><?php echo $lang->install->promotion?></strong></div>
<div class='panel-body row'>
<?php foreach($lang->install->product as $product):?>
<a class="card ad ad-<?php echo $product;?>" href="<?php echo $lang->install->{$product}->url;?>" target="_blank">
<div class="img-wrapper"><img src="<?php echo $defaultTheme . $lang->install->{$product}->logo;?>" /> <?php echo $lang->install->{$product}->name;?></div>
<div class="card-reveal">
<div class="card-content"><?php echo $lang->install->{$product}->desc?></div>
</div>
</a>
<?php endforeach;?>
</div>
</div>
</div>
-->
</div>
</div>
</div>
@@ -49,15 +31,98 @@
$(function()
{
sessionStorage.removeItem('TID');
$.get('<?php echo inlink('afterExec', "fromVersion=$fromVersion&processed=yes&skipMoveFile=yes")?>');
initHideHome();
finishedShow();
})
<?php
foreach($needProcess as $processKey => $value) echo 'var ' . $processKey . "Finish = false;\n";
if(isset($needProcess['updateFile'])):?>
foreach($needProcess as $processKey => $value)
{
$value = $processKey == 'search' ? 'true' : 'false';
echo 'var ' . $processKey . "Finish = $value;\n";
}
?>
/**
* Init hide message.
*
* @access public
* @return void
*/
function initHideHome()
{
var hide = false;
<?php
foreach($needProcess as $processKey => $value)
{
if($processKey == 'search') continue;
echo "hide = true;\n";
break;
}
?>
if(hide)
{
$('a#tohome').closest('.message').hide();
$('.result-box').css('height', 'auto').css('position', 'relative').css('margin-top', '0px');
}
}
/**
* Finished show message.
*
* @access public
* @return void
*/
function finishedShow()
{
var show = true;
<?php
foreach($needProcess as $processKey => $value)
{
echo "if({$processKey}Finish == false) show = false;\n";
}
?>
if(show)
{
$.get('<?php echo inlink('afterExec', "fromVersion=$fromVersion&processed=yes&skipMoveFile=yes")?>');
$('a#tohome').closest('.message').show();
}
}
<?php if(isset($needProcess['changeEngine'])):?>
$(function()
{
$('.col-md-6:first').append("<div id='changeEngineBox' class='alert alert-info'><p><?php echo $lang->upgrade->changeEngine;?></p></div>");
changeEngine();
})
function changeEngine()
{
var link = '<?php echo inlink('ajaxChangeTableEngine')?>';
$.getJSON(link, function(response)
{
if(response == null)
{
changeEngineFinish = true;
finishedShow();
}
else if(response.result == 'finished')
{
changeEngineFinish = true;
$('#changeEngineBox').prepend("<div class='text-success'>" + response.message + "</div>");
finishedShow();
}
else
{
if($('#changeEngineBox').find('.' + response.table).length == 0) $('#changeEngineBox').prepend("<div class='text-success " + response.table + "'></div>");
$('#changeEngineBox').find('.' + response.table).html(response.message);
if(response.next) $('#changeEngineBox').prepend("<div class='text-success " + response.next + "'>" + response.nextMessage + "</div>");
changeEngine();
}
});
}
<?php endif;?>
<?php if(isset($needProcess['updateFile'])):?>
$(function()
{
$('a#tohome').closest('.message').hide();
$('.col-md-6:first').append("<div id='resultBox' class='alert alert-info'><p><?php echo $lang->upgrade->updateFile;?></p></div>");
updateFile('<?php echo inlink('ajaxUpdateFile')?>');
})
@@ -68,22 +133,20 @@ function updateFile(link)
if(response == null)
{
updateFileFinish = true;
$.get('<?php echo inlink('afterExec', "fromVersion=$fromVersion&processed=yes")?>');
$('a#tohome').closest('.message').show();
finishedShow();
}
else if(response.result == 'finished')
{
$('#resultBox li span.' + response.type + '-num').html(num + response.count);
updateFileFinish = true;
$('#resultBox').append("<li class='text-success'>" + response.message + "</li>");
$.get('<?php echo inlink('afterExec', "fromVersion=$fromVersion&processed=yes")?>');
$('a#tohome').closest('.message').show();
$('#resultBox').prepend("<li class='text-success'>" + response.message + "</li>");
finishedShow();
}
else
{
if($('#resultBox li span.' + response.type + '-num').size() == 0 || response.type != response.nextType)
{
$('#resultBox').append("<li class='text-success'>" + response.message + "</li>");
$('#resultBox').prepend("<li class='text-success'>" + response.message + "</li>");
}
var num = parseInt($('#resultBox li span.' + response.type + '-num').html());
$('#resultBox li span.' + response.type + '-num').html(num + response.count);
@@ -92,13 +155,11 @@ function updateFile(link)
});
}
<?php endif;?>
</script>
<?php if(isset($needProcess['search'])):?>
<script>
$(function()
{
$('.col-md-6:first').append("<div class='alert alert-info'><p><?php echo $lang->upgrade->needBuild4Add;?></p></div>");
})
</script>
<?php endif;?>
</script>
<?php include '../../common/view/footer.lite.html.php';?>