summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-07-10 14:41:29 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-13 14:10:20 +0200
commit66f983b8c9bfe547835741fd93d003d56ddea186 (patch)
treeb72e8a1260a6b163e24e03cedf076fbdf19efae9
parent9a455686c7e71e71fa84514760e9fb3202da1ca7 (diff)
downloadserver-66f983b8c9bfe547835741fd93d003d56ddea186.tar.gz
Add trigger to prune game data when archiving a game.
-rw-r--r--schema.sql14
1 files changed, 14 insertions, 0 deletions
diff --git a/schema.sql b/schema.sql
index 8e5ff4d..ff99076 100644
--- a/schema.sql
+++ b/schema.sql
@@ -439,6 +439,20 @@ create view your_turn as
and active in ('All', 'Both', role)
;
+-- Trigger to remove game data when filing a game as archived
+
+drop trigger if exists trigger_archive_game;
+create trigger trigger_archive_game after update on games when new.status = 3
+begin
+ delete from game_state where game_id = old.game_id;
+ delete from game_chat where game_id = old.game_id;
+ delete from game_replay where game_id = old.game_id;
+ delete from game_snap where game_id = old.game_id;
+ delete from game_notes where game_id = old.game_id;
+ delete from last_notified where game_id = old.game_id;
+ delete from unread_chats where game_id = old.game_id;
+end;
+
-- Triggers to clean up without relying on foreign key cascades
drop trigger if exists trigger_delete_on_games;