0
votes

When i try to migrate this table in laravel.

Command output is:

[PDOException] 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

public function up()
{
    Schema::create('posts', function (Blueprint $table) {
        $table->increments('id');

        $table->bigInteger('post_author', 20);
        $table->text('post_title');
        $table->longText('post_content');
        $table->string('post_status', 20);
        $table->string('comment_status', 20);
        $table->string('post_type', 20);

        $table->timestamps();
        $table->softDeletes();
    });
}
2
how can i add this in auto_increment field?Anwarul Islam

2 Answers

2
votes

Don't specify a size for bigInteger column

$table->bigInteger('post_author');
0
votes

Specify a size for bigInteger column by following way

$table->bigInteger('post_author')->length(20);