I think the ; at the end of the statement is not expected
DB::statement("ALTER TABLE configurations AUTO_INCREMENT = 14000");
Or check if table configurations exist, and if you don't have any value above 14000 in the column.
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
If no data, maybe the table exist, but there is no row.
Try:
DB::insert('insert into sqlite_sequence (name, seq) values (?, ?)', ['configurations', 14000]);
If the sqlite_sequence row for an AUTOINCREMENT table does not exist when the AUTOINCREMENT table is updated, then a new sqlite_sequence row is created. If the sqlite_sequence.seq value for an AUTOINCREMENT table is manually set to something other than an integer and there is a subsequent attempt to insert the or update the AUTOINCREMENT table, then the behavior is undefined.
Please or to participate in this conversation.