Normalise length of language fields to varbinary(35)
Update length in patch-langlinks.sql and fix PK too Update length in patch-sites.sql and fix PK too Update length in patch-l10n_cache.sql and fix PK too Re-use patch-langlinks-ll_lang-20.sql and update Bug: T253276 Change-Id: I95bef3ef279cb59d54a3127c646a03826fa0da6b
This commit is contained in:
parent
3f2937810e
commit
141e0b0b35
8 changed files with 43 additions and 27 deletions
|
|
@ -189,7 +189,6 @@ class MysqlUpdater extends DatabaseUpdater {
|
|||
[ 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ],
|
||||
[ 'addIndexIfNoneExist',
|
||||
'archive', [ 'ar_revid', 'ar_revid_uniq' ], 'patch-archive_ar_revid.sql' ],
|
||||
[ 'doLangLinksLengthUpdate' ],
|
||||
|
||||
// 1.18
|
||||
[ 'doUserNewTalkTimestampNotNull' ],
|
||||
|
|
@ -425,6 +424,7 @@ class MysqlUpdater extends DatabaseUpdater {
|
|||
'patch-ipblocks-rename-ipb_address.sql' ],
|
||||
[ 'addField', 'revision', 'rev_actor', 'patch-revision-actor-comment-MCR.sql' ],
|
||||
[ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
|
||||
[ 'doLanguageLinksLengthSync' ],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -1170,19 +1170,28 @@ class MysqlUpdater extends DatabaseUpdater {
|
|||
);
|
||||
}
|
||||
|
||||
protected function doLangLinksLengthUpdate() {
|
||||
$langlinks = $this->db->tableName( 'langlinks' );
|
||||
$res = $this->db->query( "SHOW COLUMNS FROM $langlinks LIKE 'll_lang'" );
|
||||
$row = $this->db->fetchObject( $res );
|
||||
protected function doLanguageLinksLengthSync() {
|
||||
$sync = [
|
||||
[ 'table' => 'l10n_cache', 'field' => 'lc_lang' ],
|
||||
[ 'table' => 'langlinks', 'field' => 'll_lang' ],
|
||||
[ 'table' => 'sites', 'field' => 'site_language' ],
|
||||
];
|
||||
|
||||
if ( $row && $row->Type == "varbinary(10)" ) {
|
||||
$this->applyPatch(
|
||||
'patch-langlinks-ll_lang-20.sql',
|
||||
false,
|
||||
'Updating length of ll_lang in langlinks'
|
||||
);
|
||||
} else {
|
||||
$this->output( "...ll_lang is up-to-date.\n" );
|
||||
foreach ( $sync as $s ) {
|
||||
$table = $this->db->tableName( $s['table'] );
|
||||
$field = $s['field'];
|
||||
$res = $this->db->query( "SHOW COLUMNS FROM $table LIKE '$field'" );
|
||||
$row = $this->db->fetchObject( $res );
|
||||
|
||||
if ( $row && $row->Type !== "varbinary(35)" ) {
|
||||
$this->applyPatch(
|
||||
"patch-{$s['table']}-$field-35.sql",
|
||||
false,
|
||||
"Updating length of $field in $table"
|
||||
);
|
||||
} else {
|
||||
$this->output( "...$field is up-to-date.\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
-- Table for storing localisation data
|
||||
CREATE TABLE /*_*/l10n_cache (
|
||||
lc_lang varbinary(32) NOT NULL,
|
||||
lc_lang varbinary(35) NOT NULL,
|
||||
lc_key varchar(255) NOT NULL,
|
||||
lc_value mediumblob NOT NULL
|
||||
lc_value mediumblob NOT NULL,
|
||||
|
||||
PRIMARY KEY(lc_lang, lc_key)
|
||||
) /*$wgDBTableOptions*/;
|
||||
CREATE INDEX /*i*/lc_lang_key ON /*_*/l10n_cache (lc_lang, lc_key);
|
||||
|
|
|
|||
3
maintenance/archives/patch-l10ncache-lc_lang-35.sql
Normal file
3
maintenance/archives/patch-l10ncache-lc_lang-35.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE /*$wgDBprefix*/l10n_cache
|
||||
MODIFY `lc_lang`
|
||||
VARBINARY(35) NOT NULL;
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
ALTER TABLE /*$wgDBprefix*/langlinks
|
||||
MODIFY `ll_lang`
|
||||
VARBINARY(20) NOT NULL DEFAULT '';
|
||||
VARBINARY(35) NOT NULL DEFAULT '';
|
||||
|
|
@ -3,11 +3,11 @@ CREATE TABLE /*$wgDBprefix*/langlinks (
|
|||
ll_from int unsigned NOT NULL default '0',
|
||||
|
||||
-- Language code of the target
|
||||
ll_lang varbinary(20) NOT NULL default '',
|
||||
ll_lang varbinary(35) NOT NULL default '',
|
||||
|
||||
-- Title of the target, including namespace
|
||||
ll_title varchar(255) binary NOT NULL default '',
|
||||
|
||||
UNIQUE KEY (ll_from, ll_lang),
|
||||
PRIMARY KEY (ll_from, ll_lang),
|
||||
KEY (ll_lang, ll_title)
|
||||
) /*$wgDBTableOptions*/;
|
||||
|
|
|
|||
3
maintenance/archives/patch-sites-site_language-35.sql
Normal file
3
maintenance/archives/patch-sites-site_language-35.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE /*$wgDBprefix*/sites
|
||||
MODIFY `site_language`
|
||||
VARBINARY(35) NOT NULL
|
||||
|
|
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS /*_*/sites (
|
|||
site_source varbinary(32) NOT NULL,
|
||||
|
||||
-- Language code of the sites primary language.
|
||||
site_language varbinary(32) NOT NULL,
|
||||
site_language varbinary(35) NOT NULL,
|
||||
|
||||
-- Protocol of the site, ie 'http://', 'irc://', '//'
|
||||
-- This field is an index for lookups and is build from type specific data in site_data.
|
||||
|
|
@ -53,7 +53,6 @@ CREATE INDEX /*i*/sites_domain ON /*_*/sites (site_domain);
|
|||
CREATE INDEX /*i*/sites_forward ON /*_*/sites (site_forward);
|
||||
|
||||
|
||||
|
||||
-- Links local site identifiers to their corresponding site.
|
||||
CREATE TABLE IF NOT EXISTS /*_*/site_identifiers (
|
||||
-- Key on site.site_id
|
||||
|
|
@ -63,9 +62,10 @@ CREATE TABLE IF NOT EXISTS /*_*/site_identifiers (
|
|||
si_type varbinary(32) NOT NULL,
|
||||
|
||||
-- local key value, ie 'en' or 'wiktionary'
|
||||
si_key varbinary(32) NOT NULL
|
||||
si_key varbinary(32) NOT NULL,
|
||||
|
||||
PRIMARY KEY (si_type, si_key)
|
||||
) /*$wgDBTableOptions*/;
|
||||
|
||||
CREATE UNIQUE INDEX /*i*/site_ids_type ON /*_*/site_identifiers (si_type, si_key);
|
||||
CREATE INDEX /*i*/site_ids_site ON /*_*/site_identifiers (si_site);
|
||||
CREATE INDEX /*i*/site_ids_key ON /*_*/site_identifiers (si_key);
|
||||
CREATE INDEX /*i*/site_ids_key ON /*_*/site_identifiers (si_key);
|
||||
|
|
|
|||
|
|
@ -902,7 +902,7 @@ CREATE TABLE /*_*/langlinks (
|
|||
ll_from int unsigned NOT NULL default 0,
|
||||
|
||||
-- Language code of the target
|
||||
ll_lang varbinary(20) NOT NULL default '',
|
||||
ll_lang varbinary(35) NOT NULL default '',
|
||||
|
||||
-- Title of the target, including namespace
|
||||
ll_title varchar(255) binary NOT NULL default '',
|
||||
|
|
@ -1757,7 +1757,7 @@ CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct
|
|||
-- Table for storing localisation data
|
||||
CREATE TABLE /*_*/l10n_cache (
|
||||
-- Language code
|
||||
lc_lang varbinary(32) NOT NULL,
|
||||
lc_lang varbinary(35) NOT NULL,
|
||||
-- Cache key
|
||||
lc_key varchar(255) NOT NULL,
|
||||
-- Value
|
||||
|
|
@ -1796,7 +1796,7 @@ CREATE TABLE /*_*/sites (
|
|||
site_source varbinary(32) NOT NULL,
|
||||
|
||||
-- Language code of the sites primary language.
|
||||
site_language varbinary(32) NOT NULL,
|
||||
site_language varbinary(35) NOT NULL,
|
||||
|
||||
-- Protocol of the site, ie 'http://', 'irc://', '//'
|
||||
-- This field is an index for lookups and is build from type specific data in site_data.
|
||||
|
|
|
|||
Loading…
Reference in a new issue