-- Add optional polygon field for quadrilateral annotation shapes (Kraken OCR output).
-- See ADR-002 for the design decision.

ALTER TABLE document_annotations ADD COLUMN polygon JSONB;

ALTER TABLE document_annotations
ADD CONSTRAINT chk_annotation_polygon_quad
    CHECK (polygon IS NULL OR jsonb_array_length(polygon) = 4);
