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
4a754553f7
commit
7dda377a79
@ -82,12 +82,12 @@ class SchemaDefDriver extends StaticPHPDriver
|
||||
foreach ($schema['fields'] as $name => $opts) {
|
||||
// TODO
|
||||
// Convert old to new types
|
||||
$type = // $name === 'date'
|
||||
// // Old date fields were stored as int, store as datetime/timestamp
|
||||
// ? 'datetime'
|
||||
// // For ints, prepend the size (smallint)
|
||||
// // The size field doesn't exist otherwise
|
||||
// :
|
||||
$type = $name === 'date'
|
||||
// Old date fields were stored as int, store as datetime/timestamp
|
||||
? 'datetime'
|
||||
// For ints, prepend the size (smallint)
|
||||
// The size field doesn't exist otherwise
|
||||
:
|
||||
self::types[($opts['size'] ?? '') . $opts['type']];
|
||||
|
||||
$unique = null;
|
||||
@ -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 = [
|
||||
// boolean, optional
|
||||
'id' => in_array($name, $schema['primary key']),
|
||||
@ -119,7 +122,7 @@ class SchemaDefDriver extends StaticPHPDriver
|
||||
'scale' => $opts['scale'] ?? null,
|
||||
'options' => [
|
||||
'comment' => $opts['description'] ?? null,
|
||||
'default' => $opts['default'] ?? null,
|
||||
'default' => $default,
|
||||
'unsigned' => $opts['unsigned'] ?? null,
|
||||
// bool, optional
|
||||
'fixed' => $opts['type'] === 'char',
|
||||
|
Loading…
Reference in New Issue
Block a user