laravel migration schema builder: deferred constraint checking

814 Views Asked by At

i have to insert bulk data into tables and defer foreign key constraint checking until transaction commit.

as in postgresql, NOT DEFERRABLE is the default constraint type (mysql innoDB does not support DEFERRABLE constraints at all), how can i change this default within migrations?

1

There are 1 best solutions below

1
On

You can always run raw MySQL using DB::raw('...'). This should do the trick:

DB::raw('SET foreign_key_checks = 0;');

http://laravel.com/docs/queries