diff --git a/src/Console/Command/Backup/RestoreCommand.php b/src/Console/Command/Backup/RestoreCommand.php index eeb6dca4d..0cf44d6d4 100644 --- a/src/Console/Command/Backup/RestoreCommand.php +++ b/src/Console/Command/Backup/RestoreCommand.php @@ -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,