SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name ' ' is too long

Posted 3 months ago by nizam0786

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');
        });

any ideas?

thanks in advance.

Please sign in or create an account to participate in this conversation.