From e833d1f71a1607ab3b43890f307fb043222106a2 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 28 Apr 2026 20:03:36 +0200 Subject: [PATCH] feat(transcription): V56 migration adds transcription_block_mentioned_persons sidecar Child table for @-mentions inside transcription block text. Each row binds one block to one person via personId + displayName; the literal "@DisplayName" stays in block.text. No FK on person_id so deleted persons degrade gracefully to plain unlinked text rather than cascade-deleting the block. Indexed on person_id for the future "blocks mentioning person X" query and on block_id for the @ElementCollection load. Schema choice diverges from document_comments.comment_mentions (many-to-many to AppUser): the latter cascades, this one degrades. Mirrors the established UserGroup.permissions / group_permissions @ElementCollection pattern. Refs #362 Co-Authored-By: Claude Opus 4.7 --- ..._transcription_block_mentioned_persons.sql | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V56__add_transcription_block_mentioned_persons.sql diff --git a/backend/src/main/resources/db/migration/V56__add_transcription_block_mentioned_persons.sql b/backend/src/main/resources/db/migration/V56__add_transcription_block_mentioned_persons.sql new file mode 100644 index 00000000..80a44ef4 --- /dev/null +++ b/backend/src/main/resources/db/migration/V56__add_transcription_block_mentioned_persons.sql @@ -0,0 +1,25 @@ +-- Sidecar table for @-mentions inside transcription_blocks.text. +-- Each row is one (block_id, person_id, display_name) tuple emitted by the +-- typeahead in the transcription editor. block.text contains the literal +-- "@DisplayName" — the UUID lives only here so historical text stays clean. +-- +-- Schema choice: child table via @ElementCollection (mirrors the established +-- UserGroup.permissions / group_permissions pattern), NOT JSONB. The "show +-- all blocks mentioning person X" query on the person detail page joins on +-- the indexed person_id column — equally fast as JSONB GIN containment, no +-- new dependency. document_comments.comment_mentions stays as a many-to-many +-- to AppUser; the divergence is intentional: Person mentions need lazy +-- degradation when a person is deleted (no FK), while user mentions don't. +-- +-- No FK on person_id: when a Person is deleted we want @Auguste Raddatz to +-- remain visible as plain unlinked text inside the transcription rather than +-- vanishing or cascade-deleting the block. + +CREATE TABLE transcription_block_mentioned_persons ( + block_id UUID NOT NULL REFERENCES transcription_blocks(id) ON DELETE CASCADE, + person_id UUID NOT NULL, + display_name VARCHAR(200) NOT NULL +); + +CREATE INDEX idx_tbmp_person_id ON transcription_block_mentioned_persons(person_id); +CREATE INDEX idx_tbmp_block_id ON transcription_block_mentioned_persons(block_id);