mediawiki-extensions-Linter/linter.sql
Kunal Mehta 419610bcdb Enforce category/page/position uniqueness constraint in the database
Move location to two separate columns in the database: linter_start and
linter_end. This allows us to have the database enforce the uniqueness
of those fields, instead of just relying upon the PHP code to do so,
which could be bypassed since we have multiple servers and concurrent
processes.

Change-Id: I3e67ce1b7cb3c93866a388ec3248af4cff2a81e0
2016-11-30 18:55:19 -08:00

20 lines
752 B
SQL

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);
-- Query by category
CREATE INDEX /*i*/linter_cat ON /*_*/linter (linter_cat);
CREATE UNIQUE INDEX /*i*/linter_cat_page_position ON /*_*/linter (linter_cat, linter_page, linter_start, linter_end);