1

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.

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

2 Answers 2

6

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>
2
  • After adding the PRIMARY key it's working. Commented Dec 15, 2021 at 7:05
  • 1
    yes i know @NagendraKodi
    – Devidas
    Commented Dec 15, 2021 at 7:17
0

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

2
  • Well, nothing happens. I notice that default is set to 0, maybe that's it? Commented May 14, 2020 at 11:59
  • After adding the PRIMARY key it's working. Commented Dec 15, 2021 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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