Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 161 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
FlaggedRevsUpdaterHooks | |
0.00% |
0 / 161 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
onLoadExtensionSchemaUpdates | |
0.00% |
0 / 161 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName |
3 | // phpcs:disable MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic |
4 | |
5 | use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; |
6 | |
7 | /** |
8 | * Class containing updater functions for a FlaggedRevs environment |
9 | */ |
10 | class FlaggedRevsUpdaterHooks implements |
11 | LoadExtensionSchemaUpdatesHook |
12 | { |
13 | |
14 | /** |
15 | * @inheritDoc |
16 | */ |
17 | public function onLoadExtensionSchemaUpdates( $du ) { |
18 | $dbType = $du->getDB()->getType(); |
19 | $du->dropExtensionTable( 'flaggedimages' ); |
20 | |
21 | // Initial install tables (current schema) |
22 | $du->addExtensionTable( 'flaggedrevs', __DIR__ . "/$dbType/tables-generated.sql" ); |
23 | |
24 | if ( $dbType == 'mysql' ) { |
25 | $base = __DIR__ . '/mysql'; |
26 | |
27 | // 1.38 |
28 | $du->dropExtensionField( |
29 | 'flaggedrevs', |
30 | 'fr_img_name', |
31 | "$base/patch-drop-fr_img.sql" |
32 | ); |
33 | |
34 | // 1.39 |
35 | $du->dropExtensionField( |
36 | 'flaggedpage_config', |
37 | 'fpc_select', |
38 | "$base/patch-drop-fpc_select.sql" |
39 | ); |
40 | $du->modifyExtensionField( |
41 | 'flaggedpages', |
42 | 'fp_pending_since', |
43 | "$base/patch-flaggedpages-timestamp.sql" |
44 | ); |
45 | $du->modifyExtensionField( |
46 | 'flaggedrevs', |
47 | 'fr_timestamp', |
48 | "$base/patch-flaggedrevs-timestamps.sql" |
49 | ); |
50 | $du->modifyExtensionField( |
51 | 'flaggedrevs_statistics', |
52 | 'frs_timestamp', |
53 | "$base/patch-flaggedrevs_statistics-timestamp.sql" |
54 | ); |
55 | $du->modifyExtensionField( |
56 | 'flaggedpage_config', |
57 | 'fpc_expiry', |
58 | "$base/patch-flaggedpage_config-timestamp.sql" |
59 | ); |
60 | } elseif ( $dbType == 'postgres' ) { |
61 | $base = __DIR__ . '/postgres'; |
62 | |
63 | // 1.38 |
64 | $du->addExtensionUpdate( |
65 | [ 'dropPgIndex', 'flaggedrevs', 'fr_img_sha1' ] |
66 | ); |
67 | $du->addExtensionUpdate( |
68 | [ 'dropPgField', 'flaggedrevs', 'fr_img_name' ] |
69 | ); |
70 | $du->addExtensionUpdate( |
71 | [ 'dropPgField', 'flaggedrevs', 'fr_img_timestamp' ] |
72 | ); |
73 | $du->addExtensionUpdate( |
74 | [ 'dropPgField', 'flaggedrevs', 'fr_img_sha1' ] |
75 | ); |
76 | |
77 | // 1.39 |
78 | $du->addExtensionUpdate( |
79 | [ 'dropPgField', 'flaggedpage_config', 'fpc_select' ] |
80 | ); |
81 | $du->addExtensionUpdate( [ |
82 | 'dropDefault', 'flaggedpages', 'fp_page_id' |
83 | ] ); |
84 | $du->addExtensionUpdate( [ |
85 | 'dropDefault', 'flaggedpages', 'fp_stable' |
86 | ] ); |
87 | $du->addExtensionUpdate( [ |
88 | 'changeField', 'flaggedpages', 'fp_page_id', 'INT', '' |
89 | ] ); |
90 | $du->addExtensionUpdate( [ |
91 | 'changeField', 'flaggedpages', 'fp_reviewed', 'SMALLINT', 'fp_reviewed::SMALLINT DEFAULT 0' |
92 | ] ); |
93 | $du->addExtensionUpdate( [ |
94 | 'changeField', 'flaggedpages', 'fp_stable', 'INT', '' |
95 | ] ); |
96 | $du->addExtensionUpdate( [ |
97 | 'changeField', 'flaggedpages', 'fp_quality', 'SMALLINT', '' |
98 | ] ); |
99 | $du->addExtensionUpdate( [ |
100 | 'dropDefault', 'flaggedrevs', 'fr_rev_id' |
101 | ] ); |
102 | $du->addExtensionUpdate( [ |
103 | 'dropDefault', 'flaggedrevs', 'fr_page_id' |
104 | ] ); |
105 | $du->addExtensionUpdate( [ |
106 | 'dropDefault', 'flaggedrevs', 'fr_tags' |
107 | ] ); |
108 | $du->addExtensionUpdate( [ |
109 | 'changeNullableField', 'flaggedrevs', 'fr_user', 'NOT NULL', true |
110 | ] ); |
111 | $du->addExtensionUpdate( [ |
112 | 'changeNullableField', 'flaggedrevs', 'fr_timestamp', 'NOT NULL', true |
113 | ] ); |
114 | $du->addExtensionUpdate( [ |
115 | 'renameIndex', 'flaggedrevs', 'page_rev', 'fr_page_rev' |
116 | ] ); |
117 | $du->addExtensionUpdate( [ |
118 | 'renameIndex', 'flaggedrevs', 'page_time', 'fr_page_time' |
119 | ] ); |
120 | $du->addExtensionUpdate( [ |
121 | 'renameIndex', 'flaggedrevs', 'page_qal_rev', 'fr_page_qal_rev' |
122 | ] ); |
123 | $du->addExtensionUpdate( [ |
124 | 'renameIndex', 'flaggedrevs', 'page_qal_time', 'fr_page_qal_time' |
125 | ] ); |
126 | $du->addExtensionUpdate( [ |
127 | 'changeField', 'flaggedrevs', 'fr_rev_id', 'INT', '' |
128 | ] ); |
129 | $du->addExtensionUpdate( [ |
130 | 'changeField', 'flaggedrevs', 'fr_page_id', 'INT', '' |
131 | ] ); |
132 | $du->addExtensionUpdate( [ |
133 | 'changeField', 'flaggedrevs', 'fr_user', 'INT', '' |
134 | ] ); |
135 | $du->addExtensionUpdate( [ |
136 | 'changeField', 'flaggedrevs', 'fr_quality', 'SMALLINT', 'fr_quality::SMALLINT DEFAULT 0' |
137 | ] ); |
138 | $du->addExtensionUpdate( [ |
139 | 'dropDefault', 'flaggedpage_config', 'fpc_page_id' |
140 | ] ); |
141 | $du->addExtensionUpdate( [ |
142 | 'changeNullableField', 'flaggedpage_config', 'fpc_expiry', 'NOT NULL', true |
143 | ] ); |
144 | $du->addExtensionUpdate( [ |
145 | 'changeField', 'flaggedpage_config', 'fpc_page_id', 'INT', '' |
146 | ] ); |
147 | $du->addExtensionUpdate( [ |
148 | 'changeField', 'flaggedpage_config', 'fpc_override', 'SMALLINT', '' |
149 | ] ); |
150 | $du->addExtensionUpdate( [ |
151 | 'renameIndex', 'flaggedrevs_tracking', 'namespace_title_from', 'frt_namespace_title_from' |
152 | ] ); |
153 | $du->addExtensionUpdate( [ |
154 | 'changeField', 'flaggedrevs_tracking', 'ftr_from', 'INT', 'ftr_from::INT DEFAULT 0' |
155 | ] ); |
156 | $du->addExtensionUpdate( [ |
157 | 'changeField', 'flaggedrevs_tracking', 'ftr_namespace', 'INT', 'ftr_namespace::INT DEFAULT 0' |
158 | ] ); |
159 | $du->dropExtensionIndex( |
160 | 'flaggedrevs_tracking', 'flaggedrevs_tracking_pkey', "$base/patch-flaggedrevs_tracking-drop-pk.sql" |
161 | ); |
162 | $du->addExtensionUpdate( [ |
163 | 'dropDefault', 'flaggedrevs_promote', 'frp_user_id' |
164 | ] ); |
165 | $du->addExtensionUpdate( [ |
166 | 'dropDefault', 'flaggedrevs_promote', 'frp_user_params' |
167 | ] ); |
168 | $du->addExtensionUpdate( [ |
169 | 'changeField', 'flaggedrevs_promote', 'frp_user_id', 'INT', '' |
170 | ] ); |
171 | } elseif ( $dbType == 'sqlite' ) { |
172 | $base = __DIR__ . '/sqlite'; |
173 | |
174 | // 1.38 |
175 | $du->dropExtensionField( |
176 | 'flaggedrevs', |
177 | 'fr_img_name', |
178 | "$base/patch-drop-fr_img.sql" |
179 | ); |
180 | |
181 | // 1.39 |
182 | $du->dropExtensionField( |
183 | 'flaggedpage_config', |
184 | 'fpc_select', |
185 | "$base/patch-drop-fpc_select.sql" |
186 | ); |
187 | } |
188 | |
189 | // 1.40 |
190 | $du->dropExtensionIndex( |
191 | 'flaggedrevs_tracking', |
192 | 'frt_from_namespace_title', |
193 | __DIR__ . "/$dbType/patch-flaggedrevs_tracking-unique-to-pk.sql" |
194 | ); |
195 | // 1.42 |
196 | $du->dropExtensionTable( 'flaggedtemplates' ); |
197 | $du->dropExtensionTable( 'flaggedpage_pending' ); |
198 | } |
199 | } |