Bug 32030: Add document to license - DB
authorPedro Amorim <pjamorim91@gmail.com>
Wed, 19 Oct 2022 11:29:43 +0000 (11:29 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 8 Nov 2022 12:44:30 +0000 (09:44 -0300)
Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/erm.pl
installer/data/mysql/kohastructure.sql

index 7b781d1..108bbf0 100755 (executable)
@@ -168,11 +168,12 @@ return {
             });
         }
 
-        unless ( TableExists('erm_agreement_documents') ) {
+        unless ( TableExists('erm_documents') ) {
             $dbh->do(q{
-                CREATE TABLE `erm_agreement_documents` (
+                CREATE TABLE `erm_documents` (
                     `document_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
-                    `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement',
+                    `agreement_id` INT(11) NULL COMMENT 'link to the agreement',
+                    `license_id` INT(11) NULL COMMENT 'link to the agreement',
                     `file_name` varchar(255) DEFAULT NULL COMMENT 'name of the file',
                     `file_type` varchar(255) DEFAULT NULL COMMENT 'type of the file',
                     `file_description` varchar(255) DEFAULT NULL COMMENT 'description of the file',
@@ -181,7 +182,8 @@ return {
                     `physical_location` VARCHAR(255) DEFAULT NULL COMMENT 'physical location of the document',
                     `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the document',
                     `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship',
-                    CONSTRAINT `erm_agreement_documents_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+                    CONSTRAINT `erm_documents_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+                    CONSTRAINT `erm_documents_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
                     PRIMARY KEY(`document_id`)
                 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
             });
index 5d78453..259d029 100644 (file)
@@ -2876,13 +2876,14 @@ CREATE TABLE `erm_agreement_relationships` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
--- Table structure for table `erm_agreement_documents`
+-- Table structure for table `erm_documents`
 --
 
-DROP TABLE IF EXISTS `erm_agreement_documents`;
-CREATE TABLE `erm_agreement_documents` (
+DROP TABLE IF EXISTS `erm_documents`;
+CREATE TABLE `erm_documents` (
     `document_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
-    `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement',
+    `agreement_id` INT(11) NULL COMMENT 'link to the agreement',
+    `license_id` INT(11) NULL COMMENT 'link to the license',
     `file_name` varchar(255) DEFAULT NULL COMMENT 'name of the file',
     `file_type` varchar(255) DEFAULT NULL COMMENT 'type of the file',
     `file_description` varchar(255) DEFAULT NULL COMMENT 'description of the file',
@@ -2891,7 +2892,8 @@ CREATE TABLE `erm_agreement_documents` (
     `physical_location` VARCHAR(255) DEFAULT NULL COMMENT 'physical location of the document',
     `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the document',
     `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship',
-    CONSTRAINT `erm_agreement_documents_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+    CONSTRAINT `erm_documents_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+    CONSTRAINT `erm_documents_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
     PRIMARY KEY(`document_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;