Skip to content

add UNIQUE or UNQ name to unique indexes in database tables #36336

Open
@jakwinkler

Description

@jakwinkler

Description (*)

This table eav_attribute_label has an index defined in db_schema.xml

    <index referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID" indexType="btree">
        <column name="attribute_id"/>
        <column name="store_id"/>
    </index>

I work on fast database import scripts and tried to add a new unique index in that table:

    <table name="eav_attribute_label">
        <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID_UNQ">
            <column name="attribute_id"/>
            <column name="store_id"/>
        </constraint>
    </table>

but unique index name create by Magento 2 is: EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID
which is identical to the index defined above and that breaks installation / running db:upgrade schema

Expected behavior (*)

Unique indexes should contain UNQ / UNIQUE in referenceId

Benefits

No conflicts on core tables when new indexes or unique indexes are added.
Ability to create multiple insert scripts.

Additional information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Pull Request in Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions