Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
SchemaHooks | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
onLoadExtensionSchemaUpdates | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
6 | |||
onUnitTestsAfterDatabaseSetup | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments; |
4 | |
5 | use MediaWiki\Config\ConfigException; |
6 | use MediaWiki\Hook\UnitTestsAfterDatabaseSetupHook; |
7 | use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; |
8 | |
9 | /** |
10 | * LoadExtensionSchemaUpdates hook handler. |
11 | * This hook handler must not have any service dependencies. |
12 | */ |
13 | class SchemaHooks implements LoadExtensionSchemaUpdatesHook, UnitTestsAfterDatabaseSetupHook { |
14 | |
15 | /** @inheritDoc */ |
16 | public function onLoadExtensionSchemaUpdates( $updater ) { |
17 | global $wgGEDatabaseCluster; |
18 | if ( $wgGEDatabaseCluster ) { |
19 | throw new ConfigException( 'Cannot use automatic schema upgrades when not on the ' |
20 | . 'default cluster' ); |
21 | } |
22 | |
23 | $sqlDir = __DIR__ . '/../sql'; |
24 | $engine = $updater->getDB()->getType(); |
25 | $updater->addExtensionTable( 'growthexperiments_link_recommendations', |
26 | "$sqlDir/$engine/growthexperiments_link_recommendations.sql" ); |
27 | $updater->addExtensionTable( 'growthexperiments_link_submissions', |
28 | "$sqlDir/$engine/growthexperiments_link_submissions.sql" ); |
29 | $updater->addExtensionTable( 'growthexperiments_mentee_data', |
30 | "$sqlDir/$engine/growthexperiments_mentee_data.sql" ); |
31 | $updater->addExtensionTable( 'growthexperiments_mentor_mentee', |
32 | "$sqlDir/$engine/growthexperiments_mentor_mentee.sql" ); |
33 | $updater->addExtensionTable( 'growthexperiments_user_impact', |
34 | "$sqlDir/$engine/growthexperiments_user_impact.sql" ); |
35 | $updater->addExtensionField( 'growthexperiments_link_submissions', |
36 | 'gels_anchor_offset', |
37 | "$sqlDir/$engine/patch-add_gels_anchor.sql" ); |
38 | $updater->addExtensionField( 'growthexperiments_mentor_mentee', |
39 | 'gemm_mentee_is_active', |
40 | "$sqlDir/$engine/patch-add_gemm_mentee_is_active.sql" ); |
41 | } |
42 | |
43 | /** @inheritDoc */ |
44 | public function onUnitTestsAfterDatabaseSetup( $db, $prefix ) { |
45 | global $wgGEDatabaseCluster; |
46 | |
47 | if ( $wgGEDatabaseCluster ) { |
48 | throw new ConfigException( 'Cannot use database tests when not on the default cluster' ); |
49 | } |
50 | } |
51 | |
52 | } |