Skip to content

Commit

Permalink
Add entity schema manager DatabaseException
Browse files Browse the repository at this point in the history
  • Loading branch information
PululuK committed Mar 1, 2024
1 parent ae977d2 commit 5882c1e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Core/Util/Database/EntitySchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\ToolsException;
use PrestaShop\PrestaShop\Core\Exception\DatabaseException;

/**
* Class EntitySchemaManager help to manage an entity schema: update, create, drop.
Expand Down Expand Up @@ -61,6 +63,8 @@ public function __construct(EntityManagerInterface $entityManager)
* @param bool $dropIfExist
*
* @return bool
*
* @throws DatabaseException
*/
public function create(string $entityClassName, bool $dropIfExist = true): bool
{
Expand All @@ -72,8 +76,8 @@ public function create(string $entityClassName, bool $dropIfExist = true): bool

try {
$this->schemaTool->createSchema([$entityMetaData]);
} catch (\Exception $exception) {
return false;
} catch (ToolsException $exception) {
throw new DatabaseException($exception->getMessage());
}

return true;
Expand Down Expand Up @@ -116,6 +120,8 @@ public function drop(string $entityClassName): bool
* @param bool $dropIfExist
*
* @return bool
*
* @throws DatabaseException
*/
public function createMultiple(array $entitiesClassesName, bool $dropIfExist = true): bool
{
Expand Down

0 comments on commit 5882c1e

Please sign in to comment.