From ef7219e411f0aa95b14c3157c4efb326524632d3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 3 Jan 2008 12:36:13 -0600 Subject: [PATCH] DB rev 041: disallow NULL in some item status columns notforloan, damaged, itemlost, wthdrawn Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- installer/data/mysql/updatedatabase.pl | 19 ++++++++++++++++++- kohaversion.pl | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a994352c78..77dfe6ef96 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -821,6 +821,24 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { } +$DBversion = "3.00.00.041"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + # Strictly speaking it is not necessary to explicitly change + # NULL values to 0, because the ALTER TABLE statement will do that. + # However, setting them first avoids a warning. + $dbh->do("UPDATE items SET notforloan = 0 WHERE notforloan IS NULL"); + $dbh->do("UPDATE items SET damaged = 0 WHERE damaged IS NULL"); + $dbh->do("UPDATE items SET itemlost = 0 WHERE itemlost IS NULL"); + $dbh->do("UPDATE items SET wthdrawn = 0 WHERE wthdrawn IS NULL"); + $dbh->do("ALTER TABLE items + MODIFY notforloan tinyint(1) NOT NULL default 0, + MODIFY damaged tinyint(1) NOT NULL default 0, + MODIFY itemlost tinyint(1) NOT NULL default 0, + MODIFY wthdrawn tinyint(1) NOT NULL default 0"); + print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n"; + SetVersion ($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table @@ -884,4 +902,3 @@ sub SetVersion { } exit; -# Revision 1.172 2007/07/19 10:21:22 hdl diff --git a/kohaversion.pl b/kohaversion.pl index 2a7fdd8a74..ba2fda9132 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = "3.00.00.040"; + our $VERSION = "3.00.00.041"; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.39.5