Skip to content
Permalink
Browse files

Disable foreign keys when truncating tables.

This fixes issues in MySQL where truncation cannot occur when tables
have foreign keys.
  • Loading branch information...
markstory committed Sep 5, 2014
1 parent 92478a1 commit 3e143d98af5d3a56ebda391a600e3a2b2bdc0ac5
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/TestSuite/Fixture/FixtureManager.php
@@ -277,11 +277,13 @@ public function unload($test) {
foreach ($dbs as $connection => $fixtures) {
$db = ConnectionManager::get($connection, false);
$db->transactional(function($db) use ($fixtures, $connection) {
$db->disableForeignKeys();
foreach ($fixtures as $f) {
if (!empty($fixture->created) && in_array($connection, $fixture->created)) {
$fixture->truncate($db);
}
}
$db->enableForeignKeys();
});
}
}

0 comments on commit 3e143d9

Please sign in to comment.
You can’t perform that action at this time.