In SQLite, foreign key constraints are disabled by default.
What\'s the best way to configure Laravel 5.1\'s SQLite database connection to enable foreign key constra
You could also activate foreign keys on a per test (file) basis, when the tests actually depend on tables with foreign keys.
Here's a trait: (e.g. tests/ForeignKeys.php)
make('db');
$db->getSchemaBuilder()->enableForeignKeyConstraints();
}
}
don't forget to run the method somewhere in your test set-up chain. I added mine as an override to my TestCase: (tests/TestCase.php)
enableForeignKeys();
}
}
...
after that you can add it to your tests like so: