agent_mcp: отдельный MCP для рутин Claude, роль khb_agent (миграция 004), деплой, документация
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
27
packages/khb_common/migrations/004_agent_role_grants.sql
Normal file
27
packages/khb_common/migrations/004_agent_role_grants.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- Права роли 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 $$;
|
||||
Reference in New Issue
Block a user