forked from GNUsocial/gnu-social
[DATABASE][MariaDB] Always use LONGBLOB for "blob"
"blob" is practically used with the expectation of unlimited length, which is true with PostgreSQL's bytea, but not with MariaDB's BLOB, which is limited to 64KiB. So instead use LONGBLOB, which has a maximum of 4GiB, effectively unlimited.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user