Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
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 / 9
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 onLoadExtensionSchemaUpdates
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * GlobalUsage schema hooks for updating globalimagelinks table.
4 */
5
6namespace MediaWiki\Extension\GlobalUsage;
7
8use MediaWiki\Installer\DatabaseUpdater;
9use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook;
10
11class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
12    /**
13     * Hook to apply schema changes
14     *
15     * @param DatabaseUpdater $updater
16     */
17    public function onLoadExtensionSchemaUpdates( $updater ) {
18        $dir = dirname( __DIR__ ) . '/sql';
19
20        $type = $updater->getDB()->getType();
21        $updater->addExtensionTable( 'globalimagelinks', "$dir/$type/tables-generated.sql" );
22
23        if ( $type === 'mysql' || $type === 'sqlite' ) {
24            // 1.35
25            $updater->dropExtensionIndex(
26                'globalimagelinks',
27                'globalimagelinks_to_wiki_page',
28                "$dir/patch-globalimagelinks-pk.sql"
29            );
30        }
31    }
32
33}