diff --git a/lib/database/mysqlschema.php b/lib/database/mysqlschema.php index a35f474f6f..ae1a1ce57a 100644 --- a/lib/database/mysqlschema.php +++ b/lib/database/mysqlschema.php @@ -517,24 +517,31 @@ class MysqlSchema extends Schema $map = [ 'integer' => 'int', 'numeric' => 'decimal', + 'blob' => 'longblob', ]; $type = $column['type']; - if (isset($map[$type])) { + if (array_key_exists($type, $map)) { $type = $map[$type]; } - if (!empty($column['size'])) { - $size = $column['size']; - if ($type == 'int' && - in_array($size, ['tiny', 'small', 'medium', 'big'])) { - $type = $size . $type; - } elseif ($type == 'float' && $size == 'big') { - $type = 'double'; - } elseif (in_array($type, ['blob', 'text']) && - in_array($size, ['tiny', 'medium', 'long'])) { - $type = $size . $type; - } + $size = $column['size'] ?? null; + switch ($type) { + case 'int': + if (in_array($size, ['tiny', 'small', 'medium', 'big'])) { + $type = $size . $type; + } + break; + case 'float': + if ($size === 'big') { + $type = 'double'; + } + break; + case 'text': + if (in_array($size, ['tiny', 'medium', 'long'])) { + $type = $size . $type; + } + break; } return $type; diff --git a/lib/database/pgsqlschema.php b/lib/database/pgsqlschema.php index 56d4cfc4e8..ceb966b381 100644 --- a/lib/database/pgsqlschema.php +++ b/lib/database/pgsqlschema.php @@ -419,21 +419,24 @@ class PgsqlSchema extends Schema ]; $type = $column['type']; - if (isset($map[$type])) { + if (array_key_exists($type, $map)) { $type = $map[$type]; } $size = $column['size'] ?? null; - if ($type === 'int') { - if (in_array($size, ['tiny', 'small'])) { - $type = 'int2'; - } elseif ($size === 'big') { - $type = 'int8'; - } else { - $type = 'int4'; - } - } elseif ($type === 'float') { - $type = ($size !== 'big') ? 'float4' : 'float8'; + switch ($type) { + case 'int': + if (in_array($size, ['tiny', 'small'])) { + $type = 'int2'; + } elseif ($size === 'big') { + $type = 'int8'; + } else { + $type = 'int4'; + } + break; + case 'float': + $type = ($size !== 'big') ? 'float4' : 'float8'; + break; } return $type;