Oh my… this is not really an ideal started task, its actually quite fiddly and tricky as you discovered @saurabhp
I think the most correct thing to stop with this unconditional deleting of user actions and deal with elimination of duplication instead. The extra tricky thing is you need to deal with post_actions and user_actions here. Also once you do all this stuff you have to float the correct number up to the topic.
Recovery here is a nighmare, once we allow this then this turns into hell basically to implement cause we need to yank out the likes on recovery.
I kind of want to put dealing with this on the back burner.