From d13f6f69d5dfc2fa51d48a97006bfd8fc36efde7 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 5 Apr 2026 20:29:41 +0200 Subject: [PATCH] fix(migration): add CHECK constraint on text length (defense in depth) V18: text column now has CHECK (length(text) <= 10000) to enforce the 10,000 character limit at the database level, complementing the application-level enforcement in TranscriptionService.sanitizeText(). Fixes @Nora: "DB constraint catches anything the application misses" Co-Authored-By: Claude Sonnet 4.6 --- .../resources/db/migration/V18__add_transcription_blocks.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/resources/db/migration/V18__add_transcription_blocks.sql b/backend/src/main/resources/db/migration/V18__add_transcription_blocks.sql index 524a2649..94fc30de 100644 --- a/backend/src/main/resources/db/migration/V18__add_transcription_blocks.sql +++ b/backend/src/main/resources/db/migration/V18__add_transcription_blocks.sql @@ -2,7 +2,7 @@ CREATE TABLE transcription_blocks ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), annotation_id UUID NOT NULL REFERENCES document_annotations(id) ON DELETE RESTRICT, document_id UUID NOT NULL REFERENCES documents(id) ON DELETE CASCADE, - text TEXT NOT NULL DEFAULT '', + text TEXT NOT NULL DEFAULT '' CHECK (length(text) <= 10000), label VARCHAR(200), sort_order INTEGER NOT NULL DEFAULT 0, version INTEGER NOT NULL DEFAULT 0,