SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name ' ' is too long
Hi guys,
I am trying to add a foreign key to my database and the following error is returned.
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'mother_haematological_disorder_type_mother_medical_history_id_foreign' is too long (SQL: alter table `mother_haematological_d
isorder_type` add constraint `mother_haematological_disorder_type_mother_medical_history_id_foreign` foreign key (`mother_medical_history_id`) references `mother_medical_history` (`id`) on delete cascade)
I think the problem is the auto generated primary key but I don't know how to set it.
Schema::table('mother_haematological_disorder_type', function ($table){
$table->uuid('mother_medical_history_id')->unique()->after('id');
$table->foreign('mother_medical_history_id')->references('id')->on('mother_medical_history')->onDelete('cascade');
});
I have also noticed it adds the foreign key to the database with the passed name however, it returns the error when running 'php artisan migrate:fresh' ???