2
2
3
3
if (c ('Garden.Installed ' )) {
4
4
5
- $ Database = Gdn::database ();
6
- $ SQL = $ Database ->sql ();
7
-
8
- $ Construct = $ Database ->structure ();
9
-
10
5
// Update Vanilla Role Names
11
6
Gdn::sql ()->update ('Role ' )->set ('Name ' , 'Vanilla Member ' )->where ('RoleID ' , 8 )->put ();
12
7
Gdn::sql ()->update ('Role ' )->set ('Name ' , 'Vanilla Admin ' )->where ('RoleID ' , 16 )->put ();
13
8
Gdn::sql ()->update ('Role ' )->set ('Name ' , 'Vanilla Moderator ' )->where ('RoleID ' , 32 )->put ();
14
9
15
10
16
11
//
17
- // Update Vanilla tables
12
+ // Update Vanilla tables and data
18
13
//
19
14
20
15
//Add extra columns in Category : https://github.com/topcoder-platform/forums/issues/178
21
- $ Construct ->table ('Category ' );
22
- $ GroupIDExists = $ Construct ->columnExists ('GroupID ' );
23
- if (!$ GroupIDExists ) {
24
- $ Construct ->column ('GroupID ' , 'int ' , true , 'key ' );
25
- $ Construct ->set (false , false );
26
- }
27
-
28
- // Update data after adding GroupID column: https://github.com/topcoder-platform/forums/issues/178
29
- Gdn::sql ()->query ("UPDATE GDN_Category c
30
- INNER JOIN (select c.CategoryID, g.GroupID from GDN_Category c , GDN_Group g where c.UrlCode like concat(g.ChallengeID,'%')) as src
16
+ if (!Gdn::structure ()->table ('Category ' )->columnExists ('GroupID ' )) {
17
+ Gdn::structure ()->table ('Category ' )
18
+ ->column ('GroupID ' , 'int ' , true , 'key ' )
19
+ ->set (false , false );
20
+
21
+ // Update data after adding GroupID column: https://github.com/topcoder-platform/forums/issues/178
22
+ Gdn::sql ()->query ("UPDATE GDN_Category c
23
+ INNER JOIN (SELECT c.CategoryID, g.GroupID FROM GDN_Category c , GDN_Group g WHERE c.UrlCode LIKE concat(g.ChallengeID,'%')) AS src
31
24
ON src.CategoryID = c.CategoryID
32
25
SET c.GroupID = src.GroupID
33
- WHERE c.GroupID is null " );
26
+ WHERE c.GroupID IS NULL " );
27
+ }
28
+
29
+
34
30
31
+ // Add the column Type in Group : https://github.com/topcoder-platform/forums/issues/133
32
+ if (! Gdn::structure ()->table ('Group ' )->columnExists ('Privacy ' )) {
33
+ if (Gdn::structure ()->table ('Group ' )->renameColumn ('Type ' , 'Privacy ' )) {
34
+
35
+ // Reset the internal state of this object so that it can be reused.
36
+ Gdn::structure ()->reset ();
37
+
38
+ Gdn::structure ()->table ('Group ' )
39
+ ->column ('Type ' , ['challenge ' , 'regular ' ], true )
40
+ ->set (false , false );
41
+
42
+ // Update existing data, all groups with ChallengeID will have the type 'challenge'
43
+ Gdn::sql ()->query ("UPDATE GDN_Group g
44
+ SET g.Type = CASE WHEN g.ChallengeID IS NOT NULL THEN 'challenge'
45
+ ELSE 'regular' END " );
46
+
47
+ Gdn::structure ()->table ('Group ' )
48
+ ->column ('Type ' , ['challenge ' , 'regular ' ], false )
49
+ ->set (false , false );
50
+ }
51
+ }
52
+
53
+ // Add the column Archived in Group : https://github.com/topcoder-platform/forums/issues/136
54
+ if (!Gdn::structure ()->table ('Group ' )->columnExists ('Archived ' )) {
55
+ Gdn::structure ()->table ('Group ' )
56
+ ->column ('Archived ' , 'tinyint(1) ' , '0 ' )
57
+ ->set (false , false );
58
+ }
35
59
}
0 commit comments