更新时间:2022-06-13 07:53:34
将主键拖放到单独的迁移中,然后删除 $ table-> primary('id')
.添加 AUTO_INCREMENT
列会自动创建一个主键:
Drop the primary key in a separate migration and remove $table->primary('id')
. Adding an AUTO_INCREMENT
column automatically creates a primary key:
Schema::table('item_tag', function (Blueprint $table) {
$table->dropPrimary();
});
Schema::table('item_tag', function (Blueprint $table) {
$table->unsignedInteger('id', true)->first();
});
您还可以简化第二次迁移:
You can also simplify the second migration:
Schema::table('item_tag', function (Blueprint $table) {
$table->increments('id')->first();
});