<?php

declare(strict_types=1);

namespace KupShop\AdminBundle\Resources\upgrade;

class DeliveryPriceListUpgrade extends \UpgradeNew
{
    public function check_migrateCurrencies()
    {
        return $this->checkDataMigration(26);
    }

    /** Update delivery currency from delivery pricelist */
    public function upgrade_migrateCurrencies()
    {
        if (findModule(\Modules::DELIVERY_PRICELIST)) {
            sqlQuery('UPDATE delivery_type_delivery dtd, delivery_pricelists dp
                SET dtd.currency = dp.id_currency
                WHERE dtd.id_pricelist = dp.id;');
        }

        $this->commitDataMigration(26);

        $this->upgradeOK();
    }
}
