CREATE TABLE document_annotations (
    id          UUID             PRIMARY KEY DEFAULT gen_random_uuid(),
    document_id UUID             NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
    page_number INTEGER          NOT NULL,
    x           DOUBLE PRECISION NOT NULL,
    y           DOUBLE PRECISION NOT NULL,
    width       DOUBLE PRECISION NOT NULL,
    height      DOUBLE PRECISION NOT NULL,
    color       VARCHAR(20)      NOT NULL,
    created_by  UUID             REFERENCES users(id) ON DELETE SET NULL,
    created_at  TIMESTAMP        NOT NULL DEFAULT now()
);

CREATE INDEX ON document_annotations (document_id, page_number);
