Morfik wants to remove all post revisions from their Discourse board to reduce database size. zogstrip suggests not worrying about it, but Morfik is still interested in removing them. zogstrip proposes two SQL queries to delete all post revisions and update post versions. Morfik finds this solution promising and decides to test it. They then provide the exact SQL commands to delete post revisions and update post versions, as suggested by zogstrip.
I’ve been editing posts on my board, mainly in order to fix weird post formating after importing the old database and also to convert links to oneboxes – it needed a little work, but it’s done now.
The problem is that many posts now have 2-5 revisions, which makes the database larger. The posts revisions could be safely removed because I obviously don’t need them, at least these ones.
So is there a way to remove all the post revisions somehow?
discourse-# \connect discourse
discourse=# delete from post_revisions *;
discourse=# update posts set public_version=1 where public_version>1;
discourse=# update posts set version=1 where version>1;