* finish task #5435.

This commit is contained in:
wangyidong
2019-04-30 10:53:38 +08:00
parent 83ef9700c4
commit 1dfd857601
5 changed files with 85 additions and 9 deletions
+21
View File
@@ -2294,6 +2294,27 @@ class upgradeModel extends model
return true;
}
/**
* Add unique key for stage.
*
* @access public
* @return bool
*/
public function addUniqueKey4Stage()
{
$this->saveLogs('Run Method ' . __FUNCTION__);
$stmt = $this->dao->select('story,branch')->from(TABLE_STORYSTAGE)->orderBy('story,branch')->query();
$preStage = '';
while($stage = $stmt->fetch())
{
if($preStage == "{$stage->story}_{$stage->branch}") $this->dao->delete()->from(TABLE_STORYSTAGE)->where('story')->eq($stage->story)->andWhere('branch')->eq($stage->branch)->exec();
$preStage = "{$stage->story}_{$stage->branch}";
}
$this->dao->exec("ALTER TABLE " . TABLE_STORYSTAGE . " ADD UNIQUE `story_branch` (`story`, `branch`)");
$this->saveLogs($this->dao->get());
return true;
}
/**
* Judge any error occers.
*