From 2e4e8a104333b51ceac63190c72ae800f1ff346b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Thu, 13 Jan 2022 16:24:26 +0800 Subject: [PATCH] * Add upgrade logic. --- module/upgrade/model.php | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index b89bbe559d..b94aec3fb2 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -741,6 +741,11 @@ class upgradeModel extends model $this->execSQL($this->getUpgradeFile('16.0.beta1')); $this->loadModel('api')->createDemoData($this->lang->api->zentaoAPI, 'http://' . $_SERVER['HTTP_HOST'] . $this->app->config->webRoot . 'api.php/v1', '16.0'); $this->appendExec('16_0_beta1'); + case '16_1': + $this->saveLogs('Execute 16_1'); + $this->execSQL($this->getUpgradeFile('16.1')); + $this->moveKanbanData(); + $this->appendExec('16_0_beta1'); } $this->deletePatch(); @@ -5360,6 +5365,47 @@ class upgradeModel extends model return true; } + /** + * Move kanban card data to kanbancell table. + * + * @access public + * @return void + */ + public function moveKanbanData() + { + $cards = $this->dao->select('id,kanban,`column`,lane')->from(TABLE_KANBANCARD)->fetchAll('id'); + + foreach($cards as $cardID => $card) + { + $oldCell = $this->dao->select('id,kanban,`column`,lane,card')->from(TABLE_KANBANCELL) + ->where('kanban')->eq($card->kanban) + ->andWhere('lane')->eq($card->lane) + ->andWhere('`column`')->eq($card->column) + ->fetch(); + + if(!empty($oldCell)) + { + $oldCell->cards = $oldCell->cards . "$cardID,"; + $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq($oldCell->cards)->where('id')->eq($oldCell->id)->exec(); + } + else + { + $cell = new stdclass(); + $cell->kanban = $card->kanban; + $cell->lane = $card->lane; + $cell->column = $card->column; + $cell->type = 'card'; + $cell->cards = ",$cardID,"; + + $this->dao->insert(TABLE_KANBANCELL)->data($cell)->exec(); + } + } + + $lanePairs = $this->dao->select('id')->from(TABLE_KANBANLANE)->where('execution')->gt(0)->fetchPairs(); + $this->dao->delete()->from(TABLE_KANBANLANE)->where('execution')->gt(0)->exec(); + $this->dao->delete()->from(TABLE_KANBANCOLUMN)->where('lane')->in($lanePairs)->exec(); + } + /** * Adjust for bug required field. *