<?php
use mbeshipping\classes\custom\helper;

if (!defined('_PS_VERSION_')) {
    exit;
}

function upgrade_module_1_5_0($object)
{
    $sql = [];

    $sql[] = "CREATE TABLE IF NOT EXISTS `" . _DB_PREFIX_ . "mbe_shipping_standard_packages`(
                `id_mbeshippingpackage` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
                `max_weight` decimal(12,4) default 0 not null,
                `length` decimal(12,4) default 0 not null,
                `width` decimal(12,4) default 0 not null,
                `height` decimal(12,4) default 0 not null,
                `package_label` varchar(255) not null,
                `package_code` varchar(55) not null,                
                 UNIQUE KEY MBE_PKG_PROD_UNIQUE (package_code))";

    $sql[] = "CREATE TABLE IF NOT EXISTS `" . _DB_PREFIX_ . "mbe_shipping_standard_package_product`(
                `id_mbeshippingpackageproduct` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
                `custom_package` tinyint(1) NULL,
                `single_parcel` tinyint(1) NULL,
                `product_sku` varchar(64) NOT NULL DEFAULT '',
                `package_code` varchar(50) NOT NULL DEFAULT '',                                
                UNIQUE KEY MBE_PKG_PROD_PACKAGE_PRODUCT_UNIQUE  (package_code, product_sku),
                UNIQUE KEY MBE_PKG_PROD_PRODUCT_SKU  (product_sku),
                KEY MBE_PKG_PROD_PACKAGE_CODE  (package_code))";

    foreach ($sql as $query) {
        if (Db::getInstance()->execute($query) == false) {
            return Db::getInstance()->getMsgError();
        }
    }
    return true;
}