mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Only truncate users table if it exists
This commit is contained in:
@@ -298,14 +298,17 @@ class Upgrade39Users implements PreSchemaUpgradeInterface
|
|||||||
$connection = $em->getConnection();
|
$connection = $em->getConnection();
|
||||||
$dbPlatform = $connection->getDatabasePlatform();
|
$dbPlatform = $connection->getDatabasePlatform();
|
||||||
$connection->beginTransaction();
|
$connection->beginTransaction();
|
||||||
try {
|
|
||||||
$connection->query('SET FOREIGN_KEY_CHECKS=0');
|
if ($connection->getSchemaManager()->tablesExist([ $meta->getTableName() ])) {
|
||||||
$connection->executeUpdate($dbPlatform->getTruncateTableSql($meta->getTableName()));
|
try {
|
||||||
$connection->query('SET FOREIGN_KEY_CHECKS=1');
|
$connection->query('SET FOREIGN_KEY_CHECKS=0');
|
||||||
$connection->commit();
|
$connection->executeUpdate($dbPlatform->getTruncateTableSql($meta->getTableName()));
|
||||||
} catch (\Exception $e) {
|
$connection->query('SET FOREIGN_KEY_CHECKS=1');
|
||||||
$connection->rollback();
|
$connection->commit();
|
||||||
throw $e;
|
} catch (\Exception $e) {
|
||||||
|
$connection->rollback();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user