我的代码如下,所以我的问题是要在创建迁移表中的down方法中删除关联关系吗?什么是编写迁移的最佳方法?创建与外键等关系相关的表
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserRoleTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_role', function (Blueprint $table) {
$table->uuid('id');
$table->uuid('user_id');
$table->string('name', 255);
$table->softDeletes();
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('user_role', function (Blueprint $table) {
$table->dropForeign('user_id');
$table->dropIfExists();
});
}
}