RVRNEXT-5 migration for main_currency_id
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good
This commit is contained in:
parent
20a850f011
commit
e0ea18a6d0
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use RVR\PersistentData\Model\Community;
|
||||
use RVR\PersistentData\Model\Currency;
|
||||
use SokoWeb\Database\Query\Select;
|
||||
|
||||
$select = new Select(Container::$dbConnection);
|
||||
$communities = Container::$persistentDataManager->selectMultipleFromDb($select, Community::class);
|
||||
|
||||
foreach ($communities as $community) {
|
||||
$mainCurrency = new Currency();
|
||||
$mainCurrency->setCommunity($community);
|
||||
$mainCurrency->setCode($community->getCurrency());
|
||||
$mainCurrency->setRoundDigits(0);
|
||||
Container::$persistentDataManager->saveToDb($mainCurrency);
|
||||
|
||||
$community->setMainCurrency($mainCurrency);
|
||||
Container::$persistentDataManager->saveToDb($community);
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
ALTER TABLE `communities`
|
||||
ADD `main_currency_id` int(10) unsigned DEFAULT NULL,
|
||||
ADD KEY `main_currency_id` (`main_currency_id`),
|
||||
ADD CONSTRAINT `communities_main_currency_id` FOREIGN KEY (`main_currency_id`) REFERENCES `currencies` (`id`);
|
Loading…
Reference in New Issue
Block a user