16 lines
329 B
MySQL
16 lines
329 B
MySQL
|
WITH
|
||
|
deleted_files AS (
|
||
|
DELETE FROM files USING folders
|
||
|
WHERE
|
||
|
files.folder_id = folders.folder_id
|
||
|
AND folders.owner_id = $1 RETURNING files.file_id
|
||
|
),
|
||
|
deleted_users AS (
|
||
|
DELETE FROM users
|
||
|
WHERE
|
||
|
user_id = $1
|
||
|
)
|
||
|
SELECT
|
||
|
*
|
||
|
FROM
|
||
|
deleted_files;
|