1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Update MySQL schema inspection code for deprecation of integer display widths

Summary:
Fixes T13536. See that task for discussion.

Older versions of MySQL (roughly, prior to 8.0.19) emit "int(10)" types. Newer versions emit "int" types. Accept these as equivalent.

Test Plan: Ran `bin/storage upgrade --force` against MySQL 8.0.11 and 8.0.20. Got clean adjustment lists on both versions.

Maniphest Tasks: T13536

Differential Revision: https://secure.phabricator.com/D21265
This commit is contained in:
epriestley 2020-05-18 11:59:26 -07:00
parent 7b0db3eb54
commit f86d822a37

View file

@ -68,6 +68,37 @@ final class PhabricatorConfigColumnSchema
return $this->characterSet; return $this->characterSet;
} }
public function hasSameColumnTypeAs(PhabricatorConfigColumnSchema $other) {
$u_type = $this->getColumnType();
$v_type = $other->getColumnType();
if ($u_type === $v_type) {
return true;
}
// See T13536. Display widths for integers were deprecated in MySQL 8.0.17
// and removed from some display contexts in or around 8.0.19. Older
// MySQL versions will report "int(10)"; newer versions will report "int".
// Accept these as equivalent.
static $map = array(
'int(10) unsigned' => 'int unsigned',
'int(10)' => 'int',
'bigint(20) unsigned' => 'bigint unsigned',
'bigint(20)' => 'bigint',
);
if (isset($map[$u_type])) {
$u_type = $map[$u_type];
}
if (isset($map[$v_type])) {
$v_type = $map[$v_type];
}
return ($u_type === $v_type);
}
public function getKeyByteLength($prefix = null) { public function getKeyByteLength($prefix = null) {
$type = $this->getColumnType(); $type = $this->getColumnType();
@ -138,7 +169,7 @@ final class PhabricatorConfigColumnSchema
$issues[] = self::ISSUE_COLLATION; $issues[] = self::ISSUE_COLLATION;
} }
if ($this->getColumnType() != $expect->getColumnType()) { if (!$this->hasSameColumnTypeAs($expect)) {
$issues[] = self::ISSUE_COLUMNTYPE; $issues[] = self::ISSUE_COLUMNTYPE;
} }