Answer the question
In order to leave comments, you need to log in
What is the problem with migration?
Good day to all. There are two migrations. They are movies and genres. When you try to link and by id, this error appears:
General error: 1822 Failed to add the foreign key constraint. Missing index for constraint 'movies_genres_id_foreign' in the referenced table 'genres' (SQL: alter table `movies` add constraint `movies_genres_id_foreign` foreign key (`genres_id`) references `genres` (`id`))
Это код из create_movies_table(файл миграции)
$table->unsignedBigInteger('genres_id');
$table->foreign('genres_id')->references('id')->on('genres');
------------------------------------------
А это из create_genres_table(файл миграции genres)
$table->unsignedBigInteger('id');
$table->string('name');
$table->timestamps();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question