sequenceGenerator->setLastNumberFor($type, $number)) { $this->outputLine('Last number successfully set.'); } else { $this->outputLine('Failed to set last number.'); } } /** * Clean up sequence table. * * @param string[] $types * @throws DoctrineDBALDriverException * @throws DoctrineDBALException * @throws InvalidSourceException */ public function cleanUpCommand(array $types = []): void { if ($types === []) { foreach ( $this ->entityManager ->createQuery('SELECT DISTINCT(se.type) type FROM ' . SequenceEntry::class . ' se') ->execute() as $result ) { $types[] = $result['type']; } } foreach ($types as $type) { $rowCount = $this ->entityManager ->createQuery('DELETE FROM ' . SequenceEntry::class . ' se WHERE se.type = ?0 AND se.number < ?1') ->execute([$type, $this->sequenceGenerator->getLastNumberFor($type)]); $this->outputLine('Deleted ' . $rowCount . ' row(s) for type "' . $type . '".'); } } }