nuke-room-from-db.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. ## CAUTION:
  3. ## This script will remove (hopefully) all trace of the given room ID from
  4. ## your homeserver.db
  5. ## Do not run it lightly.
  6. set -e
  7. if [ "$1" == "-h" ] || [ "$1" == "" ]; then
  8. echo "Call with ROOM_ID as first option and then pipe it into the database. So for instance you might run"
  9. echo " nuke-room-from-db.sh <room_id> | sqlite3 homeserver.db"
  10. echo "or"
  11. echo " nuke-room-from-db.sh <room_id> | psql --dbname=synapse"
  12. exit
  13. fi
  14. ROOMID="$1"
  15. cat <<EOF
  16. DELETE FROM event_forward_extremities WHERE room_id = '$ROOMID';
  17. DELETE FROM event_backward_extremities WHERE room_id = '$ROOMID';
  18. DELETE FROM event_edges WHERE room_id = '$ROOMID';
  19. DELETE FROM room_depth WHERE room_id = '$ROOMID';
  20. DELETE FROM state_forward_extremities WHERE room_id = '$ROOMID';
  21. DELETE FROM events WHERE room_id = '$ROOMID';
  22. DELETE FROM event_json WHERE room_id = '$ROOMID';
  23. DELETE FROM state_events WHERE room_id = '$ROOMID';
  24. DELETE FROM current_state_events WHERE room_id = '$ROOMID';
  25. DELETE FROM room_memberships WHERE room_id = '$ROOMID';
  26. DELETE FROM feedback WHERE room_id = '$ROOMID';
  27. DELETE FROM topics WHERE room_id = '$ROOMID';
  28. DELETE FROM room_names WHERE room_id = '$ROOMID';
  29. DELETE FROM rooms WHERE room_id = '$ROOMID';
  30. DELETE FROM room_hosts WHERE room_id = '$ROOMID';
  31. DELETE FROM room_aliases WHERE room_id = '$ROOMID';
  32. DELETE FROM state_groups WHERE room_id = '$ROOMID';
  33. DELETE FROM state_groups_state WHERE room_id = '$ROOMID';
  34. DELETE FROM receipts_graph WHERE room_id = '$ROOMID';
  35. DELETE FROM receipts_linearized WHERE room_id = '$ROOMID';
  36. DELETE FROM event_search WHERE room_id = '$ROOMID';
  37. DELETE FROM guest_access WHERE room_id = '$ROOMID';
  38. DELETE FROM history_visibility WHERE room_id = '$ROOMID';
  39. DELETE FROM room_tags WHERE room_id = '$ROOMID';
  40. DELETE FROM room_tags_revisions WHERE room_id = '$ROOMID';
  41. DELETE FROM room_account_data WHERE room_id = '$ROOMID';
  42. DELETE FROM event_push_actions WHERE room_id = '$ROOMID';
  43. DELETE FROM local_invites WHERE room_id = '$ROOMID';
  44. DELETE FROM pusher_throttle WHERE room_id = '$ROOMID';
  45. DELETE FROM event_reports WHERE room_id = '$ROOMID';
  46. DELETE FROM public_room_list_stream WHERE room_id = '$ROOMID';
  47. DELETE FROM stream_ordering_to_exterm WHERE room_id = '$ROOMID';
  48. DELETE FROM event_auth WHERE room_id = '$ROOMID';
  49. DELETE FROM appservice_room_list WHERE room_id = '$ROOMID';
  50. VACUUM;
  51. EOF