diff options
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; |