Reputation: 411
I would like to set my incremental id to start counting from 1000. How can do that
my animal table
public function up()
{
Schema::create('animals', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('type_id')->index();
$table->string('gender');
$table->string('placeOfBirth');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('type_id')->references('id')->on('types');
});
}
Upvotes: 1
Views: 97
Reputation: 15296
DB::statement()
can be used to execute any single SQL statement you need.
public function up()
{
Schema::create('animals', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('type_id')->index();
$table->string('gender');
$table->string('placeOfBirth');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('type_id')->references('id')->on('types');
});
// Here's the magic
\DB::statement('ALTER TABLE animals AUTO_INCREMENT = 1000;');
}
Check this for more info
Upvotes: 1