Files
windmill/backend/migrations/20260610151334_folder_labels.up.sql
Ruben Fiszel 765f50c474 feat: folder-level label inheritance for scripts, flows and jobs (#9524)
* feat: folder-level label inheritance for scripts, flows and jobs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: use SECURITY DEFINER folder_labels() for RLS-consistent inheritance

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat: extend folder label inheritance to apps, resources, variables, schedules

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 07:49:02 +00:00

14 lines
734 B
PL/PgSQL

-- Add up migration script here
ALTER TABLE folder ADD COLUMN labels text[];
-- Returns the labels of the folder containing the given item path ('f/<folder>/...').
-- SECURITY DEFINER so it bypasses folder RLS: inherited labels must be consistent
-- regardless of who reads the item or pushes the job (a user can have access to an
-- item without being in the folder's extra_perms, and label values are already
-- workspace-visible via the labels/list endpoint).
CREATE FUNCTION folder_labels(w_id text, item_path text) RETURNS text[]
LANGUAGE sql STABLE SECURITY DEFINER SET search_path = public AS $$
SELECT labels FROM folder
WHERE workspace_id = w_id AND item_path LIKE 'f/%' AND name = split_part(item_path, '/', 2)
$$;