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/.sqlx/query-13785c2084644fe5a0054c67c16e117dcbfae4f15cd09d364706394989739dc3.json
2024-07-27 16:41:43 +03:00

23 lines
1.2 KiB
JSON

{
"db_name": "PostgreSQL",
"query": "WITH RECURSIVE folder_hierarchy AS (\n -- Start with the given directory\n SELECT \n folder_id \n FROM \n folders \n WHERE \n folder_id = $1\n\n UNION ALL\n\n -- Recursively find all subdirectories\n SELECT \n f.folder_id\n FROM \n folders f\n INNER JOIN \n folder_hierarchy fh ON f.parent_folder_id = fh.folder_id\n),\ndeleted_files AS (\n -- Delete the files and return their IDs\n DELETE FROM \n files \n WHERE \n folder_id IN (SELECT folder_id FROM folder_hierarchy)\n RETURNING file_id\n),\ndeleted_folders AS (\n -- Delete the directories\n DELETE FROM \n folders \n WHERE \n folder_id IN (SELECT folder_id FROM folder_hierarchy)\n)\n-- Return the IDs of deleted files\nSELECT \n file_id \nFROM \n deleted_files;\n",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "file_id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false
]
},
"hash": "13785c2084644fe5a0054c67c16e117dcbfae4f15cd09d364706394989739dc3"
}