add database prune sql script

This commit is contained in:
skylar
2025-08-03 04:03:22 -05:00
parent e8639069fb
commit fd9ca3ee17
2 changed files with 48 additions and 1 deletions

View File

@ -1,4 +1,4 @@
Deletes are the danger zone, deleting activities from the table can and will introduce weird problems. For example, when a new activity federates in referencing a deleted activity, it'll cause notifications to temporarily break for the affected user(s). Pleroma will look in the table for the activity it's referencing, that'll time out, and the request to load notifications into pleroma-fe will 502 and they'll just be blank.
Deletes are the danger zone, deleting activities from the table can and will introduce weird problems. For example, when a new activity federates in referencing a deleted activity, it'll cause notifications to temporarily break for the affected user(s). Pleroma will look in the table for the activity it's referencing, that'll fail, and users will see one or more 500 errors on screen.
But if it's a choice between killing the instance entirely due to storage constraints or deleting activities and accepting the risk of errors, we can delete them. Before you delete anything, take a look at how to clean up pg_repack remnants [here](https://git.yandere.love/skylar/pleromer-stuff/src/branch/main/repack.md).
@ -52,3 +52,11 @@ counter := counter + 1;
end loop;
end$$;
```
To prune the database on a recurring basis, adjust this [SQL file](https://git.yandere.love/skylar/pleromer-stuff/src/branch/main/database_prune.sql) to your desired retention period for activities, objects, and notifications, then execute it with:
```
sudo -Hu postgres psql -f /path/to/database_prune.sql
```
If you've named your database something other than "pleroma", that will need to be changed as well.