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

@@ -1,6 +1,5 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -31,10 +30,18 @@ class Document
#[ORM\Column]
private \DateTimeImmutable $createdAt;
#[ORM\OneToMany(mappedBy: 'document', targetEntity: DocumentVersion::class, cascade: ['persist'], orphanRemoval: true)]
// 🔥 REMOVE ergänzt
#[ORM\OneToMany(
mappedBy: 'document',
targetEntity: DocumentVersion::class,
cascade: ['persist', 'remove'],
orphanRemoval: true
)]
private Collection $versions;
// 🔥 onDelete ergänzt
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?DocumentVersion $currentVersion = null;
public function __construct()
@@ -65,7 +72,6 @@ class Document
return $this;
}
public function getStatus(): string
{
return $this->status;
@@ -94,8 +100,10 @@ class Document
public function addVersion(DocumentVersion $version): void
{
$this->versions->add($version);
$version->setDocument($this);
if (!$this->versions->contains($version)) {
$this->versions->add($version);
$version->setDocument($this);
}
}
public function setCurrentVersion(?DocumentVersion $version): void