Skip to content
Advertisement

whats causing the migration to fail with error ” there can only be on auto increment column”

My table posts does not have any limits, i am letting Laravel choose the auto increment by default. It still fails with “there can only be on auto increment column”.

migration

JavaScript

Advertisement

Answer

You can’t have multiple auto incremented columns. Change the foreign keys type to unsignedInteger() and it should work. This is usually the way i create and id column plus two foreign keys.

JavaScript

Alternatively you can create a foreign key reference also.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement