From 2324162caa5318e6b0bf7e94e646c289e39fbd4d Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Fri, 12 Oct 2018 14:30:59 +0100 Subject: [PATCH] Bug 20581: (follow-up) Modify DB updgrade As per https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c56 --- .../bug_20581-add_new_illrequests_status_alias_column.perl | 8 ++++++-- installer/data/mysql/en/optional/ill_auth_cat.sql | 1 - installer/data/mysql/en/optional/ill_auth_cat.txt | 1 - installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/mandatory/auth_val_cat.sql | 4 ++++ 5 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 installer/data/mysql/en/optional/ill_auth_cat.sql delete mode 100644 installer/data/mysql/en/optional/ill_auth_cat.txt diff --git a/installer/data/mysql/atomicupdate/bug_20581-add_new_illrequests_status_alias_column.perl b/installer/data/mysql/atomicupdate/bug_20581-add_new_illrequests_status_alias_column.perl index 64a4824e36..881d2cd13e 100644 --- a/installer/data/mysql/atomicupdate/bug_20581-add_new_illrequests_status_alias_column.perl +++ b/installer/data/mysql/atomicupdate/bug_20581-add_new_illrequests_status_alias_column.perl @@ -1,8 +1,12 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - $dbh->do( "ALTER TABLE illrequests ADD COLUMN status_alias integer DEFAULT NULL" ); - $dbh->do( "ALTER TABLE illrequests ADD CONSTRAINT illrequests_safk FOREIGN KEY (status_alias) REFERENCES authorised_values(id) ON DELETE SET NULL" ); + if ( !column_exists( 'illrequests', 'status_alias' ) ) { + $dbh->do( "ALTER TABLE illrequests ADD COLUMN status_alias integer DEFAULT NULL AFTER status" ); + } + if ( !foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) { + $dbh->do( "ALTER TABLE illrequests ADD CONSTRAINT illrequests_safk FOREIGN KEY (status_alias) REFERENCES authorised_values(id) ON UPDATE CASCADE ON DELETE SET NULL" ); + } $dbh->do( "INSERT IGNORE INTO authorised_value_categories SET category_name = 'ILLSTATUS'"); SetVersion( $DBversion ); diff --git a/installer/data/mysql/en/optional/ill_auth_cat.sql b/installer/data/mysql/en/optional/ill_auth_cat.sql deleted file mode 100644 index 96e44900be..0000000000 --- a/installer/data/mysql/en/optional/ill_auth_cat.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('ILLSTATUS'); diff --git a/installer/data/mysql/en/optional/ill_auth_cat.txt b/installer/data/mysql/en/optional/ill_auth_cat.txt deleted file mode 100644 index 934903a884..0000000000 --- a/installer/data/mysql/en/optional/ill_auth_cat.txt +++ /dev/null @@ -1 +0,0 @@ -Default ILL request status authorised value category name diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index d4d41d90f3..71c8ea90a1 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4174,7 +4174,7 @@ CREATE TABLE illrequests ( CONSTRAINT `illrequests_safk` FOREIGN KEY (`status_alias`) REFERENCES `authorised_values` (`id`) - ON DELETE SET NULL + ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- diff --git a/installer/data/mysql/mandatory/auth_val_cat.sql b/installer/data/mysql/mandatory/auth_val_cat.sql index 4ab8c0e04e..a0831af0c5 100644 --- a/installer/data/mysql/mandatory/auth_val_cat.sql +++ b/installer/data/mysql/mandatory/auth_val_cat.sql @@ -57,3 +57,7 @@ INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES -- For Housebound INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('HSBND_FREQ'); + +-- For Interlibrary loans +INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES + ('ILLSTATUS'); -- 2.11.0