Bug 15497: Add itemtypes_branches table and atomic update
authorAgustin Moyano <agustinmoyano@theke.io>
Thu, 4 Jul 2019 04:30:17 +0000 (01:30 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 12 Sep 2019 15:31:05 +0000 (16:31 +0100)
Sponsored-by: Northeast Kansas Library System
Sponsored-by: Southeast Kansas Library System
Sponsored-by: Central Kansas Library System
Signed-off-by: Jessica Zairo <jzairo@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

installer/data/mysql/atomicupdate/bug_15497.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_15497.perl b/installer/data/mysql/atomicupdate/bug_15497.perl
new file mode 100644 (file)
index 0000000..cc187cd
--- /dev/null
@@ -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";
+}
index f6da9ee..94cac76 100644 (file)
@@ -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 */;