22
33if (c ('Garden.Installed ' )) {
44
5- $ Database = Gdn::database ();
6- $ SQL = $ Database ->sql ();
7-
8- $ Construct = $ Database ->structure ();
9-
105 // Update Vanilla Role Names
116 Gdn::sql ()->update ('Role ' )->set ('Name ' , 'Vanilla Member ' )->where ('RoleID ' , 8 )->put ();
127 Gdn::sql ()->update ('Role ' )->set ('Name ' , 'Vanilla Admin ' )->where ('RoleID ' , 16 )->put ();
138 Gdn::sql ()->update ('Role ' )->set ('Name ' , 'Vanilla Moderator ' )->where ('RoleID ' , 32 )->put ();
149
1510
1611 //
17- // Update Vanilla tables
12+ // Update Vanilla tables and data
1813 //
1914
2015 //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
3124 ON src.CategoryID = c.CategoryID
3225 SET c.GroupID = src.GroupID
33- WHERE c.GroupID is null " );
26+ WHERE c.GroupID IS NULL " );
27+ }
28+
29+
3430
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+ }
3559}
0 commit comments