feature/RVRNEXT-5-main-currency-of-community-should-be-a-general-currency #34
@ -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