diff --git a/install-dev/upgrade/php/add_column_order_state_deleted_if_not_exists.php b/install-dev/upgrade/php/add_column_order_state_deleted_if_not_exists.php
index c894d4947..b145a1382 100644
--- a/install-dev/upgrade/php/add_column_order_state_deleted_if_not_exists.php
+++ b/install-dev/upgrade/php/add_column_order_state_deleted_if_not_exists.php
@@ -27,7 +27,9 @@
function add_column_order_state_deleted_if_not_exists()
{
+ $res = true;
$column = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'order_state` LIKE "deleted"');
+
if (empty($column))
$res = Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_state`
ADD COLUMN `deleted` tinyint(1) UNSIGNED NOT NULL default "0" AFTER `paid`');
diff --git a/install-dev/upgrade/php/add_missing_columns_customer.php b/install-dev/upgrade/php/add_missing_columns_customer.php
new file mode 100644
index 000000000..ae32304a8
--- /dev/null
+++ b/install-dev/upgrade/php/add_missing_columns_customer.php
@@ -0,0 +1,57 @@
+
+* @copyright 2007-2012 PrestaShop SA
+* @version Release: $Revision: 13573 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+function add_missing_columns_customer()
+{
+ $db = Db::getInstance();
+ $res = true;
+ $current_fields = $db->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'customer`');
+ foreach ($current_fields as $k => $field)
+ $current_fields[$k] = $field['Field'];
+
+ $missing_fields = array(
+ 'id_risk' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
+ ADD `id_risk` int(10) unsigned NOT NULL DEFAULT "1"',
+ 'company' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `company` varchar(64)',
+ 'siret' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `siret` varchar(14)',
+ 'ape' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `ape` varchar(5)',
+ 'website' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `website` varchar(128)',
+ 'outstanding_allow_amount' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
+ ADD `outstanding_allow_amount` DECIMAL( 10,6 ) NOT NULL default "0.00"',
+ 'show_public_prices' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
+ ADD `show_public_prices` tinyint(1) unsigned NOT NULL default "0"',
+ 'max_payment_days' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
+ ADD `max_payment_days` int(10) unsigned NOT NULL default "60"'
+ );
+
+ foreach ($missing_fields as $field => $query)
+
+ if (!in_array($field, $current_fields));
+ $res &= $db->execute($query);
+
+ return $res;
+}
diff --git a/install-dev/upgrade/php/add_missing_shop_column_pagenotfound.php b/install-dev/upgrade/php/add_missing_shop_column_pagenotfound.php
new file mode 100644
index 000000000..2471c498c
--- /dev/null
+++ b/install-dev/upgrade/php/add_missing_shop_column_pagenotfound.php
@@ -0,0 +1,47 @@
+
+* @copyright 2007-2012 PrestaShop SA
+* @version Release: $Revision: 13573 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+function add_missing_shop_column_pagenotfound()
+{
+ $res = true;
+ $exists = Db::getInstance()->executeS('SHOW TABLE LIKE "'._DB_PREFIX_.'pagenotfound"');
+ if (count($exists))
+ {
+ $fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'pagenotfound`');
+ foreach ($fields as $k => $field)
+ $fields[$k] = $field['Field'];
+
+ if (!in_array('id_shop_group', $fields))
+ $res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'pagenotfound`
+ ADD `id_shop_group` INT(10) AFTER `id_pagenotfound`');
+
+ if (!in_array('id_shop', $fields))
+ $res &= DB::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'pagenotfound`
+ ADD `id_shop` INT(10) AFTER `id_pagenotfound`');
+ }
+ return $res;
+}
diff --git a/install-dev/upgrade/php/create_multistore.php b/install-dev/upgrade/php/create_multistore.php
index 56e26745a..c5a1687fe 100755
--- a/install-dev/upgrade/php/create_multistore.php
+++ b/install-dev/upgrade/php/create_multistore.php
@@ -54,17 +54,17 @@ function create_multistore()
VALUES(1, \''.pSQL($shop_domain).'\', \''.pSQL($shop_domain_ssl).'\', \''.pSQL($_PS_DIRECTORY_).'\', \'\', 1, 1)');
// Stock conversion
- $sql = 'INSERT INTO `'._DB_PREFIX_.'.stock` (`id_product`, `id_product_attribute`, `id_shop_group`, `id_shop`, `quantity`)
+ $sql = 'INSERT INTO `'._DB_PREFIX_.'.stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`)
VALUES (SELECT `p.id_product`, 0, 1, 1, `p.quantity` FROM `'._DB_PREFIX_.'.product` p);';
$res &= Db::getInstance()->execute($sql);
- $sql = 'INSERT INTO `'._DB_PREFIX_.'.stock` (`id_product`, `id_product_attribute`, `id_shop_group`, `id_shop`, `quantity`)
+ $sql = 'INSERT INTO `'._DB_PREFIX_.'.stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`)
VALUES (SELECT `id_product`, `id_product_attribute`, 1, 1, `quantity` FROM `'._DB_PREFIX_.'product_attribute` p);';
$res &= Db::getInstance()->execute($sql);
// Add admin tabs
$shopTabId = add_new_tab('AdminShop', 'it:Shops|es:Shops|fr:Boutiques|de:Shops|en:Shops', 0, true);
- add_new_tab('AdminShopGroup', 'it:Group Shops|es:Group Shops|fr:Groupes de boutique|de:Group Shops|en:Group Shops', $shopTabId);
+ add_new_tab('AdminGroupShop', 'it:Group Shops|es:Group Shops|fr:Groupes de boutique|de:Group Shops|en:Group Shops', $shopTabId);
add_new_tab('AdminShopUrl', 'it:Shop Urls|es:Shop Urls|fr:URLs de boutique|de:Shop Urls|en:Shop Urls', $shopTabId);
return $res;
diff --git a/install-dev/upgrade/php/module_blockwishlist_multishop.php b/install-dev/upgrade/php/module_blockwishlist_multishop.php
index 1ef4e43a4..5d231696d 100644
--- a/install-dev/upgrade/php/module_blockwishlist_multishop.php
+++ b/install-dev/upgrade/php/module_blockwishlist_multishop.php
@@ -32,7 +32,7 @@ function module_blockwishlist_multishop()
{
$res = Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'wishlist`
ADD `id_shop` INTEGER NOT NULL default \'1\' AFTER `counter`,
- ADD `id_shop_group` INTEGER NOT NULL default \'1\' AFTER `id_shop`');
+ ADD `id_group_shop` INTEGER NOT NULL default \'1\' AFTER `id_shop`');
return $res;
}
diff --git a/install-dev/upgrade/sql/1.5.0.0.sql b/install-dev/upgrade/sql/1.5.0.0.sql
index 53c9ebda0..4d09beb72 100755
--- a/install-dev/upgrade/sql/1.5.0.0.sql
+++ b/install-dev/upgrade/sql/1.5.0.0.sql
@@ -1,38 +1,38 @@
SET NAMES 'utf8';
CREATE TABLE IF NOT EXISTS `PREFIX_group_shop` (
- `id_shop_group` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `id_group_shop` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(64) CHARACTER SET utf8 NOT NULL,
`share_customer` TINYINT(1) NOT NULL,
`share_order` TINYINT(1) NOT NULL,
`share_stock` TINYINT(1) NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '1',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id_shop_group`)
+ PRIMARY KEY (`id_group_shop`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
-INSERT INTO `PREFIX_group_shop` (`id_shop_group`, `name`, `active`, `deleted`, `share_stock`, `share_customer`, `share_order`) VALUES (1, 'Default', 1, 0, 0, 0, 0);
+INSERT INTO `PREFIX_group_shop` (`id_group_shop`, `name`, `active`, `deleted`, `share_stock`, `share_customer`, `share_order`) VALUES (1, 'Default', 1, 0, 0, 0, 0);
CREATE TABLE IF NOT EXISTS `PREFIX_shop` (
`id_shop` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `id_shop_group` int(11) unsigned NOT NULL,
+ `id_group_shop` int(11) unsigned NOT NULL,
`name` varchar(64) CHARACTER SET utf8 NOT NULL,
`id_category` INT(11) UNSIGNED NOT NULL DEFAULT '1',
`id_theme` INT(1) UNSIGNED NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '1',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_shop`),
- KEY `id_shop_group` (`id_shop_group`),
+ KEY `id_group_shop` (`id_group_shop`),
KEY `id_category` (`id_category`),
KEY `id_theme` (`id_theme`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
INSERT INTO `PREFIX_shop`
- (`id_shop`, `id_shop_group`, `name`, `id_category`, `id_theme`, `active`, `deleted`)
+ (`id_shop`, `id_group_shop`, `name`, `id_category`, `id_theme`, `active`, `deleted`)
VALUES
(1, 1, (SELECT value FROM `PREFIX_configuration` WHERE name = 'PS_SHOP_NAME'), 1, 1, 1, 0);
-ALTER TABLE `PREFIX_configuration` ADD `id_shop_group` INT(11) UNSIGNED DEFAULT NULL AFTER `id_configuration` , ADD `id_shop` INT(11) UNSIGNED DEFAULT NULL AFTER `id_shop_group`;
+ALTER TABLE `PREFIX_configuration` ADD `id_group_shop` INT(11) UNSIGNED DEFAULT NULL AFTER `id_configuration` , ADD `id_shop` INT(11) UNSIGNED DEFAULT NULL AFTER `id_group_shop`;
ALTER TABLE `PREFIX_configuration` DROP INDEX `name` , ADD INDEX `name` ( `name` ) ;
-ALTER TABLE `PREFIX_configuration` ADD INDEX (`id_shop_group`);
+ALTER TABLE `PREFIX_configuration` ADD INDEX (`id_group_shop`);
ALTER TABLE `PREFIX_configuration` ADD INDEX (`id_shop`);
INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, 'PS_SHOP_DEFAULT', '1', NOW(), NOW());
@@ -123,9 +123,9 @@ CREATE TABLE `PREFIX_currency_shop` (
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
INSERT INTO `PREFIX_currency_shop` (id_shop, id_currency) (SELECT 1, id_currency FROM PREFIX_currency);
-ALTER TABLE `PREFIX_cart` ADD `id_shop_group` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_cart` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_shop_group`, ADD INDEX `id_shop_group` (`id_shop_group`), ADD INDEX `id_shop` (`id_shop`);
+ALTER TABLE `PREFIX_cart` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_cart` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_group_shop`, ADD INDEX `id_group_shop` (`id_group_shop`), ADD INDEX `id_shop` (`id_shop`);
-ALTER TABLE `PREFIX_customer` ADD `id_shop_group` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_customer` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_shop_group`, ADD INDEX `id_shop_group` (`id_shop_group`), ADD INDEX `id_shop` (`id_shop`);
+ALTER TABLE `PREFIX_customer` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_customer` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_group_shop`, ADD INDEX `id_group_shop` (`id_group_shop`), ADD INDEX `id_shop` (`id_shop`);
ALTER TABLE `PREFIX_orders` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_order` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_group_shop`, ADD INDEX `id_group_shop` (`id_group_shop`), ADD INDEX `id_shop` (`id_shop`);
diff --git a/install-dev/upgrade/sql/1.5.0.10.sql b/install-dev/upgrade/sql/1.5.0.10.sql
index b9770a385..520334657 100644
--- a/install-dev/upgrade/sql/1.5.0.10.sql
+++ b/install-dev/upgrade/sql/1.5.0.10.sql
@@ -5,12 +5,18 @@ ALTER TABLE `PREFIX_supplier` DROP `id_address`;
UPDATE `PREFIX_meta` SET `page` = 'contact' WHERE `page` = 'contact-form';
RENAME TABLE `PREFIX_group_shop` TO `PREFIX_shop_group`;
+ALTER TABLE `PREFIX_shop_group` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;
+ALTER TABLE `PREFIX_shop` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
ALTER TABLE `PREFIX_stock_available` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
+ALTER TABLE `PREFIX_cart` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
+ALTER TABLE `PREFIX_configuration` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
ALTER TABLE `PREFIX_connections` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
+ALTER TABLE `PREFIX_customer` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
ALTER TABLE `PREFIX_delivery` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
ALTER TABLE `PREFIX_orders` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
ALTER TABLE `PREFIX_page_viewed` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
ALTER TABLE `PREFIX_specific_price` CHANGE `id_group_shop` `id_shop_group` INT( 11 ) UNSIGNED NOT NULL;
+ALTER TABLE `PREFIX_product` ADD `id_tax_rules_group` int(10) unsigned NOT NULL;
CREATE TABLE IF NOT EXISTS `PREFIX_product_shop_TMP` (
`id_product` int(10) unsigned NOT NULL,
diff --git a/install-dev/upgrade/sql/1.5.0.12.sql b/install-dev/upgrade/sql/1.5.0.12.sql
index e1ecb0961..78d5b6173 100644
--- a/install-dev/upgrade/sql/1.5.0.12.sql
+++ b/install-dev/upgrade/sql/1.5.0.12.sql
@@ -26,21 +26,13 @@ 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;
-ALTER TABLE `PREFIX_pagenotfound` ADD `id_shop_group` INT(10) AFTER `id_pagenotfound`, ADD `id_shop` INT(10) AFTER `id_pagenotfound`;
+/* PHP:add_missing_shop_column_pagenotfound(); */;
/* PHP:add_new_groups('Non identifié', 'Unidentified'); */;
/* PHP:editorial_update_multishop(); */;
/* PHP:update_module_product_comments(); */;
-ALTER TABLE `PREFIX_customer`
- ADD `id_risk` int(10) unsigned NOT NULL DEFAULT '1',
- ADD `company` varchar(64),
- ADD `siret` varchar(14),
- ADD `ape` varchar(5),
- ADD `website` varchar(128),
- ADD `outstanding_allow_amount` DECIMAL( 10,6 ) NOT NULL default '0.00',
- ADD `show_public_prices` tinyint(1) unsigned NOT NULL default '0',
- ADD `max_payment_days` int(10) unsigned NOT NULL default '60';
+/* PHP:add_missing_columns_customer(); */;
CREATE TABLE IF NOT EXISTS `PREFIX_risk` (
`id_risk` int(11) NOT NULL AUTO_INCREMENT,
@@ -55,4 +47,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_risk_lang` (
`name` varchar(20) NOT NULL,
PRIMARY KEY (`id_risk`,`id_lang`),
KEY `id_risk` (`id_risk`)
-) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
\ No newline at end of file
+) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+
+UPDATE `PREFIX_tab` SET `class_name`="AdminShopGroup" WHERE class_name="AdminGroupShop";
+
diff --git a/install-dev/upgrade/sql/1.5.0.5.sql b/install-dev/upgrade/sql/1.5.0.5.sql
index d642f8b65..88aeaf672 100644
--- a/install-dev/upgrade/sql/1.5.0.5.sql
+++ b/install-dev/upgrade/sql/1.5.0.5.sql
@@ -1,14 +1,14 @@
SET NAMES 'utf8';
ALTER TABLE `PREFIX_cart_rule` ADD `shop_restriction` tinyint(1) unsigned NOT NULL default 0 AFTER `product_restriction`;
-
+
CREATE TABLE `PREFIX_cart_rule_shop` (
`id_cart_rule` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_cart_rule`, `id_shop`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
-INSERT INTO `PREFIX_configuration`(`id_shop_group`, `id_shop`, `name`, `value`, `date_add`, `date_upd`)
+INSERT INTO `PREFIX_configuration`(`id_group_shop`, `id_shop`, `name`, `value`, `date_add`, `date_upd`)
VALUES
(NULL, NULL, 'PS_LOGO', 'logo.jpg', NOw(), NOW()),
(NULL, NULL, 'PS_LOGO_MAIL', 'logo_mail.jpg', NOw(), NOW()),
@@ -26,4 +26,4 @@ CREATE TABLE `PREFIX_module_preference` (
UNIQUE KEY `employee_module` (`id_employee`, `module`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
-ALTER TABLE `PREFIX_category_shop` ADD `position` int(10) unsigned NOT NULL default 0 AFTER `id_shop`;
+ALTER TABLE `PREFIX_category_shop` ADD `position` int(10) unsigned NOT NULL default 0 AFTER `id_shop`;
\ No newline at end of file
diff --git a/install-dev/upgrade/sql/1.5.0.7.sql b/install-dev/upgrade/sql/1.5.0.7.sql
index 0987d7e22..e398b2b93 100644
--- a/install-dev/upgrade/sql/1.5.0.7.sql
+++ b/install-dev/upgrade/sql/1.5.0.7.sql
@@ -19,6 +19,7 @@ CREATE TABLE `PREFIX_product_tax_rules_group_shop` (
INSERT INTO `PREFIX_product_tax_rules_group_shop` (`id_product`, `id_tax_rules_group`, `id_shop`)
(SELECT `id_product`, `id_tax_rules_group`, `id_shop` FROM `PREFIX_product`, `PREFIX_shop`);
+ALTER TABLE `PREFIX_product` DROP `id_tax_rules_group`;
CREATE TABLE `PREFIX_carrier_tax_rules_group_shop` (
`id_carrier` int(11) unsigned NOT NULL,
diff --git a/install-dev/upgrade/upgrade.php b/install-dev/upgrade/upgrade.php
index 874614023..f111d02aa 100644
--- a/install-dev/upgrade/upgrade.php
+++ b/install-dev/upgrade/upgrade.php
@@ -252,7 +252,7 @@ if (empty($fail_result))
if (!file_exists($file))
{
$logger->logError('Error while loading sql upgrade file.');
- $fail_result .= ''."\n";
+ $fail_result .= ''."\n";
}
if (!$sqlContent = file_get_contents($file))
{