28 lines
1.9 KiB
SQL
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 $$;
|