Partial Indexes

To use a partial index for the entity field, add the following condition as additional option to the index definition:

$table->addIndex(['is_featured'], 'idx_oro_product_featured', [], ['where' => '(is_featured = true)']);


PostgreSQL supports partial indexes, however MySQL does not. For MySQL the additional option causes the database schema diversion.

To eliminate the negative impact for the MySQL-based instances and automatically adjust their database schema, declare the following service:

    class: Oro\Bundle\EntityBundle\EventListener\ORM\PartialIndexListener
    public: false
        - 'oro_product'
        - 'idx_oro_product_featured'
        - { name: doctrine.event_listener, event: loadClassMetadata, connection: default }

The service removes the options that are not supported in MySQL from the index definition.