From c10d8e5344f104341cba41d7eccd7f24d367e28e Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Thu, 4 Jul 2019 01:30:17 -0300 Subject: [PATCH] Bug 15497: Add itemtypes_branches table and atomic update Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_15497.perl | 17 +++++++++++++++++ installer/data/mysql/kohastructure.sql | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_15497.perl diff --git a/installer/data/mysql/atomicupdate/bug_15497.perl b/installer/data/mysql/atomicupdate/bug_15497.perl new file mode 100644 index 0000000000..cc187cd7cd --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15497.perl @@ -0,0 +1,17 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + if( !TableExists( 'itemtypes_branches' ) ) { + $dbh->do( " + CREATE TABLE itemtypes_branches( -- association table between authorised_values and branches + itemtype VARCHAR(10) NOT NULL, + branchcode VARCHAR(10) NOT NULL, + FOREIGN KEY (itemtype) REFERENCES itemtypes(itemtype) ON DELETE CASCADE, + FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + "); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 15497 - Add itemtypes_branches table)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index f6da9ee1d3..94cac768ca 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4287,6 +4287,18 @@ shortcut_keys varchar(80) NOT NULL, PRIMARY KEY (shortcut_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table itemtypes_branches +-- + +DROP TABLE IF EXISTS itemtypes_branches; +CREATE TABLE itemtypes_branches( -- association table between authorised_values and branches + itemtype VARCHAR(10) NOT NULL, + branchcode VARCHAR(10) NOT NULL, + FOREIGN KEY (itemtype) REFERENCES itemtypes(itemtype) ON DELETE CASCADE, + FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -- 2.23.0