1
14
15 package com.liferay.portal.upgrade.v5_2_3;
16
17 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
18 import com.liferay.portal.kernel.util.StringBundler;
19
20
25 public class UpgradeMessageBoards extends UpgradeProcess {
26
27 protected void doUpgrade() throws Exception {
28 updateGroupId();
29 updateMessageClassNameId();
30 updateMessageFlagThreadId();
31 updateMessagePriority();
32 }
33
34 protected void updateGroupId() throws Exception {
35 StringBundler sb = new StringBundler(3);
36
37 sb.append("update MBCategory set threadCount = (select count(*) from ");
38 sb.append("MBThread where MBThread.categoryId = ");
39 sb.append("MBCategory.categoryId)");
40
41 runSQL(sb.toString());
42
43 sb.setIndex(0);
44
45 sb.append("update MBCategory set messageCount = (select count(*) ");
46 sb.append("from MBMessage where MBMessage.categoryId = ");
47 sb.append("MBCategory.categoryId)");
48
49 runSQL(sb.toString());
50
51 sb.setIndex(0);
52
53 sb.append("update MBMessage set groupId = (select groupId from ");
54 sb.append("MBCategory where MBCategory.categoryId = ");
55 sb.append("MBMessage.categoryId)");
56
57 runSQL(sb.toString());
58
59 sb.setIndex(0);
60
61 sb.append("update MBThread set groupId = (select groupId from ");
62 sb.append("MBCategory where MBCategory.categoryId = ");
63 sb.append("MBThread.categoryId)");
64
65 runSQL(sb.toString());
66 }
67
68 protected void updateMessageClassNameId() throws Exception {
69 StringBundler sb = new StringBundler(5);
70
71 sb.append("update MBMessage set classNameId = (select classNameId ");
72 sb.append("from MBDiscussion where MBDiscussion.threadId = ");
73 sb.append("MBMessage.threadId), classPK = (select classPK from ");
74 sb.append("MBDiscussion where MBDiscussion.threadId = ");
75 sb.append("MBMessage.threadId)");
76
77 runSQL(sb.toString());
78 }
79
80 protected void updateMessageFlagThreadId() throws Exception {
81 StringBundler sb = new StringBundler(3);
82
83 sb.append("update MBMessageFlag set threadId = (select threadId from ");
84 sb.append("MBMessage where MBMessage.messageId = ");
85 sb.append("MBMessageFlag.messageId)");
86
87 runSQL(sb.toString());
88 }
89
90 protected void updateMessagePriority() throws Exception {
91 StringBundler sb = new StringBundler(2);
92
93 sb.append("update MBMessage set priority = (select priority from ");
94 sb.append("MBThread where MBThread.threadId = MBMessage.threadId)");
95
96 runSQL(sb.toString());
97 }
98
99 }