<?php

namespace KupShop\AdminBundle\Resources\upgrade;

class CNBSharedUpgrade extends \UpgradeNew
{
    public function check_cnbCurrencies(): bool
    {
        return $this->checkTableExists('cnb_currencies', 'kupshop_shared');
    }

    /** Create table cnb_currencies */
    public function upgrade_cnbCurrencies()
    {
        sqlQuery(
            'create table kupshop_shared.cnb_currencies(
                            id varchar(3) not null,
                            rate decimal(15,8) not null,
                            constraint cnb_currencies_pk
                                primary key (id)
                        );
                        '
        );

        \CNB::updateSharedCurrencies();

        $this->upgradeOK();
    }
}
