Disable FK checks when restoring backups.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-02-22 16:17:11 -06:00
parent 5f63db9cae
commit 4cd090decd
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
1 changed files with 4 additions and 2 deletions

View File

@ -80,13 +80,15 @@ class RestoreCommand extends CommandAbstract
return 1;
}
// Drop all preloaded tables prior to running a DB dump backup.
$conn = $em->getConnection();
$connParams = $conn->getParams();
// Drop all preloaded tables prior to running a DB dump backup.
$conn->executeQuery('SET FOREIGN_KEY_CHECKS = 0');
foreach ($conn->fetchFirstColumn('SHOW TABLES') as $table) {
$conn->executeQuery('DROP TABLE ' . $conn->quoteIdentifier($table));
$conn->executeQuery('DROP TABLE IF EXISTS ' . $conn->quoteIdentifier($table));
}
$conn->executeQuery('SET FOREIGN_KEY_CHECKS = 1');
$this->passThruProcess(
$io,