Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 50 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
InstallHandler | |
0.00% |
0 / 50 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
onLoadExtensionSchemaUpdates | |
0.00% |
0 / 50 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\HookHandler; |
4 | |
5 | use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; |
6 | use UpdateNotBlockedKey; |
7 | |
8 | class InstallHandler implements LoadExtensionSchemaUpdatesHook { |
9 | /** |
10 | * @inheritDoc |
11 | */ |
12 | public function onLoadExtensionSchemaUpdates( $updater ) { |
13 | $base = dirname( dirname( __DIR__ ) ); |
14 | $type = $updater->getDB()->getType(); |
15 | |
16 | $updater->addExtensionTable( 'securepoll_entity', "$base/sql/$type/tables-generated.sql" ); |
17 | |
18 | switch ( $type ) { |
19 | case 'mysql': |
20 | // 1.39 |
21 | $updater->modifyExtensionField( |
22 | 'securepoll_elections', |
23 | 'el_end_date', |
24 | "$base/sql/$type/patch-securepoll_elections-timestamps.sql" |
25 | ); |
26 | $updater->modifyExtensionField( |
27 | 'securepoll_votes', |
28 | 'vote_timestamp', |
29 | "$base/sql/$type/patch-securepoll_votes-timestamp.sql" |
30 | ); |
31 | $updater->modifyExtensionField( |
32 | 'securepoll_strike', |
33 | 'st_timestamp', |
34 | "$base/sql/$type/patch-securepoll_strike-timestamp.sql" |
35 | ); |
36 | $updater->modifyExtensionField( |
37 | 'securepoll_cookie_match', |
38 | 'cm_timestamp', |
39 | "$base/sql/$type/patch-securepoll_cookie_match-timestamp.sql" |
40 | ); |
41 | break; |
42 | case 'postgres': |
43 | // 1.39 |
44 | $updater->addExtensionUpdate( [ |
45 | 'changeField', |
46 | 'securepoll_votes', 'vote_timestamp', 'TIMESTAMPTZ', 'th_timestamp::timestamp with time zone' |
47 | ] ); |
48 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_msgs', 'msg_entity' ] ); |
49 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_elections', 'msg_entel_entityity' ] ); |
50 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_voters', 'voter_election' ] ); |
51 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_votes', 'vote_election' ] ); |
52 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_votes', 'vote_voter' ] ); |
53 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_strike', 'st_vote' ] ); |
54 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_cookie_match', 'cm_election' ] ); |
55 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_cookie_match', 'cm_voter_1' ] ); |
56 | $updater->addExtensionUpdate( [ 'dropFkey', 'securepoll_cookie_match', 'cm_voter_2' ] ); |
57 | $updater->dropExtensionIndex( |
58 | 'securepoll_msgs', 'securepoll_msgs_pkey', "$base/sql/$type/patch-securepoll_msgs-drop-pk.sql" |
59 | ); |
60 | break; |
61 | } |
62 | |
63 | // 1.40 |
64 | $updater->dropExtensionIndex( |
65 | 'securepoll_msgs', 'spmsg_entity', "$base/sql/$type/patch-securepoll_msgs-unique-to-pk.sql" |
66 | ); |
67 | $updater->dropExtensionIndex( |
68 | 'securepoll_properties', 'sppr_entity', "$base/sql/$type/patch-securepoll_properties-unique-to-pk.sql" |
69 | ); |
70 | |
71 | $updater->addPostDatabaseUpdateMaintenance( UpdateNotBlockedKey::class ); |
72 | } |
73 | } |