parastoo
parastoo

Reputation: 2469

Disable foreign key constraints

I want to disable foreign key constraint on a relationship because I have a problem after:

php artisan migrate:refresh

How can I solve it?

Upvotes: 10

Views: 7048

Answers (2)

Prasan Ghimire
Prasan Ghimire

Reputation: 194

You can disable foreign key constraints in your migration file.

Schema::disableForeignKeyConstraints();

Ref: Laravel migrations nice way of disabling foreign key checks

Upvotes: 8

Alexey Mezenin
Alexey Mezenin

Reputation: 163788

In 5.5 you can just use the fresh command:

php artisan migrate:fresh

The migrate:fresh command will drop all tables from the database and then execute the migrate command

Upvotes: 9

Related Questions