feat(journeyitem): V74 — partial unique index + note-length CHECK as atomic backstops
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>
This commit is contained in:
@@ -377,9 +377,10 @@ package "Supporting" {
|
||||
geschichte_id : UUID <<FK>>
|
||||
document_id : UUID <<FK>>
|
||||
position : INTEGER NOT NULL CHECK (position > 0)
|
||||
note : TEXT
|
||||
note : TEXT CHECK (length <= 2000)
|
||||
==
|
||||
UNIQUE (geschichte_id, position) DEFERRABLE INITIALLY DEFERRED
|
||||
UNIQUE (geschichte_id, document_id) WHERE document_id IS NOT NULL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user