dispatcher = $dispatcher; $this->em = $em; } public function update(OutputInterface $output = null) { $connection = $this->em->getConnection(); $connection->getConfiguration()->setSQLLogger(null); $schema = $connection->getSchemaManager(); $path = preg_replace("~sqlite:///~si", '', $connection->getParams()['path']); $backup = "$path.backup"; copy($path, $backup); try { collect($schema->listTables())->reject(function (Table $schema) { return $schema->getName() === 'migration_versions'; })->each([$schema, 'dropAndCreateTable']); $this->dispatcher->dispatch(new DataUpdateEvent($output), DataUpdateEvent::NAME); unlink($backup); } catch (\Throwable $exception) { $connection->close(); unlink($path); rename($backup, $path); throw $exception; } } }