我正在尝试1:1在我的访客和联系人之间添加关系
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRelationToVisitorsDRelationToVisitorsContacts extends Migration
{
public function up()
{
Schema::table('contacts', function(Blueprint $table)
{
$table->bigInteger('visitor_id')->unsigned();
$table->foreign('visitor_id')->references('id')->on('visitors')->onDelete('cascade');
});
}
public function down()
{
Schema::table('contacts', function($table)
{
$table->dropForeign('contacts_visitor_id_foreign');
$table->dropColumn('visitor_id');
});
Schema::table('visitors', function(Blueprint $table)
{
$table->dropColumn('contact_id');
});
}
}
运行时
php artisan migrate
Migrating: 2020_04_16_104641_update_contacts_table_04_16_2020
慕的地10843
呼唤远方
FFIVE