Bug 24640: Allow quotes.timestamp to be NULL

It is broken with strict mode enable, timestamp is created without
default value.

Note that the .sql installer file init the value with NOW(), which is
wrong.

DBD::mysql::st execute failed: Field 'timestamp' doesn't have a default
value [for Statement "INSERT INTO quotes (source, text) VALUES (?, ?);"
with ParamValues: 0="poeut", 1="pouet"] at
/kohadevbox/koha/tools/quotes/quotes_ajax.pl line 49.

Test plan:
Create a new quote of the day
=> Without this patch you will get an error

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-02-12 12:26:25 +01:00 committed by Martin Renvoize
parent 79dbd63369
commit 9446b894b8
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,7 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
$dbh->do( "ALTER TABLE quotes MODIFY timestamp datetime NULL" );
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 24640 - Allow quotes.timestamp to be NULL)\n";
}

View File

@ -3314,7 +3314,7 @@ CREATE TABLE `quotes` ( -- data for the quote of the day feature
`id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the quote
`source` MEDIUMTEXT DEFAULT NULL, -- source/credit for the quote
`text` LONGTEXT NOT NULL, -- text of the quote
`timestamp` datetime NOT NULL, -- date and time that the quote last appeared in the opac
`timestamp` datetime NULL, -- date and time that the quote last appeared in the opac
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;