From 300855af74225b5edd8ab50831211540274573ad Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 12 Feb 2020 12:26:25 +0100 Subject: [PATCH] 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 --- installer/data/mysql/atomicupdate/bug_24640.perl | 7 +++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_24640.perl diff --git a/installer/data/mysql/atomicupdate/bug_24640.perl b/installer/data/mysql/atomicupdate/bug_24640.perl new file mode 100644 index 0000000000..393c049343 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24640.perl @@ -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"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 0aa3a9b784..36ba23d6e9 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -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; -- 2.11.0