<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
*  @author    Anvanto <anvantoco@gmail.com>
*  @copyright 2023 Anvanto
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/

if (!defined('_PS_VERSION_')) {
    exit;
}
function upgrade_module_3_4_1($object)
{

    
    $sql[] = '
        ALTER TABLE `'._DB_PREFIX_.'anblog_blog_widgets` ADD COLUMN `relation` int(10) NOT NULL;
    ';

    $sql[] = '
        CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'anblog_blog_widgets_relations` (
            `id_relation` int(11) NOT NULL AUTO_INCREMENT,
            `type` tinyint(1) unsigned NOT NULL DEFAULT 0,
            `id_anblog_blog_widgets` int(11) NOT NULL,
            `id_type` int(11) NOT NULL,
            PRIMARY KEY (`id_relation`)
        ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;
    ';
    
    $return = true;
    foreach ($sql as $_sql) {
        $return = Db::getInstance()->Execute($_sql);
        if (!$return){
            return false;
        }
    }

    return true;
}
