This repository has been archived on 2024-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
project/sql/delete_permissions.sql

20 lines
469 B
MySQL
Raw Permalink Normal View History

2024-07-27 19:08:56 +00:00
WITH RECURSIVE folder_hierarchy AS (
-- Start with the given directory
SELECT
folder_id
FROM
folders
WHERE
folder_id = $1
UNION ALL
-- Recursively find all subdirectories
SELECT
f.folder_id
FROM
folders f
INNER JOIN
folder_hierarchy fh ON f.parent_folder_id = fh.folder_id
)
DELETE FROM permissions WHERE user_id = $2 AND folder_id IN (SELECT folder_id FROM folder_hierarchy)