Fix linter table linter_params definition to not be nullable

* update all schema files to correct linter_params being set nullable by accident in
   2020 during abstract definition update

 * include hook to provide 3rd party support, use $updater->modifyExtensionField(

Bug: T327806
Change-Id: I7fea08280cf2fa7956e5b300dc3365dc3561ca52
This commit is contained in:
sbailey 2023-01-25 11:13:41 -08:00
parent 74730c5943
commit abbcc17511
9 changed files with 228 additions and 4 deletions

View file

@ -65,6 +65,9 @@ class Hooks implements
$updater->addExtensionField( 'linter', 'linter_template',
dirname( __DIR__ ) . '/sql/patch-linter-template-tag-fields.sql'
);
$updater->modifyExtensionField( 'linter', 'linter_params',
dirname( __DIR__ ) . '/sql/patch-linter-fix-params-null-definition.sql'
);
} elseif ( $dbType === 'sqlite' ) {
$updater->addExtensionTable( 'linter',
dirname( __DIR__ ) . '/sql/sqlite/tables-generated.sql'
@ -75,6 +78,9 @@ class Hooks implements
$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'
@ -85,6 +91,9 @@ class Hooks implements
$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'
);
}
}

View file

@ -0,0 +1,185 @@
{
"comment": "Fix linter table linter_params definition to not be nullable (T327806)",
"before": {
"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_namespace",
"comment": "page namespace",
"type": "integer",
"options": { "notnull": false, "unsigned": false }
},
{
"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 }
},
{
"name": "linter_template",
"comment": "name of a template if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 255, "default": "" }
},
{
"name": "linter_tag",
"comment": "name of tag if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 32, "default": "" }
}
],
"indexes": [
{
"name": "linter_page",
"comment": "Query by page",
"columns": [ "linter_page" ],
"unique": false
},
{
"name": "linter_cat_namespace",
"comment": "Query by category and namespace",
"columns": [ "linter_cat", "linter_namespace" ],
"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
},
{
"name": "linter_cat_template",
"comment": "Query by template",
"columns": [ "linter_cat", "linter_template" ],
"unique": false
},
{
"name": "linter_cat_tag",
"comment": "Query by tag",
"columns": [ "linter_cat", "linter_tag" ],
"unique": false
}
],
"pk": [ "linter_id" ]
},
"after": {
"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_namespace",
"comment": "page namespace",
"type": "integer",
"options": { "notnull": false, "unsigned": false }
},
{
"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": true }
},
{
"name": "linter_template",
"comment": "name of a template if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 255, "default": "" }
},
{
"name": "linter_tag",
"comment": "name of tag if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 32, "default": "" }
}
],
"indexes": [
{
"name": "linter_page",
"comment": "Query by page",
"columns": [ "linter_page" ],
"unique": false
},
{
"name": "linter_cat_namespace",
"comment": "Query by category and namespace",
"columns": [ "linter_cat", "linter_namespace" ],
"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
},
{
"name": "linter_cat_template",
"comment": "Query by template",
"columns": [ "linter_cat", "linter_template" ],
"unique": false
},
{
"name": "linter_cat_tag",
"comment": "Query by tag",
"columns": [ "linter_cat", "linter_tag" ],
"unique": false
}
],
"pk": [ "linter_id" ]
}
}

View file

@ -0,0 +1,6 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE /*_*/linter
CHANGE linter_params linter_params BLOB NOT NULL;

View file

@ -0,0 +1,6 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE linter ALTER linter_params
SET NOT NULL;

View file

@ -9,7 +9,7 @@ CREATE TABLE linter (
linter_cat INT NOT NULL,
linter_start INT NOT NULL,
linter_end INT NOT NULL,
linter_params TEXT DEFAULT NULL,
linter_params TEXT NOT NULL,
linter_template TEXT DEFAULT '' NOT NULL,
linter_tag TEXT DEFAULT '' NOT NULL,
PRIMARY KEY(linter_id)

View file

@ -0,0 +1,18 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__linter AS
SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag
FROM /*_*/linter;
DROP TABLE /*_*/linter;
CREATE TABLE /*_*/linter ( linter_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, linter_page INTEGER UNSIGNED NOT NULL, linter_namespace INTEGER DEFAULT NULL, linter_cat INTEGER UNSIGNED NOT NULL, linter_start INTEGER UNSIGNED NOT NULL, linter_end INTEGER UNSIGNED NOT NULL, linter_params BLOB NOT NULL, linter_template BLOB DEFAULT '' NOT NULL, linter_tag BLOB DEFAULT '' NOT NULL );
INSERT INTO /*_*/linter ( linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag )
SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag
FROM /*_*/__temp__linter;
DROP TABLE /*_*/__temp__linter;
CREATE INDEX linter_page ON /*_*/linter (linter_page);
CREATE INDEX linter_cat_namespace ON /*_*/linter (linter_cat, linter_namespace);
CREATE UNIQUE INDEX linter_cat_page_position ON /*_*/linter ( linter_cat, linter_page, linter_start, linter_end );
CREATE INDEX linter_cat_template ON /*_*/linter (linter_cat, linter_template);
CREATE INDEX linter_cat_tag ON /*_*/linter (linter_cat, linter_tag);

View file

@ -9,7 +9,7 @@ CREATE TABLE /*_*/linter (
linter_cat INTEGER UNSIGNED NOT NULL,
linter_start INTEGER UNSIGNED NOT NULL,
linter_end INTEGER UNSIGNED NOT NULL,
linter_params BLOB DEFAULT NULL, linter_template BLOB DEFAULT '' NOT NULL,
linter_params BLOB NOT NULL, linter_template BLOB DEFAULT '' NOT NULL,
linter_tag BLOB DEFAULT '' NOT NULL
);

View file

@ -9,7 +9,7 @@ CREATE TABLE /*_*/linter (
linter_cat INT UNSIGNED NOT NULL,
linter_start INT UNSIGNED NOT NULL,
linter_end INT UNSIGNED NOT NULL,
linter_params BLOB DEFAULT NULL,
linter_params BLOB NOT NULL,
linter_template VARBINARY(255) DEFAULT '' NOT NULL,
linter_tag VARBINARY(32) DEFAULT '' NOT NULL,
INDEX linter_page (linter_page),

View file

@ -41,7 +41,7 @@
"name": "linter_params",
"comment": "extra parameters about the error, JSON encoded",
"type": "blob",
"options": { "length": 65530, "notnull": false }
"options": { "length": 65530, "notnull": true }
},
{
"name": "linter_template",