When using Laravel 9.x with mysql I had the error:
SQLSTATE[HY000]: General error: 3780 Referencing column 'post_id' and referenced column 'id' in foreign key constraint 'post_translations_post_id_foreign' are incompatible. (SQL: alter table `post_translations` add constraint `post_translations_post_id_foreign` foreign key (`post_id`) references `posts` (`id`) on delete cascade)
This is because the the structure and data type of the primary key and foreign key must be same.
Solution:
$table->unsignedBigInteger('post_id');
EDIT: This is because I had $table->id() (default when making a new migration file) instead of $table->increments('id') I think. Maybe a warning notice in the doc would be enough though.
In the migration guide you have this:
When using Laravel 9.x with mysql I had the error:
This is because the the structure and data type of the primary key and foreign key must be same.
Solution:
EDIT: This is because I had
$table->id()
(default when making a new migration file) instead of$table->increments('id')
I think. Maybe a warning notice in the doc would be enough though.