Bug 14570: Make it possible to add multiple guarantors to a record
[koha.git] / installer / data / mysql / kohastructure.sql
index f637d27..d28822c 100644 (file)
@@ -559,7 +559,6 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
   `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
   `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
   `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
-  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
   `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
   `sex` varchar(1) default NULL, -- patron/borrower's gender
@@ -1548,7 +1547,6 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name
   `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor
   `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor
-  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
   `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client
   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
   `sex` varchar(1) default NULL, -- patron/borrower's gender
@@ -1584,7 +1582,6 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   KEY `categorycode` (`categorycode`),
   KEY `branchcode` (`branchcode`),
   UNIQUE KEY `userid` (`userid`),
-  KEY `guarantorid` (`guarantorid`),
   KEY `surname_idx` (`surname` (191)),
   KEY `firstname_idx` (`firstname` (191)),
   KEY `othernames_idx` (`othernames` (191)),
@@ -3364,7 +3361,6 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` (
   `contactname` LONGTEXT,
   `contactfirstname` MEDIUMTEXT,
   `contacttitle` MEDIUMTEXT,
-  `guarantorid` int(11) DEFAULT NULL,
   `borrowernotes` LONGTEXT,
   `relationship` varchar(100) DEFAULT NULL,
   `sex` varchar(1) DEFAULT NULL,
@@ -4074,6 +4070,21 @@ CREATE TABLE IF NOT EXISTS club_fields (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
+-- Table structure for table 'guarantors_guarantees'
+--
+
+DROP TABLE IF EXISTS borrower_relationships;
+CREATE TABLE `borrower_relationships` (
+      id INT(11) NOT NULL AUTO_INCREMENT,
+      guarantor_id INT(11) NULL DEFAULT NULL,
+      guarantee_id INT(11) NOT NULL,
+      relationship VARCHAR(100) NOT NULL,
+      PRIMARY KEY (id),
+      CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
+      CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+--
 -- Table structure for table `illrequests`
 --