summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-04-06 16:25:42 +0000
committerTor Andersson <tor@ccxvii.net>2022-04-15 14:34:17 +0200
commit9b5f4346d31e82dc02763126d5c249cbfebb1e55 (patch)
tree43ca03ad1471522590e085715b1b470745a08001
parent792c7802e1692847662834160b34113e35d35d8d (diff)
downloadserver-9b5f4346d31e82dc02763126d5c249cbfebb1e55.tar.gz
Tweak purge script.
-rw-r--r--tools/purge.sh20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/purge.sh b/tools/purge.sh
index 74e1deb..10cee16 100644
--- a/tools/purge.sh
+++ b/tools/purge.sh
@@ -2,24 +2,24 @@
# Clean out stale games from the database.
-WHERE_TIMEOUT_OPEN="WHERE status = 0 AND mtime < datetime('now', '-7 days')"
+WHERE_TIMEOUT_OPEN="WHERE status = 0 AND ctime < datetime('now', '-7 days')"
WHERE_TIMEOUT_ACTIVE="WHERE status = 1 AND mtime < datetime('now', '-14 days')"
WHERE_TIMEOUT_SOLO="WHERE status = 2 AND mtime < datetime('now', '-3 months') AND is_solo=1"
echo "--- TIMED OUT OPEN GAMES ---"
-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 )"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "SELECT * FROM game_view $WHERE_TIMEOUT_OPEN"
+sqlite3 db -box -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 -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 )"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "SELECT * FROM game_view $WHERE_TIMEOUT_ACTIVE"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "UPDATE games SET status = 3 WHERE game_id IN ( SELECT game_id FROM game_view $WHERE_TIMEOUT_ACTIVE )"
echo "--- ANCIENT SOLO GAMES ---"
-sqlite3 db -cmd "pragma foreign_keys=1" "SELECT * FROM game_full_view $WHERE_TIMEOUT_SOLO"
-sqlite3 db -cmd "pragma foreign_keys=1" "UPDATE games SET status = 3 WHERE game_id IN ( SELECT game_id FROM game_full_view $WHERE_TIMEOUT_SOLO )"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "SELECT * FROM game_full_view $WHERE_TIMEOUT_SOLO"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "UPDATE games SET status = 3 WHERE game_id IN ( SELECT game_id FROM game_full_view $WHERE_TIMEOUT_SOLO )"
echo "--- DELETED MESSAGES ---"
-sqlite3 db -cmd "pragma foreign_keys=1" "SELECT message_id, from_name, to_name, subject FROM message_view WHERE is_deleted_from_inbox=1 AND is_deleted_from_outbox=1"
-sqlite3 db -cmd "pragma foreign_keys=1" "DELETE FROM messages WHERE is_deleted_from_inbox=1 AND is_deleted_from_outbox=1"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "SELECT message_id, from_name, to_name, subject FROM message_view WHERE is_deleted_from_inbox=1 AND is_deleted_from_outbox=1"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "DELETE FROM messages WHERE is_deleted_from_inbox=1 AND is_deleted_from_outbox=1"
-sqlite3 db -cmd "pragma foreign_keys=1" "DELETE FROM game_replay WHERE game_id < 1346"
+sqlite3 db -box -cmd "pragma foreign_keys=1" "DELETE FROM game_replay WHERE game_id < 1346"