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
    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> May 14, 2020 at 12:00

3 Answers 3

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. Dec 15, 2021 at 7:05
  • 1
    yes i know @NagendraKodi
    – Devidas
    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? May 14, 2020 at 11:59
  • After adding the PRIMARY key it's working. Dec 15, 2021 at 7:05
0

Batter understanding you can view this blog.

If you have underestading regarding db_schema.xml then you can add below code or just add this line in your id column identity="true".

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

Your Answer

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

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