Remove Index from Table

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
jramirezgranada
Posts: 40
Joined: 12 Jul 2018, 19:57

Remove Index from Table

Post by jramirezgranada » 18 Oct 2018, 14:38

Hi there;

I've create a product.php file inside custom/setup/default/schema to modify some stuff in the database.

Code: Select all

return array(
    'exlcude' => array(
        'unq_mspropr_sid_tid_lid_value',
    ),
    'table' => array(
        'mshop_product_property' => function (\Doctrine\DBAL\Schema\Schema $schema) {

            $table = $schema->getTable('mshop_product_property');

            $table->dropIndex('idx_mspropr_sid_value');

            return $schema;
        },
    ),
);
but the index never is remove, how can I remove the index ?

I did it from migrations, but when I run aimeos:setup the index is created agian.

Thanks
--
Jorge A Ramirez
System Engineer
PHP Developer

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Remove Index from Table

Post by aimeos » 21 Oct 2018, 12:29

First question: Why do you want to remove the index? Did you've changed the table structure and you want to add one that fits better for the new structure? Otherwise, it's a bad idea to remove indexes because this will slow down your application.

Second thing: You have a typo in the "exclude" key but I think you don't need an exclude for the index here.

The problem regarding removing the index might be that DBAL is adding the index to the table and you are removing it immediately again. Then, DBAL adds the index to it's "removedIndexes" property but it gets not really removed because the setup tasks are not executed in "clean" mode:
https://github.com/aimeos/aimeos-core/b ... p.php#L322

Can you verify that DBAL doesn't remove the index from the table definition? Maybe that's a bug in DBAL you should report if this is the case.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply