Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
UpdateTables | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
onLoadExtensionSchemaUpdates | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\OATHAuth\Hook; |
4 | |
5 | use DatabaseUpdater; |
6 | use MediaWiki\Extension\OATHAuth\Maintenance\UpdateForMultipleDevicesSupport; |
7 | use MediaWiki\Extension\OATHAuth\Maintenance\UpdateTOTPScratchTokensToArray; |
8 | use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; |
9 | |
10 | class UpdateTables implements LoadExtensionSchemaUpdatesHook { |
11 | |
12 | /** |
13 | * @param DatabaseUpdater $updater |
14 | */ |
15 | public function onLoadExtensionSchemaUpdates( $updater ) { |
16 | $type = $updater->getDB()->getType(); |
17 | $baseDir = dirname( __DIR__, 2 ); |
18 | $typePath = "$baseDir/sql/$type"; |
19 | |
20 | $updater->addExtensionUpdateOnVirtualDomain( |
21 | [ 'virtual-oathauth', 'addTable', 'oathauth_types', "$typePath/tables-generated.sql", true ] |
22 | ); |
23 | |
24 | // Ensure that the oathauth_users table is up-to-date if it exists, so that the migration |
25 | // from the old schema to the new one can be done properly. |
26 | if ( $updater->tableExists( 'oathauth_users' ) ) { |
27 | switch ( $type ) { |
28 | case 'mysql': |
29 | case 'sqlite': |
30 | // 1.36 |
31 | $updater->addExtensionUpdate( [ |
32 | 'runMaintenance', |
33 | UpdateTOTPScratchTokensToArray::class, |
34 | "$baseDir/maintenance/updateTOTPScratchTokensToArray.php" |
35 | ] ); |
36 | break; |
37 | |
38 | case 'postgres': |
39 | // 1.38 |
40 | $updater->addExtensionUpdateOnVirtualDomain( [ |
41 | 'virtual-oathauth', |
42 | 'modifyTable', |
43 | 'oathauth_users', |
44 | "$typePath/patch-oathauth_users-drop-oathauth_users_id_seq.sql", |
45 | true |
46 | ] ); |
47 | break; |
48 | } |
49 | |
50 | // 1.41 |
51 | $updater->addExtensionUpdate( [ |
52 | 'runMaintenance', |
53 | UpdateForMultipleDevicesSupport::class, |
54 | "$baseDir/maintenance/UpdateForMultipleDevicesSupport.php" |
55 | ] ); |
56 | $updater->addExtensionUpdateOnVirtualDomain( [ 'virtual-oathauth', 'dropTable', 'oathauth_users' ] ); |
57 | } |
58 | |
59 | // add new updates here |
60 | } |
61 | } |