summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-11-13 19:03:07 +0100
committerTor Andersson <tor@ccxvii.net>2021-11-13 19:03:07 +0100
commit8f3a28d965546f89cba27b23a3d7d545e889b4cb (patch)
treeaa55d36645c39883f09bae352284fd508733ebcf /tools
parent0d0dab23fb0ecf16a2abf54295746d7dbd87c2d7 (diff)
downloadserver-8f3a28d965546f89cba27b23a3d7d545e889b4cb.tar.gz
Update tools for new SQL schema.
Diffstat (limited to 'tools')
-rw-r--r--tools/purge.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/purge.sh b/tools/purge.sh
index af64787..b1db2a7 100644
--- a/tools/purge.sh
+++ b/tools/purge.sh
@@ -6,15 +6,15 @@ WHERE_TIMEOUT_OPEN="WHERE status = 0 AND mtime < datetime('now', '-7 days')"
WHERE_TIMEOUT_ACTIVE="WHERE status = 1 AND mtime < datetime('now', '-14 days')"
echo "--- TIMED OUT OPEN GAMES ---"
-sqlite3 db "SELECT * FROM game_view $WHERE_TIMEOUT_OPEN"
-sqlite3 db "DELETE FROM games $WHERE_TIMEOUT_OPEN"
+sqlite3 db -cmd "pragma foreign_keys=1" "SELECT * FROM game_view $WHERE_TIMEOUT_OPEN"
+sqlite3 db -cmd "pragma foreign_keys=1" "DELETE FROM games WHERE game_id IN ( SELECT game_id FROM game_view $WHERE_TIMEOUT_OPEN )"
echo "--- TIMED OUT ACTIVE GAMES ---"
-sqlite3 db "SELECT * FROM game_view $WHERE_TIMEOUT_ACTIVE"
-sqlite3 db "UPDATE games SET status = 3 $WHERE_TIMEOUT_ACTIVE"
+sqlite3 db -cmd "pragma foreign_keys=1" "SELECT * FROM game_view $WHERE_TIMEOUT_ACTIVE"
+sqlite3 db -cmd "pragma foreign_keys=1" "UPDATE games SET status = 3 WHERE game_id IN ( SELECT game_id FROM game_view $WHERE_TIMEOUT_ACTIVE )"
echo "--- DELETED MESSAGES ---"
-sqlite3 db "SELECT message_id, from_name, to_name, subject FROM message_view WHERE deleted_from_inbox=1 AND deleted_from_outbox=1"
-sqlite3 db "DELETE FROM messages WHERE deleted_from_inbox=1 AND deleted_from_outbox=1"
+sqlite3 db -cmd "pragma foreign_keys=1" "SELECT message_id, from_name, to_name, subject FROM message_view WHERE deleted_from_inbox=1 AND deleted_from_outbox=1"
+sqlite3 db -cmd "pragma foreign_keys=1" "DELETE FROM messages WHERE deleted_from_inbox=1 AND deleted_from_outbox=1"
-sqlite3 db "DELETE FROM replay WHERE game_id < 1346"
+sqlite3 db -cmd "pragma foreign_keys=1" "DELETE FROM game_replay WHERE game_id < 1346"