Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Ok, got it - an extra migration does the job :-)

public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->foreign('group_id')->references('id')->on('groups');
        });
        Schema::table('groups', function (Blueprint $table) {
            $table->foreign('user_id')->references('id')->on('users');
        });
    }

BUT! How do i insert such a thing? I have two table having foreign key on each other. I get the constraint violation the second i insert the date in one of the tables...

Is this possible at all?

Has some one any suggestion?

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

sixthpack sixthpack Joined 6 May 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.