Merge remote-tracking branch 'origin/develop' into reactions
[akkoma] / docs / administration / CLI_tasks / database.md
1 # Database maintenance tasks
2
3 Every command should be ran with a prefix, in case of OTP releases it is `./bin/pleroma_ctl database` and in case of source installs it's `mix pleroma.database`.
4
5 ## Replace embedded objects with their references
6
7 Replaces embedded objects with references to them in the `objects` table. Only needs to be ran once if the instance was created before Pleroma 1.0.5. The reason why this is not a migration is because it could significantly increase the database size after being ran, however after this `VACUUM FULL` will be able to reclaim about 20% (really depends on what is in the database, your mileage may vary) of the db size before the migration.
8
9 ```sh
10 $PREFIX remove_embedded_objects [<options>]
11 ```
12
13 ### Options
14 - `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references
15
16 ## Prune old remote posts from the database
17
18 This will prune remote posts older than 90 days (configurable with [`config :pleroma, :instance, remote_post_retention_days`](../../configuration/cheatsheet.md#instance)) from the database, they will be refetched from source when accessed.
19
20 !!! note
21 The disk space will only be reclaimed after `VACUUM FULL`
22
23 ```sh
24 $PREFIX pleroma.database prune_objects [<options>]
25 ```
26
27 ### Options
28 - `--vacuum` - run `VACUUM FULL` after the objects are pruned
29
30 ## Create a conversation for all existing DMs
31
32 Can be safely re-run
33
34 ```sh
35 $PREFIX bump_all_conversations
36 ```
37
38 ## Remove duplicated items from following and update followers count for all users
39
40 ```sh
41 $PREFIX update_users_following_followers_counts
42 ```
43
44 ## Fix the pre-existing "likes" collections for all objects
45
46 ```sh
47 $PREFIX fix_likes_collections
48 ```