bug 5217 incrementing db version number
[koha.git] / installer / data / mysql / kohastructure.sql
index e42cecd..9148970 100644 (file)
@@ -262,6 +262,7 @@ CREATE TABLE `borrowers` (
   KEY `categorycode` (`categorycode`),
   KEY `branchcode` (`branchcode`),
   KEY `userid` (`userid`),
+  KEY `guarantorid` (`guarantorid`),
   CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
   CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -1790,10 +1791,15 @@ CREATE TABLE `subscriptionhistory` (
 DROP TABLE IF EXISTS `subscriptionroutinglist`;
 CREATE TABLE `subscriptionroutinglist` (
   `routingid` int(11) NOT NULL auto_increment,
-  `borrowernumber` int(11) default NULL,
+  `borrowernumber` int(11) NOT NULL,
   `ranking` int(11) default NULL,
-  `subscriptionid` int(11) default NULL,
-  PRIMARY KEY  (`routingid`)
+  `subscriptionid` int(11) NOT NULL,
+  PRIMARY KEY  (`routingid`),
+  UNIQUE (`subscriptionid`, `borrowernumber`),
+  CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+    ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`)
+    ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --