Making numerous fields unsigned to match their target referenced column

Bug: T157227
Change-Id: Ic11822d6c893103adcc99a3e188a592f13c968b8
This commit is contained in:
Reedy 2017-04-26 17:08:51 +01:00
parent 1d7a1bf8bd
commit f4022fe876
11 changed files with 52 additions and 26 deletions

View file

@ -209,6 +209,9 @@ changes to languages because of Phabricator reports.
(formerly it was needed by PostgreSQL and Oracle), and is now deprecated.
* (T146591) The lc_lang_key index on the l10n_cache table has been changed into a
PRIMARY KEY.
* (T157227) bot_password.bp_user, change_tag.ct_log_id, change_tag.ct_rev_id,
page_restrictions.pr_user, tag_summary.ts_log_id, tag_summary.ts_rev_id and
user_properties.up_user have all been made unsigned on MySQL.
== Compatibility ==
MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for

View file

@ -266,7 +266,6 @@ class MysqlUpdater extends DatabaseUpdater {
'patch-fa_major_mime-chemical.sql' ],
// 1.25
[ 'doUserNewTalkUseridUnsigned' ],
// note this patch covers other _comment and _description fields too
[ 'modifyField', 'recentchanges', 'rc_comment', 'patch-editsummary-length.sql' ],
@ -329,6 +328,7 @@ class MysqlUpdater extends DatabaseUpdater {
[ 'migrateComments' ],
[ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
'patch-l10n_cache-primary-key.sql' ],
[ 'doUnsignedSyncronisation' ],
];
}
@ -1123,26 +1123,42 @@ class MysqlUpdater extends DatabaseUpdater {
);
}
protected function doUserNewTalkUseridUnsigned() {
if ( !$this->doTable( 'user_newtalk' ) ) {
return true;
protected function doUnsignedSyncronisation() {
$sync = [
[ 'table' => 'bot_passwords', 'field' => 'bp_user' ],
[ 'table' => 'change_tag', 'field' => 'ct_log_id' ],
[ 'table' => 'change_tag', 'field' => 'ct_rev_id' ],
[ 'table' => 'page_restrictions', 'field' => 'pr_user' ],
[ 'table' => 'tag_summary', 'field' => 'ts_log_id' ],
[ 'table' => 'tag_summary', 'field' => 'ts_rev_id' ],
[ 'table' => 'user_newtalk', 'field' => 'user_id' ],
[ 'table' => 'user_properties', 'field' => 'up_user' ],
];
foreach ( $sync as $s ) {
if ( !$this->doTable( $s['table'] ) ) {
continue;
}
$info = $this->db->fieldInfo( $s['table'], $s['field'] );
if ( $info === false ) {
continue;
}
$fullName = "{$s['table']}.{$s['field']}";
if ( $info->isUnsigned() ) {
$this->output( "...$fullName is already unsigned int.\n" );
continue;
}
$this->applyPatch(
"patch-{$s['table']}-{$s['field']}-unsigned.sql",
false,
"Making $fullName into an unsigned int"
);
}
$info = $this->db->fieldInfo( 'user_newtalk', 'user_id' );
if ( $info === false ) {
return true;
}
if ( $info->isUnsigned() ) {
$this->output( "...user_id is already unsigned int.\n" );
return true;
}
return $this->applyPatch(
'patch-user-newtalk-userid-unsigned.sql',
false,
'Making user_id unsigned int'
);
return true;
}
protected function doRevisionPageRevIndexNonUnique() {

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/bot_passwords MODIFY bp_user int unsigned NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/change_tag MODIFY ct_log_id int unsigned NULL;

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/change_tag MODIFY ct_rev_id int unsigned NULL;

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/page_restrictions MODIFY pr_user int unsigned NULL;

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/tag_summary MODIFY ts_log_id int unsigned NULL;

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/tag_summary MODIFY ts_rev_id int unsigned NULL;

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/user_properties MODIFY up_user int unsigned NOT NULL;

View file

@ -213,7 +213,7 @@ CREATE INDEX /*i*/un_user_ip ON /*_*/user_newtalk (user_ip);
--
CREATE TABLE /*_*/user_properties (
-- Foreign key to user.user_id
up_user int NOT NULL,
up_user int unsigned NOT NULL,
-- Name of the option being saved. This is indexed for bulk lookup.
up_property varbinary(255) NOT NULL,
@ -231,7 +231,7 @@ CREATE INDEX /*i*/user_properties_property ON /*_*/user_properties (up_property)
--
CREATE TABLE /*_*/bot_passwords (
-- User ID obtained from CentralIdLookup.
bp_user int NOT NULL,
bp_user int unsigned NOT NULL,
-- Application identifier
bp_app_id varbinary(32) NOT NULL,
@ -1640,7 +1640,7 @@ CREATE TABLE /*_*/page_restrictions (
-- Whether or not to cascade the protection down to pages transcluded.
pr_cascade tinyint NOT NULL,
-- Field for future support of per-user restriction.
pr_user int NULL,
pr_user int unsigned NULL,
-- Field for time-limited protection.
pr_expiry varbinary(14) NULL
) /*$wgDBTableOptions*/;
@ -1692,9 +1692,9 @@ CREATE TABLE /*_*/change_tag (
-- RCID for the change
ct_rc_id int NULL,
-- LOGID for the change
ct_log_id int NULL,
ct_log_id int unsigned NULL,
-- REVID for the change
ct_rev_id int NULL,
ct_rev_id int unsigned NULL,
-- Tag applied
ct_tag varchar(255) NOT NULL,
-- Parameters for the tag, presently unused
@ -1715,9 +1715,9 @@ CREATE TABLE /*_*/tag_summary (
-- RCID for the change
ts_rc_id int NULL,
-- LOGID for the change
ts_log_id int NULL,
ts_log_id int unsigned NULL,
-- REVID for the change
ts_rev_id int NULL,
ts_rev_id int unsigned NULL,
-- Comma-separated list of tags
ts_tags blob NOT NULL
) /*$wgDBTableOptions*/;