001
014
015 package com.liferay.portal.upgrade.v5_2_3;
016
017 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018 import com.liferay.portal.kernel.util.StringBundler;
019
020
023 public class UpgradeMessageBoards extends UpgradeProcess {
024
025 @Override
026 protected void doUpgrade() throws Exception {
027 updateGroupId();
028 updateMessageClassNameId();
029 updateMessageFlagThreadId();
030 updateMessagePriority();
031 }
032
033 protected void updateGroupId() throws Exception {
034 StringBundler sb = new StringBundler(3);
035
036 sb.append("update MBCategory set threadCount = (select count(*) from ");
037 sb.append("MBThread where MBThread.categoryId = ");
038 sb.append("MBCategory.categoryId)");
039
040 runSQL(sb.toString());
041
042 sb.setIndex(0);
043
044 sb.append("update MBCategory set messageCount = (select count(*) ");
045 sb.append("from MBMessage where MBMessage.categoryId = ");
046 sb.append("MBCategory.categoryId)");
047
048 runSQL(sb.toString());
049
050 sb.setIndex(0);
051
052 sb.append("update MBMessage set groupId = (select groupId from ");
053 sb.append("MBCategory where MBCategory.categoryId = ");
054 sb.append("MBMessage.categoryId)");
055
056 runSQL(sb.toString());
057
058 sb.setIndex(0);
059
060 sb.append("update MBThread set groupId = (select groupId from ");
061 sb.append("MBCategory where MBCategory.categoryId = ");
062 sb.append("MBThread.categoryId)");
063
064 runSQL(sb.toString());
065 }
066
067 protected void updateMessageClassNameId() throws Exception {
068 StringBundler sb = new StringBundler(5);
069
070 sb.append("update MBMessage set classNameId = (select classNameId ");
071 sb.append("from MBDiscussion where MBDiscussion.threadId = ");
072 sb.append("MBMessage.threadId), classPK = (select classPK from ");
073 sb.append("MBDiscussion where MBDiscussion.threadId = ");
074 sb.append("MBMessage.threadId)");
075
076 runSQL(sb.toString());
077 }
078
079 protected void updateMessageFlagThreadId() throws Exception {
080 StringBundler sb = new StringBundler(3);
081
082 sb.append("update MBMessageFlag set threadId = (select threadId from ");
083 sb.append("MBMessage where MBMessage.messageId = ");
084 sb.append("MBMessageFlag.messageId)");
085
086 runSQL(sb.toString());
087 }
088
089 protected void updateMessagePriority() throws Exception {
090 StringBundler sb = new StringBundler(2);
091
092 sb.append("update MBMessage set priority = (select priority from ");
093 sb.append("MBThread where MBThread.threadId = MBMessage.threadId)");
094
095 runSQL(sb.toString());
096 }
097
098 }