From 50f1db6c770df7bd70aebcbe8753443b02a6f8b2 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 24 Apr 2012 11:20:42 -0400 Subject: [PATCH] Bug 8002 [SIGNED-OFF][REVISED] Can't add patron attribute type in newer installation Correcting patron_attributes_types definition in kohastructure.sql to allow NULL entries for category_code, matching the definition specified in updatedatabase.pl. Adds an entry to updatedatabase.pl to correct existing installations with the incorrect table structure. After running the updated updatedatabase.pl the category_code column in borrower_attribute_types should show that it allows NULL entries. Adding a new patron attribute type with no patron category specified should work correctly. To test the update to kohastructure.sql: Back up your Koha database, drop it, and recreate it. Load the staff interface and go through the web installer. After recreating the database enable ExtendedPatronAttributes and try adding a new patron attribute type with no patron category specified. The operation should be successful. signed-off-by: Jonathan Druart a new update for installations affected. Signed-off-by: Paul Poulain --- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a2102931ff..488a4f0bd3 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -286,7 +286,7 @@ CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron field `staff_searchable` tinyint(1) NOT NULL default 0, -- defines if this field is searchable via the patron search in the staff client (1 for yes, 0 for no) `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens - `category_code` VARCHAR(1) NOT NULL DEFAULT '',-- defines a category for an attribute_type + `category_code` VARCHAR(1) NULL DEFAULT NULL,-- defines a category for an attribute_type `class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type PRIMARY KEY (`code`), KEY `auth_val_cat_idx` (`authorised_value_category`) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 84f0437cc6..dd3483fada 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5212,6 +5212,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.08.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE borrower_attribute_types CHANGE category_code category_code VARCHAR( 1 ) NULL DEFAULT NULL"); + print "Upgrade to $DBversion done. (Bug 8002: Update patron attribute types table to allow NULL category_code)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 2.20.1