begin;

do $$
begin
  if exists (select 1 from pg_roles where rolname = 'admin_runtime') then
    drop policy if exists model_providers_admin_select on public.model_providers;
    create policy model_providers_admin_select on public.model_providers
      for select to admin_runtime using (true);

    drop policy if exists model_configs_admin_select on public.model_configs;
    create policy model_configs_admin_select on public.model_configs
      for select to admin_runtime using (true);

    drop policy if exists model_config_versions_admin_select on public.model_config_versions;
    create policy model_config_versions_admin_select on public.model_config_versions
      for select to admin_runtime using (true);

    drop policy if exists model_publish_events_admin_select on public.model_publish_events;
    create policy model_publish_events_admin_select on public.model_publish_events
      for select to admin_runtime using (true);

    drop policy if exists model_connection_test_evidence_admin_select on public.model_connection_test_evidence;
    create policy model_connection_test_evidence_admin_select on public.model_connection_test_evidence
      for select to admin_runtime using (true);
  end if;
end;
$$;

commit;
