O. Shekriladze
O. Shekriladze

Reputation: 1536

Laravel can't two tables connected with each other by foreign key

I have two tables.

tableone: id, tabletwo_id
tabletwo: id, tableone_id

structure is something like that. they are connected using foreign key, but now I can't delete these tables at all. I mean laravel rollback doesn't work, tableone expects tabletwo to be deleted first and vice versa. So what can I do?

Upvotes: 1

Views: 54

Answers (1)

Davit Zeynalyan
Davit Zeynalyan

Reputation: 8618

You must be firstly delete foregin key constrant, then table.

Schema::table('tabletwo', function(Blueprint $table)
{
    $table->dropForeign('tabletwo_table_one_id_foreign');
});

Schema::drop('tabletwo');

Upvotes: 3

Related Questions