0

My table in db_schema looks like below.

<table name="test">
    <column xsi:type="int" identity="true" name="test_id" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
    <column xsi:type="varchar" name="name" nullable="false" length="255" default="" />
    <constraint xsi:type="primary" referenceId="PRIMARY">
        <column name="test_id"/>
    </constraint>
    <index referenceId="TEST_NAME" indexType="fulltext">
        <column name="name"/>
    </index>
    <constraint xsi:type="unique" referenceId="TEST_NAME_UNIQUE">
        <column name="name"/>
    </constraint>
</table>

After setup:upgrade I get an error "SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'TEST_NAME', query was: CREATE TABLE test ( test_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT "Entity Id", name varchar(255) NOT NULL DEFAULT "" , CONSTRAINT PRIMARY KEY (test_id), CONSTRAINT TEST_NAME UNIQUE KEY (name), FULLTEXT INDEX TEST_NAME (name) ) ENGINE=innodb DEFAULT CHARSET=utf8 DEFAULT COLLATE=utf8_general_ci"

I know there cannot be two indexes with the same name, so how to customize the index name? I thought referenceId field indicates the name of index but I was wrong.

I'm using Magento 2.3.5 and MariaDB

2
  • Did you generate a db_schema_whitelist.json? – Daniel May 12 '20 at 10:50
  • @Daniel Yes, I did – zsDev May 12 '20 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.