stiftungswo / Dime

DimeERP - Timetracker, Offers & Invoices
MIT License
5 stars 1 forks source link

Projekt-Kategorie kann nicht gelöscht werden, wenn Projekte diese noch zugewiesen habe #160

Closed swoadmin closed 5 years ago

swoadmin commented 6 years ago

Reporter: Zivi

Soll dies möglich sein?

https://sentry.io/swo/dime/issues/667123519/

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`stiftun8_dimetest`.`projects`, CONSTRAINT `FK_projects_project_categories` FOREIGN KEY (`project_category_id`) REFERENCES `project_categories` (`id`))
  File "src/Dime/TimetrackerBundle/Handler/AbstractHandler.php", line 146, in deleteEntity
    $this->om->flush();
  File "src/Dime/TimetrackerBundle/Handler/GenericHandler.php", line 125, in delete
    $this->deleteEntity($entity);
  File "src/Dime/TimetrackerBundle/Controller/ProjectCategoryController.php", line 188, in deleteProjectcategoryAction
    $this->container->get($this->handlerSerivce)->delete($this->getOr404($id, $this->handlerSerivce));
  File "app/bootstrap.php.cache", line 3262, in handleRaw
    $response = \call_user_func_array($controller, $arguments);
  File "app/bootstrap.php.cache", line 3221, in handle
    return $this->handleRaw($request, $type);
...
(17 additional frame(s) were not displayed)

Doctrine\DBAL\Driver\PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`stiftun8_dimetest`.`projects`, CONSTRAINT `FK_projects_project_categories` FOREIGN KEY (`project_category_id`) REFERENCES `project_categories` (`id`))
  File "src/Dime/TimetrackerBundle/Handler/AbstractHandler.php", line 146, in deleteEntity
    $this->om->flush();
  File "src/Dime/TimetrackerBundle/Handler/GenericHandler.php", line 125, in delete
    $this->deleteEntity($entity);
  File "src/Dime/TimetrackerBundle/Controller/ProjectCategoryController.php", line 188, in deleteProjectcategoryAction
    $this->container->get($this->handlerSerivce)->delete($this->getOr404($id, $this->handlerSerivce));
  File "app/bootstrap.php.cache", line 3262, in handleRaw
    $response = \call_user_func_array($controller, $arguments);
  File "app/bootstrap.php.cache", line 3221, in handle
    return $this->handleRaw($request, $type);
...
(16 additional frame(s) were not displayed)

Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: An exception occurred while executing 'DELETE FROM project_categories WHERE id = ?' with params [78]:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`stiftun8_dimetest`.`projects`, CONSTRAINT `FK_projects_project_categories` FOREIGN KEY (`project_category_id`) REFERENCES `project_categories` (`id`))
  File "src/Dime/TimetrackerBundle/Handler/AbstractHandler.php", line 146, in deleteEntity
    $this->om->flush();
  File "src/Dime/TimetrackerBundle/Handler/GenericHandler.php", line 125, in delete
    $this->deleteEntity($entity);
  File "src/Dime/TimetrackerBundle/Controller/ProjectCategoryController.php", line 188, in deleteProjectcategoryAction
    $this->container->get($this->handlerSerivce)->delete($this->getOr404($id, $this->handlerSerivce));
  File "app/bootstrap.php.cache", line 3262, in handleRaw
    $response = \call_user_func_array($controller, $arguments);
  File "app/bootstrap.php.cache", line 3221, in handle
    return $this->handleRaw($request, $type);
...
(18 additional frame(s) were not displayed)
andyundso commented 5 years ago

Die Projekt-Kategorien im neuen Dime können im Moment nur noch archiviert, aber nicht gelöscht werden. Falls eine Kategorie dennoch gelöscht wird, funktioniert das Projekt weiter (siehe https://github.com/stiftungswo/betterDime/blob/master/api/database/migrations/2018_10_29_092642_create_projects_etc.php#L26)