Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Incorrect table definition; there can be only one auto column

Migration File

public function up()
{
    Schema::create('progress', function (Blueprint $table) {
        $table->id();
        $table->foreignId('state_id')->constrained()->cascadeOnDelete();
        $table->foreignId('city_id')->constrained()->cascadeOnDelete();
        $table->text('address');
        $table->string('project_name');
        $table->tinyInteger('status', 2);
        $table->timestamps();
    });
}

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’)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading