Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
UpdateTables
n/a
0 / 0
n/a
0 / 0
2
n/a
0 / 0
 onLoadExtensionSchemaUpdates
n/a
0 / 0
n/a
0 / 0
2
1<?php
2declare( strict_types=1 );
3
4namespace MediaWiki\Extension\OATHAuth\Hook;
5
6use MediaWiki\Extension\OATHAuth\Maintenance\MoveRecoveryCodesFromTOTP;
7use MediaWiki\Extension\OATHAuth\Maintenance\PopulateUserHandles;
8use MediaWiki\Extension\OATHAuth\Maintenance\UpdateForMultipleDevicesSupport;
9use MediaWiki\Extension\OATHAuth\Maintenance\UpdateKeysToLatestVersion;
10use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook;
11
12/** @codeCoverageIgnore */
13class UpdateTables implements LoadExtensionSchemaUpdatesHook {
14
15    /** @inheritDoc */
16    public function onLoadExtensionSchemaUpdates( $updater ) {
17        $type = $updater->getDB()->getType();
18        $baseDir = dirname( __DIR__, 2 );
19        $typePath = "$baseDir/sql/$type";
20
21        $updater->addExtensionUpdateOnVirtualDomain(
22            [ 'virtual-oathauth', 'addTable', 'oathauth_types', "$typePath/tables-generated.sql", true ]
23        );
24
25        // Ensure that the oathauth_users table is up-to-date if it exists, so that the migration
26        // from the old schema to the new one can be done properly.
27        if ( $updater->tableExists( 'oathauth_users' ) ) {
28            // 1.41
29            $updater->addExtensionUpdateOnVirtualDomain( [
30                'virtual-oathauth',
31                'runMaintenance',
32                UpdateForMultipleDevicesSupport::class,
33            ] );
34            $updater->addExtensionUpdateOnVirtualDomain( [ 'virtual-oathauth', 'dropTable', 'oathauth_users' ] );
35        }
36
37        // 1.45
38        $updater->addPostDatabaseUpdateMaintenance( MoveRecoveryCodesFromTOTP::class );
39
40        // 1.46
41        $updater->addExtensionUpdateOnVirtualDomain( [
42            'virtual-oathauth', 'addTable', 'oathauth_user_handles',
43            "$typePath/patch-add-oathauth_user_handles.sql", true
44        ] );
45        $updater->addPostDatabaseUpdateMaintenance( PopulateUserHandles::class );
46
47        // add new updates here
48
49        // 1.47
50        // This was added in 1.47, but it should be run every time update.php is run, basically...
51        $updater->addPostDatabaseUpdateMaintenance( UpdateKeysToLatestVersion::class );
52    }
53}