我正在嘗試1:1在我的訪客和聯(lián)系人之間添加關(guān)系<?phpuse 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'); }); }}運(yùn)行時(shí)php artisan migrateMigrating: 2020_04_16_104641_update_contacts_table_04_16_2020
無(wú)法添加或更新子行:外鍵約束失敗 - Laravel 7
BIG陽(yáng)
2022-12-23 16:01:50