The append dedup guard was check-then-insert: two concurrent appends of the same document both pass exists() and both insert. The partial unique index on (geschichte_id, document_id) WHERE document_id IS NOT NULL closes the race; append saveAndFlush-es and maps the DataIntegrityViolationException to the same 409 JOURNEY_DOCUMENT_ALREADY_ADDED as the friendly pre-check. The CHECK on note length pins the 2000-char contract in the schema, mirroring chk_text_length on transcription_blocks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4.3 KiB
4.3 KiB