CREATE TABLE medreport.medipost_actions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    action VARCHAR(255) NOT NULL,
    xml VARCHAR(131072),
    has_analysis_results BOOLEAN NOT NULL DEFAULT FALSE,
    medusa_order_id VARCHAR(255),
    created_at TIMESTAMP WITH TIME ZONE DEFAULT now()
);

ALTER TABLE medreport.medipost_actions ENABLE ROW LEVEL SECURITY;

CREATE POLICY "service_role_select" ON medreport.medipost_actions FOR SELECT TO service_role USING (true);
CREATE POLICY "service_role_insert" ON medreport.medipost_actions FOR INSERT TO service_role WITH CHECK (true);
CREATE POLICY "service_role_update" ON medreport.medipost_actions FOR UPDATE TO service_role USING (true);
CREATE POLICY "service_role_delete" ON medreport.medipost_actions FOR DELETE TO service_role USING (true);
grant select, insert, update, delete on table medreport.medipost_actions to service_role;
