From fbb6a871ad15f6b9a06b7d2e38fdf65fb84e2693 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Thu, 13 Sep 2012 11:34:16 +0000 Subject: [PATCH] // Improved deprecated indexes drop git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17332 b9a71923-0436-4b27-9f14-aed3839534dd --- .../php/p15017_add_id_shop_to_primary_key.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/install-dev/upgrade/php/p15017_add_id_shop_to_primary_key.php b/install-dev/upgrade/php/p15017_add_id_shop_to_primary_key.php index 964da1b6a..c608fb030 100644 --- a/install-dev/upgrade/php/p15017_add_id_shop_to_primary_key.php +++ b/install-dev/upgrade/php/p15017_add_id_shop_to_primary_key.php @@ -27,10 +27,21 @@ function p15017_add_id_shop_to_primary_key() { + // Drop old indexes + $old_indexes = array( + 'category_lang_index' => 'category_lang', + 'shipper_lang_index' => 'carrier_lang', + 'product_lang_index' => 'product_lang' + ); + foreach ($old_indexes as $index => $table) + if (Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = "'.$index.'"')) + Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'` DROP KEY `'.$index.'`'); + // The former primary keys where set on id_object and id_lang. They must now be set on id_shop too. foreach (array('product', 'category', 'meta', 'carrier') as $table) { - Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'_lang` DROP PRIMARY KEY'); + if (Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = "PRIMARY"')) + Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'_lang` DROP PRIMARY KEY'); Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'_lang` ADD PRIMARY KEY (`id_'.$table.'`, `id_shop`, `id_lang`)'); }