Reputation: 33
I'm new to Laravel and I have this table migration working fine
public function up()
{
Schema::create('tenants', function (Blueprint $table) {
$table->integer('tenant_id')->autoIncrement();
$table->string('name', 45);
$table->integer('plan_id')->nullable();
$table->integer('status')->nullable();
});
}
public function down()
{
Schema::dropIfExists('tenants');
}
If i run php artisan migrate: fresh the auto increment max value is not set back to 1.
I know how to do it in SQL but I want to use Laravel options.
Thank you
Upvotes: 1
Views: 533
Reputation: 11
1)we can use from method to set autoincrement start value
$table->integer('tenant_id')->from(number);
2)this will other method to change autoincrement value
public function up()
{
Schema::create('tenants', function (Blueprint $table) {
$table->integer('tenant_id')->autoIncrement();
$table->string('name', 45);
$table->integer('plan_id')->nullable();
$table->integer('status')->nullable();
});
\DB::statement('ALTER TABLE tenants AUTO_INCREMENT = 1000;');
}
Upvotes: 1