kgp43
9 months ago
140
8
Laravel

Alter table auto_increment, syntax error

Posted 9 months ago by kgp43

I'm trying to make my ID increment start at 14000, but getting an error - not sure why.

public function up()
    {
        Schema::create('configurations', function (Blueprint $table) {
            $table->increments('id');
            $table->string('short_description');
            $table->text('long_description')->nullable();
            $table->text('internal_notes')->nullable();
            $table->string('tags');
            $table->boolean('active')->default(true);
            $table->timestamps();
        });
        
        DB::statement("ALTER TABLE configurations AUTO_INCREMENT = 14000;");
    }

I'm getting this error on a fresh sqlite database:

SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error (SQL: ALTER TABLE configurations AUTO_INCREMENT = 14000;) {"exception":"[object] (Illuminate\Database\QueryException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"AUTO_INCREMENT\": syntax error (SQL: ALTER TABLE configurations AUTO_INCREMENT = 14000;) at /home/ec2-user/environment/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1 near \"AUTO_INCREMENT\": syntax error at /home/ec2-user/environment/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452)

It say syntax error, but all looks fine to me.

I searched a lot on Google and all guides told me, that the statement above is the correct way to do it. But why do I get this error then?

Hope one of you might be able to help me :)

, Kenneth

Please sign in or create an account to participate in this conversation.