stiftungswo / Dime

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

Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: An exception occurred while executing 'DELETE FROM users WHERE id = ?' with params [41]: #150

Closed swoadmin closed 5 years ago

swoadmin commented 6 years ago

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

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`stiftun8_dimetest`.`WorkingPeriods`, CONSTRAINT `FK_57C1BB888C03F15C` FOREIGN KEY (`employee_id`) REFERENCES `users` (`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/EmployeeBundle/Controller/EmployeeController.php", line 192, in deleteEmployeeAction
    $this->container->get($this->handlerSerivce)->delete($this->getOr404($id, $this->handlerSerivce));
  File "app/bootstrap.php.cache", line 3253, in handleRaw
    $response = call_user_func_array($controller, $arguments);
  File "app/bootstrap.php.cache", line 3212, in handle
    return $this->handleRaw($request, $type);
...
(18 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`.`WorkingPeriods`, CONSTRAINT `FK_57C1BB888C03F15C` FOREIGN KEY (`employee_id`) REFERENCES `users` (`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/EmployeeBundle/Controller/EmployeeController.php", line 192, in deleteEmployeeAction
    $this->container->get($this->handlerSerivce)->delete($this->getOr404($id, $this->handlerSerivce));
  File "app/bootstrap.php.cache", line 3253, in handleRaw
    $response = call_user_func_array($controller, $arguments);
  File "app/bootstrap.php.cache", line 3212, in handle
    return $this->handleRaw($request, $type);
...
(17 additional frame(s) were not displayed)

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

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`stiftun8_dimetest`.`WorkingPeriods`, CONSTRAINT `FK_57C1BB888C03F15C` FOREIGN KEY (`employee_id`) REFERENCES `users` (`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/EmployeeBundle/Controller/EmployeeController.php", line 192, in deleteEmployeeAction
    $this->container->get($this->handlerSerivce)->delete($this->getOr404($id, $this->handlerSerivce));
  File "app/bootstrap.php.cache", line 3253, in handleRaw
    $response = call_user_func_array($controller, $arguments);
  File "app/bootstrap.php.cache", line 3212, in handle
    return $this->handleRaw($request, $type);
...
(19 additional frame(s) were not displayed)
andyundso commented 5 years ago

WorkPeriods werden neu mitgelöscht, wenn ein Mitarbeiter gelöscht wird.

https://github.com/stiftungswo/betterDime/blob/master/api/database/migrations/2018_10_31_142637_create_work_periods_table.php#L19