sequenceGenerator->advanceTo($to, $type); } /** * @param string[] $typesToClean * @throws DigiCompSequenceServiceException * @throws DoctrineDBALDriverException * @throws DoctrineDBALException */ public function cleanSequenceInsertsCommand(array $typesToClean = []) { $cleanArray = []; if ($typesToClean === []) { $results = $this->entityManager ->createQuery('SELECT i.type, MAX(i.number) max_number FROM ' . Insert::class . ' i GROUP BY i.type') ->getScalarResult(); foreach ($results as $result) { $cleanArray[$result['type']] = (int)$result['max_number']; } } else { foreach ($typesToClean as $typeToClean) { $cleanArray[$typeToClean] = $this->sequenceGenerator->getLastNumberFor($typeToClean); } } foreach ($cleanArray as $typeToClean => $number) { $this->entityManager ->createQuery('DELETE FROM ' . Insert::class . ' i WHERE i.type = ?0 AND i.number < ?1') ->execute([$typeToClean, $number]); } } }