Skip to content
Advertisement

Incorrect table definition; there can be only one auto column

Migration File

JavaScript

After running php artisan migrate

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table progress (id bigint unsigned not null auto_increment primary key, state_id bigint unsigned not null, city_id bigint unsigned not null, address text not null, project_name varchar(255) not null, status tinyint not null auto_increment primary key, created_a t timestamp null, updated_at timestamp null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

Advertisement

Answer

Your migration has defined the tiny integer column as an auto increment column. Take a look at the Laravel tinyInterger docs and you’ll see the second argument is a Boolean for defining the column as auto increment.

So to remove this error you’ll need to remove the 2 from your column definition.

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