mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-11 16:59:40 +00:00
Convert Linter to abstract schema
Bug: T259374 Change-Id: Ida866d45bc3daca6ed763df2b8c38d2b27c809aa
This commit is contained in:
parent
eba6670a58
commit
3387c848d0
|
@ -36,8 +36,20 @@ class Hooks {
|
|||
* @param DatabaseUpdater $updater
|
||||
*/
|
||||
public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) {
|
||||
$dir = dirname( __DIR__ ) . '/sql';
|
||||
$updater->addExtensionTable( 'linter', "$dir/linter.sql" );
|
||||
$dbType = $updater->getDB()->getType();
|
||||
if ( $dbType === 'mysql' ) {
|
||||
$updater->addExtensionTable( 'linter',
|
||||
dirname( __DIR__ ) . '/sql/tables-generated.sql'
|
||||
);
|
||||
} elseif ( $dbType === 'sqlite' ) {
|
||||
$updater->addExtensionTable( 'linter',
|
||||
dirname( __DIR__ ) . '/sql/sqlite/tables-generated.sql'
|
||||
);
|
||||
} elseif ( $dbType === 'postgres' ) {
|
||||
$updater->addExtensionTable( 'linter',
|
||||
dirname( __DIR__ ) . '/sql/postgres/tables-generated.sql'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
CREATE TABLE /*_*/linter (
|
||||
-- primary key
|
||||
linter_id int UNSIGNED PRIMARY KEY not null AUTO_INCREMENT,
|
||||
-- page id
|
||||
linter_page int UNSIGNED not null,
|
||||
-- error category (see CategoryManager::$categoryIds)
|
||||
linter_cat int UNSIGNED not null,
|
||||
-- start and end positions of where the error is located
|
||||
linter_start int UNSIGNED not null,
|
||||
linter_end int UNSIGNED not null,
|
||||
-- extra parameters about the error, JSON encoded
|
||||
linter_params blob NOT NULL
|
||||
) /*$wgDBTableOptions*/;
|
||||
|
||||
-- Query by page
|
||||
CREATE INDEX /*i*/linter_page ON /*_*/linter (linter_page);
|
||||
-- Unique index for lint errors, also covers linter_cat for query by category
|
||||
CREATE UNIQUE INDEX /*i*/linter_cat_page_position ON /*_*/linter (linter_cat, linter_page, linter_start, linter_end);
|
20
sql/postgres/tables-generated.sql
Normal file
20
sql/postgres/tables-generated.sql
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- This file is automatically generated using maintenance/generateSchemaSql.php.
|
||||
-- Source: ./tables.json
|
||||
-- Do not modify this file directly.
|
||||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
|
||||
CREATE TABLE linter (
|
||||
linter_id SERIAL NOT NULL,
|
||||
linter_page INT NOT NULL,
|
||||
linter_cat INT NOT NULL,
|
||||
linter_start INT NOT NULL,
|
||||
linter_end INT NOT NULL,
|
||||
linter_params TEXT DEFAULT NULL,
|
||||
PRIMARY KEY(linter_id)
|
||||
);
|
||||
|
||||
CREATE INDEX linter_page ON linter (linter_page);
|
||||
|
||||
CREATE UNIQUE INDEX linter_cat_page_position ON linter (
|
||||
linter_cat, linter_page, linter_start,
|
||||
linter_end
|
||||
);
|
19
sql/sqlite/tables-generated.sql
Normal file
19
sql/sqlite/tables-generated.sql
Normal file
|
@ -0,0 +1,19 @@
|
|||
-- This file is automatically generated using maintenance/generateSchemaSql.php.
|
||||
-- Source: ./tables.json
|
||||
-- Do not modify this file directly.
|
||||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
|
||||
CREATE TABLE /*_*/linter (
|
||||
linter_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
linter_page INTEGER UNSIGNED NOT NULL,
|
||||
linter_cat INTEGER UNSIGNED NOT NULL,
|
||||
linter_start INTEGER UNSIGNED NOT NULL,
|
||||
linter_end INTEGER UNSIGNED NOT NULL,
|
||||
linter_params BLOB DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX linter_page ON /*_*/linter (linter_page);
|
||||
|
||||
CREATE UNIQUE INDEX linter_cat_page_position ON /*_*/linter (
|
||||
linter_cat, linter_page, linter_start,
|
||||
linter_end
|
||||
);
|
18
sql/tables-generated.sql
Normal file
18
sql/tables-generated.sql
Normal file
|
@ -0,0 +1,18 @@
|
|||
-- This file is automatically generated using maintenance/generateSchemaSql.php.
|
||||
-- Source: ./tables.json
|
||||
-- Do not modify this file directly.
|
||||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
|
||||
CREATE TABLE /*_*/linter (
|
||||
linter_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
linter_page INT UNSIGNED NOT NULL,
|
||||
linter_cat INT UNSIGNED NOT NULL,
|
||||
linter_start INT UNSIGNED NOT NULL,
|
||||
linter_end INT UNSIGNED NOT NULL,
|
||||
linter_params BLOB DEFAULT NULL,
|
||||
INDEX linter_page (linter_page),
|
||||
UNIQUE INDEX linter_cat_page_position (
|
||||
linter_cat, linter_page, linter_start,
|
||||
linter_end
|
||||
),
|
||||
PRIMARY KEY(linter_id)
|
||||
) /*$wgDBTableOptions*/;
|
57
sql/tables.json
Normal file
57
sql/tables.json
Normal file
|
@ -0,0 +1,57 @@
|
|||
[
|
||||
{
|
||||
"name": "linter",
|
||||
"columns": [
|
||||
{
|
||||
"name": "linter_id",
|
||||
"type": "integer",
|
||||
"options": { "notnull": true, "unsigned": true, "autoincrement": true }
|
||||
},
|
||||
{
|
||||
"name": "linter_page",
|
||||
"comment": "page id",
|
||||
"type": "integer",
|
||||
"options": { "notnull": true, "unsigned": true }
|
||||
},
|
||||
{
|
||||
"name": "linter_cat",
|
||||
"comment": "error category (see CategoryManager::$categoryIds)",
|
||||
"type": "integer",
|
||||
"options": { "notnull": true, "unsigned": true }
|
||||
},
|
||||
{
|
||||
"name": "linter_start",
|
||||
"comment": "end positions of where the error is located",
|
||||
"type": "integer",
|
||||
"options": { "notnull": true, "unsigned": true }
|
||||
},
|
||||
{
|
||||
"name": "linter_end",
|
||||
"comment": "end positions of where the error is located",
|
||||
"type": "integer",
|
||||
"options": { "notnull": true, "unsigned": true }
|
||||
},
|
||||
{
|
||||
"name": "linter_params",
|
||||
"comment": "extra parameters about the error, JSON encoded",
|
||||
"type": "blob",
|
||||
"options": { "length": 65530, "notnull": false }
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
{
|
||||
"name": "linter_page",
|
||||
"comment": "Query by page",
|
||||
"columns": [ "linter_page" ],
|
||||
"unique": false
|
||||
},
|
||||
{
|
||||
"name": "linter_cat_page_position",
|
||||
"comment": "Unique index for lint errors, also covers linter_cat for query by category",
|
||||
"columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ],
|
||||
"unique": true
|
||||
}
|
||||
],
|
||||
"pk": [ "linter_id" ]
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue