I try to migrate db, but I got an error, and I am not sure why. Not sure what is "incorrectly formed".
//First Table
Schema::create('lkp_anime_lists', function (Blueprint $table) {
$table->id();
//more columns here
});
//Second one
Schema::create('lkp_cards', function (Blueprint $table) {
$table->id();
$table->integer('lkp_anime_list_id');
});
Schema::table('lkp_cards', function ($table) {
$table->foreign('lkp_anime_list_id')
->references('id')
->on('lkp_anime_lists')
->onDelete('cascade');
});
SQLSTATE[HY000]: General error: 1005 Can't create table
anime_db.lkp_cards(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter tablelkp_cardsadd constraintlkp_cards_lkp_anime_list_id_foreignforeign key (lkp_anime_list_id) referenceslkp_anime_lists(id) on delete cascade)
lkp_cards.lkp_anime_list_idis unsigned andlkp_anime_lists.idisn't. So either remove the->unsigned()or add it to thelkp_anime_lists$table->id()above, - lufcid()function alias tobigIncrementsso you also need to change the$table->integer('lkp_anime_list_id');to$table->bigInteger('lkp_anime_list_id');- lufc