Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SchemaHooks
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 onLoadExtensionSchemaUpdates
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Extension\CreditSource;
4
5use DatabaseUpdater;
6use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook;
7
8class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
9    /**
10     * LoadExtensionSchemaUpdates hook
11     *
12     * @param DatabaseUpdater $updater
13     */
14    public function onLoadExtensionSchemaUpdates( $updater ) {
15        $dbType = $updater->getDB()->getType();
16        $base = dirname( __DIR__, 1 ) . '/schema';
17        $updater->addExtensionTable( 'revsrc', "$base/$dbType/tables-generated.sql" );
18
19        if ( $dbType === 'postgres' ) {
20            // 1.37
21            $updater->addExtensionUpdate( [
22                'dropFkey',
23                'revsrc', 'revsrc_user'
24            ] );
25
26            // 1.39
27            $updater->addExtensionUpdate( [
28                'dropFkey',
29                'srcwork', 'srcwork_creator'
30            ] );
31            $updater->addExtensionUpdate( [
32                'dropFkey',
33                'srcwork', 'srcwork_site'
34            ] );
35            $updater->addExtensionUpdate( [
36                'dropFkey',
37                'revsrc', 'revsrc_revid'
38            ] );
39            $updater->addExtensionUpdate( [
40                'dropFkey',
41                'revsrc', 'revsrc_srcworkid'
42            ] );
43            $updater->addExtensionUpdate(
44                [ 'dropDefault', 'revsrc', 'revsrc_comment' ]
45            );
46        }
47
48        // 1.40
49        $updater->dropExtensionIndex(
50            'revsrc',
51            'revsrc_rs_unique',
52            "$base/$dbType/patch-revsrc-unique-to-pk.sql"
53        );
54        $updater->dropExtensionTable( 'swauthor' );
55        $updater->dropExtensionTable( 'swauthor_links' );
56        $updater->dropExtensionTable( 'swsource_links' );
57    }
58}