Enforce filename uniqueness in StoredObjectVersion with partial unique index...

This commit is contained in:
2025-10-13 10:47:47 +00:00
parent 208a378185
commit e1bf4a24d2
3 changed files with 73 additions and 0 deletions

View File

@@ -23,10 +23,14 @@ use Random\RandomException;
* Store each version of StoredObject's.
*
* A version should not be created manually: use the method @see{StoredObject::registerVersion} instead.
*
* Each filename must be unique within the same StoredObject. We add a condition on id to apply this condition only for
* newly created versions when this new index is applied.
*/
#[ORM\Entity]
#[ORM\Table('chill_doc.stored_object_version')]
#[ORM\UniqueConstraint(name: 'chill_doc_stored_object_version_unique_by_object', columns: ['stored_object_id', 'version'])]
#[ORM\UniqueConstraint(name: 'chill_doc_stored_object_version_unique_by_filename', columns: ['filename'], options: ['where' => '(id > 0)'])]
class StoredObjectVersion implements TrackCreationInterface
{
use TrackCreationTrait;