Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SchemaHooks | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
onLoadExtensionSchemaUpdates | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | /** |
3 | * Schema hooks for extension. |
4 | * |
5 | * @file |
6 | * @license GPL-2.0-or-later |
7 | */ |
8 | |
9 | declare( strict_types = 1 ); |
10 | |
11 | namespace MediaWiki\Babel; |
12 | |
13 | use DatabaseUpdater; |
14 | use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; |
15 | |
16 | class SchemaHooks implements LoadExtensionSchemaUpdatesHook { |
17 | /** |
18 | * @param DatabaseUpdater $updater |
19 | */ |
20 | public function onLoadExtensionSchemaUpdates( $updater ): void { |
21 | $dir = dirname( __DIR__ ) . '/sql/'; |
22 | $dbType = $updater->getDB()->getType(); |
23 | |
24 | if ( $dbType === 'mysql' ) { |
25 | $updater->addExtensionTable( 'babel', |
26 | $dir . 'tables-generated.sql' |
27 | ); |
28 | $updater->modifyExtensionField( |
29 | 'babel', |
30 | 'babel_lang', |
31 | $dir . 'babel-babel_lang-length-type.sql' |
32 | ); |
33 | $updater->modifyExtensionField( |
34 | 'babel', |
35 | 'babel_level', |
36 | $dir . 'babel-babel_level-type.sql' |
37 | ); |
38 | } elseif ( $dbType === 'sqlite' ) { |
39 | $updater->addExtensionTable( 'babel', |
40 | $dir . 'sqlite/tables-generated.sql' |
41 | ); |
42 | |
43 | $updater->modifyExtensionField( |
44 | 'babel', |
45 | 'babel_lang', |
46 | $dir . 'sqlite/babel-babel_lang-length.sql' |
47 | ); |
48 | } elseif ( $dbType === 'postgres' ) { |
49 | $updater->addExtensionTable( 'babel', |
50 | $dir . 'postgres/tables-generated.sql' |
51 | ); |
52 | } |
53 | } |
54 | } |