0 votes

this way of defining indexes seem not to be working

    name: 'custom_article_table_name',
    indexes: [
        new ORM\Index(name: 'name_index', columns: ['name'])

I had to convert it to

#[ORM\Table(name: 'custom_invoice_table_name')]
#[ORM\Index(name: 'date_index', columns: ['date'])]

bug documentation to reproduce

I don't know if this is a bug in Doctrine or the implementation of indexes:... is not fully supported in attributes arguments ?

All I have found is people fixing it with #[ORM\Index] attributes

related articles



in Bug report by (170 points)

What PHP version are you using? I believe this can be caused by bug/missing feature in Php 8, but already fixed in 8.1

I'm using PHP 8.1.0

This is strange, other users already confirmed that this format of definition worked for them correctly on Php 8.1+

Can you please double-check the version?

The issue is that the format you're mentioning as working is different than the Annotation format. Currently export shares the same base logic for annotations and attributes and we can't simply switch it to the #[ORM\Index] format without breaking annotations.

Hello Ludek,

We have checked on several configurations, (mac OS, Debian and Windows) with PHP 8.1, Symfony 5.4 (LTS) and Doctrine ORM 2.13.1. We all have the same issue.

I was planing to report the bug to the Doctring ORM team, but as I was browsing their open issues, I understood they are moving away from nested attributes (which are supported since PHP 8.1) towards split attributes.
source: https://github.com/doctrine/orm/issues/9540#issuecomment-1048026426

Attributes documented here do not mention the nested Table#indexes attribute anymore

I added a workaround by rolling back to annotation in my bug sample repo:

Best regards

Please log in or register to answer this question.