Files
khb_microservices/packages/khb_common/migrations/004_agent_role_grants.sql
Yuri Yaryshev e203d2cc1e
All checks were successful
ci / test (push) Successful in 14s
ci / deploy (push) Successful in 1m18s
agent_mcp: отдельный MCP для рутин Claude, роль khb_agent (миграция 004), деплой, документация
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 14:34:26 +03:00

28 lines
1.9 KiB
SQL

-- Права роли khb_agent (рутины Claude через MCP agent_mcp). Роль создаётся отдельно администратором БД
-- (create role khb_agent login ...), поэтому миграция выполняется только если роль существует.
-- Белый список объектов: чтение - v_agent_input, reminder_history, active_task_list, active_task;
-- запись (insert/update, без delete) - active_task_list, active_task.
do $$
begin
if exists (select 1 from pg_roles where rolname = 'khb_agent') then
grant usage on schema public to khb_agent;
grant select on v_agent_input, reminder_history, active_task_list, active_task to khb_agent;
grant insert, update on active_task_list, active_task to khb_agent;
drop policy if exists khb_agent_read on reminder_history;
create policy khb_agent_read on reminder_history for select to khb_agent using (true);
drop policy if exists khb_agent_read on active_task_list;
create policy khb_agent_read on active_task_list for select to khb_agent using (true);
drop policy if exists khb_agent_write on active_task_list;
create policy khb_agent_write on active_task_list for insert to khb_agent with check (true);
drop policy if exists khb_agent_update on active_task_list;
create policy khb_agent_update on active_task_list for update to khb_agent using (true) with check (true);
drop policy if exists khb_agent_read on active_task;
create policy khb_agent_read on active_task for select to khb_agent using (true);
drop policy if exists khb_agent_write on active_task;
create policy khb_agent_write on active_task for insert to khb_agent with check (true);
drop policy if exists khb_agent_update on active_task;
create policy khb_agent_update on active_task for update to khb_agent using (true) with check (true);
end if;
end $$;