johnnyhowey/liferay-portal — pull request #81 by yuhai (2014-08-22 09:40:30+00:00)
Title: SOS-2386

We should not be writing portal upgrade that deletes entries from the table, so we should use "update" to replace "delete"

Due to we can't get unique key between SocialActivity and other Entries table(WikiPage..) so that we can't use one simply sql (inner join) to achieve our expected.

For example, for wiki, dl and web content, they may have multiple versions. When we add these different versions, related data will be insert into SocialActivity table. So it will exist duplicated data in below fields of SocialActivity.
"
groupId, userId, classNameId, classPK, receiverUserId, type (all larger than 1.0 version, type will be "2").
"

The fix logic is as the followings:
1. We firstly get unique classPK of these tables because classPK might have multiple versions data (for example, wikipage table).
2. For the detailed classPK entry, for example, it has 3 versions(1.0,1.1,1.2). When we created these versions, in SocialActivity table, it also will create related datas to match the three version. I think we can match related data between SocialActivity and wikipage table by data's creating order. So this is main point regarding the fix.

Please help check the fix.

Thanks,
Hai