harden document delete and rebuild faiss index

This commit is contained in:
team 1
2026-02-17 14:59:56 +01:00
parent fcd9488a18
commit 47ae0232de
3 changed files with 52 additions and 24 deletions

View File

@@ -97,27 +97,8 @@ class DocumentService
$this->em->flush();
}
/**
* HARD DELETE
*
* Entfernt das Dokument vollständig aus der Datenbank.
* Chunks und Vector-Index werden NICHT hier behandelt,
* sondern im Ingest-Job (TYPE_DOCUMENT_DELETE).
*/
public function delete(Document $document): void
{
// 1. FK-Zyklus auflösen
$document->setCurrentVersion(null);
$this->em->flush(); // <-- WICHTIG: zuerst FK nullen!
// 2. Versionen entfernen (falls kein cascade remove existiert)
foreach ($document->getVersions() as $version) {
$this->em->remove($version);
}
$this->em->flush(); // <-- Versionen löschen
// 3. Dokument löschen
$this->em->remove($document);
$this->em->flush();
}