CREATE TABLE storage_webhook_events ( event_id text PRIMARY KEY, library_id uuid NOT NULL, event_type text NOT NULL, paths jsonb NOT NULL, task_ids jsonb NOT NULL DEFAULT '[]'::jsonb, state text NOT NULL CHECK (state IN ('processing','accepted','failed')), error_code text NOT NULL DEFAULT '', received_at timestamptz NOT NULL DEFAULT now(), completed_at timestamptz ); CREATE INDEX storage_webhook_events_received_idx ON storage_webhook_events(received_at DESC);