Is there a way to remove all post revisions from all the posts?

(Mikhail Morfikov) #1

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?

(Régis Hanol) #2

I would not worry about that.

An image would be worth 100s (if not 1000s) of post revisions storage-wise.

(Mikhail Morfikov) #3

Hmm, but is there a way to remove them all? I’m just curious :smiley:

(Régis Hanol) #4

If you know SQL, then it’s two queries away

  • delete everything in the post_revisions table
  • update version and public_version on the posts table to 1


(Mikhail Morfikov) #5

I think that’s the solution I’ve been looking for. :slight_smile: I’ll test how it works and see whether it’s worth doing.

(Mikhail Morfikov) #6

Ok, so it would be something like this, right?

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;