diff artifact-database/src/main/resources/sql/org-h2-driver.properties @ 195:63f555bbdbc0

Fix a foreign key constraint violation when deleting outdated artifacts. artifacts/trunk@1425 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 08 Mar 2011 10:35:40 +0000
parents 949d69ad3756
children 94654cbf8db2
line wrap: on
line diff
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Mar 08 10:25:51 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Mar 08 10:35:40 2011 +0000
@@ -10,7 +10,9 @@
 artifacts.touch=UPDATE artifacts SET last_access = CURRENT_TIMESTAMP WHERE id = ?
 
 artifacts.outdated=SELECT id, factory, data FROM artifacts WHERE ttl IS NOT NULL \
-    AND DATEDIFF('MILLISECOND', last_access, CURRENT_TIMESTAMP) > ttl LIMIT 50
+    AND DATEDIFF('MILLISECOND', last_access, CURRENT_TIMESTAMP) > ttl \
+    AND id NOT IN (SELECT UNIQUE artifact_id FROM collection_items) \
+    LIMIT 50
 
 artifacts.select.gid=SELECT id, last_access, ttl, factory, data FROM artifacts WHERE gid = ?
 

http://dive4elements.wald.intevation.org