forked from GNUsocial/gnu-social
[DATABASE] Postgres doesn't understand '0000-00-00 00:00:00' for datetime, use '-infinity'
This commit is contained in:
parent
aaf38353ea
commit
0ccc359880
@ -82,13 +82,13 @@ class SchemaDefDriver extends StaticPHPDriver
|
|||||||
foreach ($schema['fields'] as $name => $opts) {
|
foreach ($schema['fields'] as $name => $opts) {
|
||||||
// TODO
|
// TODO
|
||||||
// Convert old to new types
|
// Convert old to new types
|
||||||
$type = // $name === 'date'
|
$type = $name === 'date'
|
||||||
// // Old date fields were stored as int, store as datetime/timestamp
|
// Old date fields were stored as int, store as datetime/timestamp
|
||||||
// ? 'datetime'
|
? 'datetime'
|
||||||
// // For ints, prepend the size (smallint)
|
// For ints, prepend the size (smallint)
|
||||||
// // The size field doesn't exist otherwise
|
// The size field doesn't exist otherwise
|
||||||
// :
|
:
|
||||||
self::types[($opts['size'] ?? '') . $opts['type']];
|
self::types[($opts['size'] ?? '') . $opts['type']];
|
||||||
|
|
||||||
$unique = null;
|
$unique = null;
|
||||||
foreach ($schema['unique keys'] ?? [] as $key => $uniq_arr) {
|
foreach ($schema['unique keys'] ?? [] as $key => $uniq_arr) {
|
||||||
@ -98,6 +98,9 @@ class SchemaDefDriver extends StaticPHPDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$default = (($opts['default'] ?? null) === '0000-00-00 00:00:00' && $_ENV['DBMS'] === 'postgres')
|
||||||
|
? '-infinity' : $opts['default'] ?? null;
|
||||||
|
|
||||||
$field = [
|
$field = [
|
||||||
// boolean, optional
|
// boolean, optional
|
||||||
'id' => in_array($name, $schema['primary key']),
|
'id' => in_array($name, $schema['primary key']),
|
||||||
@ -119,7 +122,7 @@ class SchemaDefDriver extends StaticPHPDriver
|
|||||||
'scale' => $opts['scale'] ?? null,
|
'scale' => $opts['scale'] ?? null,
|
||||||
'options' => [
|
'options' => [
|
||||||
'comment' => $opts['description'] ?? null,
|
'comment' => $opts['description'] ?? null,
|
||||||
'default' => $opts['default'] ?? null,
|
'default' => $default,
|
||||||
'unsigned' => $opts['unsigned'] ?? null,
|
'unsigned' => $opts['unsigned'] ?? null,
|
||||||
// bool, optional
|
// bool, optional
|
||||||
'fixed' => $opts['type'] === 'char',
|
'fixed' => $opts['type'] === 'char',
|
||||||
|
Loading…
Reference in New Issue
Block a user