jeudi 11 février 2021

Hello guys...Error while setting foreign key constraints

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table manage_db.sub_services (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table sub_services add constraint sub_services_id_foreign foreign key (id) references `service_lists

please find the migration table of sub_service

   Schema::create('sub_services', function (Blueprint $table) {
        
        $table->unsignedBigInteger('id');
        $table->foreign('id')->references('sub_service_id')->on('service_lists');

        $table->unsignedBigInteger('main_service_id');
        $table->foreign('main_service_id')->references('id')->on('main_services');
        
        $table->string('sub_service_name');
        $table->timestamps();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire