0

In M2 dev docs there is this regarding auto increment:

identity Indicates whether a column is auto incremented.

Here's excerpt from my db_schema.xml:

<column xsi:type="int" name="entity_id" padding="11" unsigned="false" nullable="false" identity="true" comment="Entity ID"/>

No AUTO_INCREMENT in db is found. What am I doing wrong/missing?

Magento 2.3.4, MySQL 5.7

UPD. It seems like db_schema is cached somewhere. Nothing I do affects it, nor changing padding, nor anything else.

UPD2. Adding a column works. Moreso, even commenting old entity_id column and adding a dummy column with auto_increment works.

  • Is this column a primary key or not? – Shankar May 14 at 10:05
  • Yeah, it is a primary key, set by constraint <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> – Vadim Shmyrov May 14 at 12:00
0

Use extra="auto_increment" after identity="true" and see what happens.

| improve this answer | |
  • Well, nothing happens. I notice that default is set to 0, maybe that's it? – Vadim Shmyrov May 14 at 11:59
0

try this

<table name="custom_table" resource="default" engine="innodb" comment="Custom Table">
    <column xsi:type="int" name="entity_id" unsigned="true" nullable="false" padding="10" identity="true" comment="Entity Id"/>
    <constraint xsi:type="primary" referenceId="PRIMARY">
        <column name="entity_id"/>
    </constraint>
</table>
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.