Cleanup SchemaHooks and SQL files

* Move MySQL files into subfolder
* Simplify onLoadExtensionSchemaUpdates hook by using variable for dbType
* Document what MW version patches were added

Bug: T353922
Change-Id: I4b87481163121047619d173675747feef4d8ede1
This commit is contained in:
Reedy 2023-12-22 02:13:52 +00:00
parent 46e44bc694
commit 2276363a99
5 changed files with 16 additions and 40 deletions

View file

@ -29,45 +29,21 @@ class SchemaHooks implements LoadExtensionSchemaUpdatesHook {
*/ */
public function onLoadExtensionSchemaUpdates( $updater ) { public function onLoadExtensionSchemaUpdates( $updater ) {
$dbType = $updater->getDB()->getType(); $dbType = $updater->getDB()->getType();
if ( $dbType === 'mysql' ) { $dir = dirname( __DIR__ );
$updater->addExtensionTable( 'linter', $updater->addExtensionTable( 'linter',
dirname( __DIR__ ) . '/sql/tables-generated.sql' "{$dir}/sql/{$dbType}/tables-generated.sql"
); );
$updater->addExtensionField( 'linter', 'linter_namespace', // 1.38
dirname( __DIR__ ) . '/sql/patch-linter-add-namespace.sql' $updater->addExtensionField( 'linter', 'linter_namespace',
); "{$dir}/sql/{$dbType}/patch-linter-add-namespace.sql"
$updater->addExtensionField( 'linter', 'linter_template', );
dirname( __DIR__ ) . '/sql/patch-linter-template-tag-fields.sql' // 1.38
); $updater->addExtensionField( 'linter', 'linter_template',
$updater->modifyExtensionField( 'linter', 'linter_params', "{$dir}/sql/{$dbType}/patch-linter-template-tag-fields.sql"
dirname( __DIR__ ) . '/sql/patch-linter-fix-params-null-definition.sql' );
); // 1.40
} elseif ( $dbType === 'sqlite' ) { $updater->modifyExtensionField( 'linter', 'linter_params',
$updater->addExtensionTable( 'linter', "{$dir}/sql/{$dbType}/patch-linter-fix-params-null-definition.sql"
dirname( __DIR__ ) . '/sql/sqlite/tables-generated.sql' );
);
$updater->addExtensionField( 'linter', 'linter_namespace',
dirname( __DIR__ ) . '/sql/sqlite/patch-linter-add-namespace.sql'
);
$updater->addExtensionField( 'linter', 'linter_template',
dirname( __DIR__ ) . '/sql/sqlite/patch-linter-template-tag-fields.sql'
);
$updater->modifyExtensionField( 'linter', 'linter_params',
dirname( __DIR__ ) . '/sql/sqlite/patch-linter-fix-params-null-definition.sql'
);
} elseif ( $dbType === 'postgres' ) {
$updater->addExtensionTable( 'linter',
dirname( __DIR__ ) . '/sql/postgres/tables-generated.sql'
);
$updater->addExtensionField( 'linter', 'linter_namespace',
dirname( __DIR__ ) . '/sql/postgres/patch-linter-add-namespace.sql'
);
$updater->addExtensionField( 'linter', 'linter_template',
dirname( __DIR__ ) . '/sql/postgres/patch-linter-template-tag-fields.sql'
);
$updater->modifyExtensionField( 'linter', 'linter_params',
dirname( __DIR__ ) . '/sql/postgres/patch-linter-fix-params-null-definition.sql'
);
}
} }
} }