From 1db00037b44d313f08f2de1c771dbff3a020688e Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 24 Aug 2022 10:05:49 +0800 Subject: [PATCH] * * Modify update sql of change story status. --- db/update17.5.sql | 1 + module/upgrade/model.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/db/update17.5.sql b/db/update17.5.sql index be88aa2b78..925889dfce 100644 --- a/db/update17.5.sql +++ b/db/update17.5.sql @@ -1,3 +1,4 @@ +ALTER TABLE `zt_story` MODIFY `status` enum('','changed','active','draft','closed','reviewing') NOT NULL DEFAULT '' AFTER `estimate`; UPDATE `zt_story` SET `status` = 'reviewing' WHERE `status` = 'changed'; ALTER TABLE `zt_story` MODIFY `status` enum('','changing','active','draft','closed','reviewing') NOT NULL DEFAULT '' AFTER `estimate`; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 45ad94bb87..dbf704b70f 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -7062,11 +7062,16 @@ class upgradeModel extends model */ public function updateStoryStatus() { - /* After cancel the review of changed story, the story status should be 'changing'. */ + /* After cancel the review of changed story, the story status should be "changing". */ $this->dao->update(TABLE_STORY)->set('status')->eq('changing')->where('status')->eq('draft')->andWhere('version')->gt(1)->exec(); - /* Other stories in draft status should be 'reviewing'. */ - $this->dao->update(TABLE_STORY)->set('status')->eq('reviewing')->where('status')->eq('draft')->exec(); + /* The draft story with reviewers should be "reviewing". */ + $reviewingStories = $this->dao->select('story')->from(TABLE_STORYREVIEW)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id and t1.version = t2.version') + ->where('t2.status')->eq('draft') + ->andWhere('t2.version')->eq(1) + ->fetchPairs(); + $this->dao->update(TABLE_STORY)->set('status')->eq('reviewing')->where('id')->in($reviewingStories)->exec(); return !dao::isError(); }