I'm working with Laravel8. I have two tables contact_lists
and contacts
I contact_lists
have many contacts
.
Here is my migration code for generation of foreignKey contstraints on contact_lists
public function up()
{
Schema::create('contacts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->foreignId('contact_list_id')->nullable()->constrained()->onDelete('cascade');
$table->string('first_name');
$table->string('last_name');
$table->string('phone');
$table->longText('organization')->nullable();
$table->longText('note')->nullable();
$table->timestamps();
});
}
But I don't know why foreign key is not generating.