From f76a6c0ee56b421fdbb9bfa12f90a6927fd1022c Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 14 Apr 2026 10:38:11 +0200 Subject: [PATCH] migration(annotations): add chk_annotation_bounds CHECK constraint (V33) Co-Authored-By: Claude Sonnet 4.6 --- .../V33__add_annotation_bounds_constraint.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V33__add_annotation_bounds_constraint.sql diff --git a/backend/src/main/resources/db/migration/V33__add_annotation_bounds_constraint.sql b/backend/src/main/resources/db/migration/V33__add_annotation_bounds_constraint.sql new file mode 100644 index 00000000..608ebe99 --- /dev/null +++ b/backend/src/main/resources/db/migration/V33__add_annotation_bounds_constraint.sql @@ -0,0 +1,12 @@ +-- Enforce valid normalized coordinate ranges for annotation bounding boxes. +-- x and y must be within [0, 1]; width and height must be at least 1% of the +-- document dimension and at most 100%. +-- Consistent with the application-layer minimum draw threshold (0.01). +ALTER TABLE document_annotations + ADD CONSTRAINT chk_annotation_bounds + CHECK ( + x >= 0 AND x <= 1 AND + y >= 0 AND y <= 1 AND + width >= 0.01 AND width <= 1 AND + height >= 0.01 AND height <= 1 + );