From a2266fa088874626d787d37fded78cb09fa50a6f Mon Sep 17 00:00:00 2001 From: dMetzger Date: Thu, 16 Aug 2012 09:59:35 +0000 Subject: [PATCH] [-] Installer : fixed warnings #PSCFV-3633 --- install-dev/data/db_structure.sql | 2 +- install-dev/upgrade/sql/1.5.0.0.sql | 10 +++++++++- install-dev/upgrade/sql/1.5.0.12.sql | 6 +++--- install-dev/upgrade/sql/1.5.0.13.sql | 6 +++--- install-dev/upgrade/sql/1.5.0.2.sql | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql index 8015930f3..b93c2f3e4 100644 --- a/install-dev/data/db_structure.sql +++ b/install-dev/data/db_structure.sql @@ -1085,7 +1085,7 @@ CREATE TABLE `PREFIX_order_detail_tax` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; CREATE TABLE `PREFIX_order_invoice` ( - `id_order_invoice` int(11) NOT NULL AUTO_INCREMENT, + `id_order_invoice` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `id_order` int(11) NOT NULL, `number` int(11) NOT NULL, `delivery_number` int(11) NOT NULL, diff --git a/install-dev/upgrade/sql/1.5.0.0.sql b/install-dev/upgrade/sql/1.5.0.0.sql index 4d09beb72..7822e367c 100755 --- a/install-dev/upgrade/sql/1.5.0.0.sql +++ b/install-dev/upgrade/sql/1.5.0.0.sql @@ -86,7 +86,15 @@ INSERT INTO `PREFIX_stock` (id_product, id_product_attribute, id_shop, quantity) ) FROM PREFIX_product p); ALTER TABLE PREFIX_stock_mvt ADD id_stock INT UNSIGNED NOT NULL AFTER id_stock_mvt; -UPDATE PREFIX_stock_mvt sm SET sm.id_stock = (SELECT s.id_stock FROM PREFIX_stock s WHERE s.id_product = sm.id_product AND s.id_product_attribute = sm.id_product_attribute ORDER BY s.id_shop LIMIT 1); +UPDATE PREFIX_stock_mvt sm SET sm.id_stock = ( + SELECT IFNULL(s.id_stock, 0) + FROM PREFIX_stock s + WHERE s.id_product = sm.id_product + AND s.id_product_attribute = sm.id_product_attribute + ORDER BY s.id_shop + LIMIT 1 +); +DELETE FROM PREFIX_stock_mvt WHERE id_stock = 0; ALTER TABLE PREFIX_stock_mvt DROP id_product, DROP id_product_attribute; CREATE TABLE `PREFIX_country_shop` ( diff --git a/install-dev/upgrade/sql/1.5.0.12.sql b/install-dev/upgrade/sql/1.5.0.12.sql index eb6865996..2fc6de254 100644 --- a/install-dev/upgrade/sql/1.5.0.12.sql +++ b/install-dev/upgrade/sql/1.5.0.12.sql @@ -20,17 +20,17 @@ ALTER TABLE `PREFIX_tax_rule` CHANGE `zipcode_from` `zipcode_from` VARCHAR(12) N UPDATE PREFIX_order_detail_tax odt LEFT JOIN PREFIX_tax t ON (t.id_tax = odt.id_tax) -SET unit_amount = ROUND((t.rate / 100) * ( +SET unit_amount = IFNULL(ROUND((t.rate / 100) * ( SELECT od.unit_price_tax_excl - ( o.total_discounts_tax_excl * ( od.unit_price_tax_excl / o.total_products )) FROM PREFIX_order_detail od LEFT JOIN PREFIX_orders o ON ( o.id_order = od.id_order) WHERE odt.id_order_detail = od.id_order_detail -), 2); +), 2), 0); UPDATE PREFIX_order_detail_tax odt LEFT JOIN PREFIX_order_detail od ON (od.id_order_detail = odt.id_order_detail) -SET total_amount = odt.unit_amount * od.product_quantity; +SET total_amount = IFNULL(odt.unit_amount * od.product_quantity, 0); /* PHP:add_missing_shop_column_pagenotfound(); */; diff --git a/install-dev/upgrade/sql/1.5.0.13.sql b/install-dev/upgrade/sql/1.5.0.13.sql index 83f96c5a2..65121283c 100644 --- a/install-dev/upgrade/sql/1.5.0.13.sql +++ b/install-dev/upgrade/sql/1.5.0.13.sql @@ -37,9 +37,9 @@ ALTER TABLE `PREFIX_order_payment` -- update for all employee the last ids for notifications UPDATE `PREFIX_employee` - SET `id_last_order`= (SELECT max(`id_order`) FROM `PREFIX_orders`), - `id_last_customer_message`= (SELECT max(`id_customer_message`) FROM `PREFIX_customer_message`), - `id_last_customer`= (SELECT max(`id_customer`) FROM `PREFIX_customer`); + SET `id_last_order`= (SELECT IFNULL(MAX(`id_order`), 0) FROM `PREFIX_orders`), + `id_last_customer_message`= (SELECT IFNULL(MAX(`id_customer_message`), 0) FROM `PREFIX_customer_message`), + `id_last_customer`= (SELECT IFNULL(MAX(`id_customer`), 0) FROM `PREFIX_customer`); UPDATE `PREFIX_category_shop` cs SET `position` = (SELECT `position` FROM `PREFIX_category` c WHERE cs.`id_category` = c.`id_category`); diff --git a/install-dev/upgrade/sql/1.5.0.2.sql b/install-dev/upgrade/sql/1.5.0.2.sql index 10df5ec96..5bb99cf5a 100644 --- a/install-dev/upgrade/sql/1.5.0.2.sql +++ b/install-dev/upgrade/sql/1.5.0.2.sql @@ -323,7 +323,7 @@ ADD `total_wrapping_tax_excl` decimal(17,2) NOT NULL AFTER `total_wrapping`, ADD `total_wrapping_tax_incl` decimal(17,2) NOT NULL AFTER `total_wrapping_tax_excl`; ALTER TABLE `PREFIX_order_cart_rule` ADD `value_tax_excl` DECIMAL(17, 2) NOT NULL DEFAULT '0.00'; -ALTER TABLE `PREFIX_order_cart_rule` ADD `id_order_invoice` INT NOT NULL DEFAULT '0' AFTER `id_cart_rule`; +ALTER TABLE `PREFIX_order_cart_rule` ADD `id_order_invoice` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `id_cart_rule`; ALTER TABLE `PREFIX_specific_price` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL AFTER `id_shop`; @@ -346,7 +346,7 @@ INSERT INTO `PREFIX_order_invoice` (`id_order`, `number`, `total_discount_tax_ex ALTER TABLE `PREFIX_tab` ADD `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'; UPDATE `PREFIX_order_detail` od -SET od.`id_order_invoice` = ( +SET od.`id_order_invoice` = ( SELECT oi.`id_order_invoice` FROM `PREFIX_order_invoice` oi WHERE oi.`id_order` = od.`id_order`