Prevent files from being deleted upon module deletion if they belong to documents or comments that have since been moved to a different module

This commit is contained in:
Kijin Sung 2025-03-13 22:57:38 +09:00
parent b213fc1968
commit beec50f217
2 changed files with 39 additions and 4 deletions

View file

@ -0,0 +1,31 @@
<query id="getModuleFilesProper" action="select">
<tables>
<table name="files" />
<table name="documents" type="left join">
<conditions>
<condition operation="equal" column="files.upload_target_srl" default="documents.document_srl" />
</conditions>
</table>
<table name="comments" type="left join">
<conditions>
<condition operation="equal" column="files.upload_target_srl" default="comments.comment_srl" />
</conditions>
</table>
</tables>
<columns>
<column name="files.*" />
<column name="documents.module_srl" alias="d_module_srl" />
<column name="comments.module_srl" alias="c_module_srl" />
</columns>
<conditions>
<condition operation="equal" column="files.module_srl" var="module_srl" filter="number" notnull="notnull" />
<group pipe="and">
<condition operation="equal" column="documents.module_srl" var="module_srl" filter="number" notnull="notnull" />
<condition operation="null" column="documents.module_srl" pipe="or" />
</group>
<group pipe="and">
<condition operation="equal" column="comments.module_srl" var="module_srl" filter="number" notnull="notnull" />
<condition operation="null" column="comments.module_srl" pipe="or" />
</group>
</conditions>
</query>