<?php

namespace KupShop\DeliveryPriceListBundle;

class DeliveryTypeDeliveryUpgrade extends \UpgradeNew
{
    public function check_pricelistColumn()
    {
        return $this->checkColumnExists('delivery_type_delivery', 'id_pricelist');
    }

    /** Add id_pricelist column to delivery_type_delivery */
    public function upgrade_pricelistColumn()
    {
        sqlQuery('ALTER TABLE delivery_type_delivery
                  ADD id_pricelist INT NULL,
                  ADD CONSTRAINT id_pricelist FOREIGN KEY (id_pricelist)  REFERENCES delivery_pricelists (id) ON DELETE SET NULL ON UPDATE CASCADE 
               ;');

        $this->upgradeOK();
    }
}
