diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-07-02 20:53:49 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-07-23 13:47:44 +0200 |
commit | dda6b1d635023d43f6e8ea63936824f4b2ef17ef (patch) | |
tree | 84905bbb452be824397a78124e4587d8e368d03b /tools/purge.sql | |
parent | f93ebad5249418fc19d8cda818805bb0f5ede727 (diff) | |
download | server-dda6b1d635023d43f6e8ea63936824f4b2ef17ef.tar.gz |
Fix purge script.
Diffstat (limited to 'tools/purge.sql')
-rw-r--r-- | tools/purge.sql | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/purge.sql b/tools/purge.sql index e48e305..3e0c898 100644 --- a/tools/purge.sql +++ b/tools/purge.sql @@ -1,13 +1,15 @@ -- Prune game snapshot and game state data to save database space. +attach database 'db' as live; + create temporary view prune_snap_list as select distinct game_id from - game_snap + live.game_snap where game_id in ( - select game_id from games + select game_id from live.games where status=2 and date(mtime) < date('now', '-7 days') ) ; @@ -16,10 +18,10 @@ create temporary view prune_all_list as select distinct game_id from - games + live.games where game_id in ( - select game_id from games + select game_id from live.games where status=2 and date(mtime) < date('now', '-28 days') ) ; @@ -27,9 +29,9 @@ create temporary view prune_all_list as begin; select 'PURGE SNAPS FROM ' || count(1) from prune_snap_list; -delete from game_snap where game_id in (select game_id from prune_snap_list); +delete from live.game_snap where game_id in (select game_id from prune_snap_list); select 'PURGE ALL FROM ' || count(1) from prune_all_list; -update games set status = 3 where game_id in (select game_id from prune_all_list); +update live.games set status = 3 where game_id in (select game_id from prune_all_list); commit; |