ALTER TABLE medreport.ai_responses ENABLE ROW LEVEL SECURITY;

CREATE POLICY "ai_responses_select" ON medreport.ai_responses FOR SELECT TO authenticated USING (true);
CREATE POLICY "ai_responses_insert" ON medreport.ai_responses FOR INSERT TO authenticated WITH CHECK (true);

grant select, insert, update, delete on table medreport.ai_responses to authenticated;

ALTER TABLE medreport.ai_responses
ALTER COLUMN prompt_id TYPE text
USING prompt_name::text;

ALTER TABLE medreport.ai_responses
ALTER COLUMN prompt_name TYPE text
USING prompt_name::text;

ALTER TABLE medreport.ai_responses
ADD CONSTRAINT ai_responses_id_pkey PRIMARY KEY (id);
