我是Laravel的新手,我的表迁移工作得很好
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');
}
如果我运行php artisan migrate:fresh,则自动增量最大值不会设置回1。
我知道如何在SQL中做到这一点,但我想使用Laravel选项。
谢谢
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;');
}