// Improved deprecated indexes drop

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17332 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-09-13 11:34:16 +00:00
parent 5bc2b64eed
commit fbb6a871ad
@@ -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`)');
}