From 3cc7d6ad3e4a9174546d8ac8465f77ed2f943dd9 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 ae3757605a..a22ec1c5bb 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4192,7 +4192,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