From a027202717adf27ec99c2f14cddf018970c19ac0 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 19 Aug 2022 12:42:21 -0300 Subject: [PATCH] Bug 23681: (QA follow-up) debarment_types => restriction_types The code moved from *debarments* to *restrictions* but the table didn't. This patch just renames things accordingly. Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_23681.pl | 35 +++++++++++-------- ...tions.yml => patron_restriction_types.yml} | 2 +- installer/data/mysql/kohastructure.sql | 17 ++++----- 3 files changed, 30 insertions(+), 24 deletions(-) rename installer/data/mysql/en/mandatory/{patron_restrictions.yml => patron_restriction_types.yml} (98%) diff --git a/installer/data/mysql/atomicupdate/bug_23681.pl b/installer/data/mysql/atomicupdate/bug_23681.pl index 422de181bc..c3e30cc05f 100755 --- a/installer/data/mysql/atomicupdate/bug_23681.pl +++ b/installer/data/mysql/atomicupdate/bug_23681.pl @@ -7,24 +7,28 @@ return { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - $dbh->do(q{ - CREATE TABLE IF NOT EXISTS debarment_types ( - code varchar(50) NOT NULL PRIMARY KEY, - display_text text NOT NULL, - is_system tinyint(1) NOT NULL DEFAULT 0, - is_default tinyint(1) NOT NULL DEFAULT 0 - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - }); - say $out "Added debarment_types table"; + unless ( TableExists('restriction_types') ) { + $dbh->do(q{ + CREATE TABLE `restriction_types` ( + `code` varchar(50) NOT NULL, + `display_text` text NOT NULL, + `is_system` tinyint(1) NOT NULL DEFAULT 0, + `is_default` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`code`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + + say $out "Added restriction_types table"; + } $dbh->do(q{ - INSERT IGNORE INTO debarment_types (code, display_text, is_system, is_default) VALUES - ('MANUAL', 'Manual', 0, 1), - ('OVERDUES', 'Overdues', 1, 0), + INSERT IGNORE INTO restriction_types (code, display_text, is_system, is_default) VALUES + ('MANUAL', 'Manual', 0, 1), + ('OVERDUES', 'Overdues', 1, 0), ('SUSPENSION', 'Suspension', 1, 0), - ('DISCHARGE', 'Discharge', 1, 0); + ('DISCHARGE', 'Discharge', 1, 0); }); - say $out "Added system debarment_types"; + say $out "Added system restriction_types"; unless ( foreign_key_exists('borrower_debarments', 'borrower_debarments_ibfk_2') ) { $dbh->do(q{ @@ -33,8 +37,9 @@ return { }); $dbh->do(q{ ALTER TABLE borrower_debarments - ADD CONSTRAINT borrower_debarments_ibfk_2 FOREIGN KEY (type) REFERENCES debarment_types(code) ON DELETE NO ACTION ON UPDATE CASCADE; + ADD CONSTRAINT `borrower_debarments_ibfk_2` FOREIGN KEY (`type`) REFERENCES `restriction_types` (`code`) ON DELETE NO ACTION ON UPDATE CASCADE; }); + say $out "Added borrower_debarments relation"; } diff --git a/installer/data/mysql/en/mandatory/patron_restrictions.yml b/installer/data/mysql/en/mandatory/patron_restriction_types.yml similarity index 98% rename from installer/data/mysql/en/mandatory/patron_restrictions.yml rename to installer/data/mysql/en/mandatory/patron_restriction_types.yml index 634803469c..5299692324 100644 --- a/installer/data/mysql/en/mandatory/patron_restrictions.yml +++ b/installer/data/mysql/en/mandatory/patron_restriction_types.yml @@ -21,7 +21,7 @@ description: - "Default Koha system patron restriction types" tables: - - debarment_types: + - restriction_types: translatable: [] multiline: [] rows: diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b19d86bb79..affa80e9c2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1187,7 +1187,7 @@ CREATE TABLE `borrower_debarments` ( `borrower_debarment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the restriction', `borrowernumber` int(11) NOT NULL COMMENT 'foreign key for borrowers.borrowernumber for patron who is restricted', `expiration` date DEFAULT NULL COMMENT 'expiration date of the restriction', - `type` varchar(50) NOT NULL COMMENT 'type of restriction, FK to debarment_types.code', + `type` varchar(50) NOT NULL COMMENT 'type of restriction, FK to restriction_types.code', `comment` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'comments about the restriction', `manager_id` int(11) DEFAULT NULL COMMENT 'foreign key for borrowers.borrowernumber for the librarian managing the restriction', `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date the restriction was added', @@ -1195,7 +1195,7 @@ CREATE TABLE `borrower_debarments` ( PRIMARY KEY (`borrower_debarment_id`), KEY `borrowernumber` (`borrowernumber`), CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `borrower_debarments_ibfk_2` FOREIGN KEY (`type`) REFERENCES `debarment_types` (`code`) ON DELETE NO ACTION ON UPDATE CASCADE + CONSTRAINT `borrower_debarments_ibfk_2` FOREIGN KEY (`type`) REFERENCES `restriction_types` (`code`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2081,12 +2081,13 @@ CREATE TABLE `collections_tracking` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `debarment_types`; -CREATE TABLE debarment_types ( - code varchar(50) NOT NULL PRIMARY KEY, - display_text text NOT NULL, - is_system tinyint(1) NOT NULL DEFAULT 0, - is_default tinyint(1) NOT NULL DEFAULT 0 +DROP TABLE IF EXISTS `restriction_types`; +CREATE TABLE `restriction_types` ( + `code` varchar(50) NOT NULL, + `display_text` text NOT NULL, + `is_system` tinyint(1) NOT NULL DEFAULT 0, + `is_default` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.39.5