* Finish task#8963.#8962. Deal with upgrade data.
This commit is contained in:
@@ -77,6 +77,7 @@ ALTER TABLE `zt_project` DROP `storyConcept`;
|
||||
ALTER TABLE `zt_product` DROP `storyConcept`;
|
||||
|
||||
ALTER TABLE `zt_user` CHANGE `avatar` `avatar` text NOT NULL AFTER `commiter`;
|
||||
ALTER TABLE `zt_project` CHANGE `budgetUnit` `budgetUnit` char(30) NOT NULL DEFAULT 'CNY' AFTER `budget`;
|
||||
|
||||
-- DROP TABLE IF EXISTS `zt_searchindex`;
|
||||
CREATE TABLE IF NOT EXISTS `zt_searchindex` (
|
||||
|
||||
@@ -732,7 +732,7 @@ CREATE TABLE IF NOT EXISTS `zt_project` (
|
||||
`product` char(30) NOT NULL DEFAULT 'single',
|
||||
`lifetime` char(30) NOT NULL,
|
||||
`budget` varchar(30) NOT NULL DEFAULT '0',
|
||||
`budgetUnit` char(30) NOT NULL DEFAULT 'wanyuan',
|
||||
`budgetUnit` char(30) NOT NULL DEFAULT 'CNY',
|
||||
`attribute` varchar(30) NOT NULL DEFAULT '',
|
||||
`percent` float unsigned NOT NULL DEFAULT '0',
|
||||
`milestone` enum('0','1') NOT NULL DEFAULT '0',
|
||||
|
||||
@@ -664,6 +664,7 @@ class upgradeModel extends model
|
||||
$this->saveLogs('Execute 20_0_beta3');
|
||||
$this->execSQL($this->getUpgradeFile('20.0.beta3'));
|
||||
$this->addPriv20_0_bata3();
|
||||
$this->adjustBudgetUnit();
|
||||
$this->appendExec('20_0_beta3');
|
||||
}
|
||||
|
||||
@@ -4505,4 +4506,30 @@ class upgradeModel extends model
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust budget units and values.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function adjustBudgetUnit()
|
||||
{
|
||||
$budgets = $this->dao->select('id,budget,budgetUnit')->from(TABLE_PROJECT)
|
||||
->where('type')->in('project,program')
|
||||
->fetchAll('id');
|
||||
|
||||
foreach($budgets as $id => $budget)
|
||||
{
|
||||
$data = array();
|
||||
$data['budgetUnit'] = 'CNY';
|
||||
$data['budget'] = str_replace(',', '', $budget->budget);
|
||||
if($budget->budgetUnit == 'wanyuan') $data['budget'] = (float)$data['budget'] * 10000;
|
||||
if($budget->budgetUnit == 'dollars') $data['budgetUnit'] = 'USD';
|
||||
|
||||
if($data) $this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($id)->exec();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user