Question about PostRevision.destroy_all


I just used PostRevision.destroy_all for deleting all post revisions. But I figure out that, even though revisions deleted, revision numbers still in here. How can I get rid of it?

I’m sorry if this comes across as being harsh, but IIRC I did let you know that many tables had foreign keys that referenced other tables and deleting stuff from the database was not an easy thing to do and hence not a good idea.

It might be a bit different if table schemas had “ON DELETE CASCADE” but they don’t because database size is not a problem

I also suggested you become familiar with the database tables, but apparently you have not yet done so.

If you go ahead and do things that you were strongly advised to not do by forum members including devs and those that wrote Discourse and would know better than anyone, you can at best expect to have “llttle quirks” like this happen and at worse trash the entire database.

Anyway what you need to do now is restore your latest backup.

1 Like

I don’t care about nor DB size neither db corruption. I’ve regularly backed up everything. This is not a production server. So I can fix what I broke. Even I cannot fix it, no problem. I’ve a database which is have 5k posts, 2k users for testing. I’m testing on it about 1month. All I made is deleting post revisions, removing already “removed” posts. So far so good.

Oh, btw looks like PostRevision.ensure_consistency!; solved that problem.


:thumbsup: You’re lucky you found a way to solve the issue.

1 Like