// 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:
@@ -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`)');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user