【发布时间】:2020-10-23 06:40:03
【问题描述】:
如错误日志中所写,可能错误是由于引用表和父表中的不同形式引起的,但我仍然不明白,因为我是编程新手
这里是表 1
<?php
Schema::create('questions', function (Blueprint $table) {
$table->id();
$table->string('question');
$table->unsignedInteger('quiz_id');
$table->timestamps();
});
这里是表 2
<?php
Schema::create('answers', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('question_id');
$table->string('answer');
$table->boolean('is_correct');
$table->timestamps();
});
Schema::table('answers', function (Blueprint $table){
$table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade');
});
我应该在此代码中进行哪些更改?谢谢
【问题讨论】:
标签: laravel migration laravel-migrations