Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber
[srvgit] / installer / data / mysql / kohastructure.sql
index f5e1862..024039f 100644 (file)
@@ -56,6 +56,7 @@ CREATE TABLE `auth_subfield_structure` (
   `linkid` tinyint(1) NOT NULL default 0,
   `kohafield` varchar(45) NULL default '',
   `frameworkcode` varchar(10) NOT NULL default '',
+  `defaultvalue` TEXT DEFAULT '',
   PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
   KEY `tab` (`authtypecode`,`tab`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -246,7 +247,7 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   `ethnicity` varchar(50) default NULL, -- unused in Koha
   `ethnotes` varchar(255) default NULL, -- unused in Koha
   `sex` varchar(1) default NULL, -- patron/borrower's gender
-  `password` varchar(30) default NULL, -- patron/borrower's encrypted password
+  `password` varchar(60) default NULL, -- patron/borrower's encrypted password
   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
   `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
@@ -478,11 +479,11 @@ CREATE TABLE collections_tracking (
 DROP TABLE IF EXISTS courses;
 CREATE TABLE `courses` (
   `course_id` int(11) NOT NULL AUTO_INCREMENT,
-  `department` varchar(20) DEFAULT NULL, -- Stores the authorised value DEPT
+  `department` varchar(80) DEFAULT NULL, -- Stores the authorised value DEPT
   `course_number` varchar(255) DEFAULT NULL, -- An arbitrary field meant to store the "course number" assigned to a course
   `section` varchar(255) DEFAULT NULL, -- Also arbitrary, but for the 'section' of a course.
   `course_name` varchar(255) DEFAULT NULL,
-  `term` varchar(20) DEFAULT NULL, -- Stores the authorised value TERM
+  `term` varchar(80) DEFAULT NULL, -- Stores the authorised value TERM
   `staff_note` mediumtext,
   `public_note` mediumtext,
   `students_count` varchar(20) DEFAULT NULL, -- Meant to be just an estimate of how many students will be taking this course/section
@@ -866,7 +867,7 @@ CREATE TABLE `deleteditems` (
   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
-  `wthdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
+  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
   `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
   `issues` smallint(6) default NULL, -- number of times this item has been checked out
@@ -921,11 +922,12 @@ CREATE TABLE `export_format` (
   `export_format_id` int(11) NOT NULL auto_increment,
   `profile` varchar(255) NOT NULL,
   `description` mediumtext NOT NULL,
-  `marcfields` mediumtext NOT NULL,
+  `content` mediumtext NOT NULL,
   `csv_separator` varchar(2) NOT NULL,
   `field_separator` varchar(2) NOT NULL,
   `subfield_separator` varchar(2) NOT NULL,
   `encoding` varchar(255) NOT NULL,
+  `type` varchar(255) DEFAULT 'marc',
   PRIMARY KEY  (`export_format_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
 
@@ -1130,7 +1132,7 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules
   `renewalperiod` int(4) default NULL, -- renewal period in the unit set in issuingrules.lengthunit
   `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
   `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
-  overduefinescap decimal default NULL, -- the maximum amount of an overdue fine
+  overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
   PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
   KEY `categorycode` (`categorycode`),
   KEY `itemtype` (`itemtype`)
@@ -1158,7 +1160,7 @@ CREATE TABLE `items` ( -- holdings/item information
   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
-  `wthdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
+  `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
   `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
   `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
@@ -1204,12 +1206,14 @@ CREATE TABLE `items` ( -- holdings/item information
 
 DROP TABLE IF EXISTS `itemtypes`;
 CREATE TABLE `itemtypes` ( -- defines the item types
-  `itemtype` varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
-  `description` mediumtext, -- a plain text explanation of the item type
-  `rentalcharge` double(16,4) default NULL, -- the amount charged when this item is checked out/issued
-  `notforloan` smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
-  `imageurl` varchar(200) default NULL, -- URL for the item type icon
-  `summary` text, -- information from the summary field, may include HTML
+  itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
+  description mediumtext, -- a plain text explanation of the item type
+  rentalcharge double(16,4) default NULL, -- the amount charged when this item is checked out/issued
+  notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
+  imageurl varchar(200) default NULL, -- URL for the item type icon
+  summary text, -- information from the summary field, may include HTML
+  checkinmsg VARCHAR(255), -- message that is displayed when an item with the given item type is checked in
+  checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message"
   PRIMARY KEY  (`itemtype`),
   UNIQUE KEY `itemtype` (`itemtype`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -1521,6 +1525,7 @@ CREATE TABLE `oai_sets_mappings` (
   `set_id` int(11) NOT NULL,
   `marcfield` char(3) NOT NULL,
   `marcsubfield` char(1) NOT NULL,
+  `operator` varchar(8) NOT NULL default 'equal',
   `marcvalue` varchar(80) NOT NULL,
   CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -1660,11 +1665,11 @@ CREATE TABLE `patroncards` (
 
 DROP TABLE IF EXISTS `patronimage`;
 CREATE TABLE `patronimage` ( -- information related to patron images
-  `cardnumber` varchar(16) NOT NULL, -- the cardnumber of the patron this image is attached to (borrowers.cardnumber)
+  `borrowernumber` int(11) NOT NULL, -- the borrowernumber of the patron this image is attached to (borrowers.borrowernumber)
   `mimetype` varchar(15) NOT NULL, -- the format of the image (png, jpg, etc)
   `imagefile` mediumblob NOT NULL, -- the image
-  PRIMARY KEY  (`cardnumber`),
-  CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
+  PRIMARY KEY  (`borrowernumber`),
+  CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 -- Table structure for table `pending_offline_operations`
@@ -2280,6 +2285,7 @@ CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets u
   `type` enum('zed','opensearch') NOT NULL default 'zed',
   `encoding` text default NULL, -- characters encoding provided by this target
   `description` text NOT NULL, -- unused in Koha
+  `recordtype` varchar(45) NOT NULL default 'biblio', -- server contains bibliographic or authority records
   PRIMARY KEY  (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -2523,14 +2529,14 @@ CREATE TABLE `message_transports` (
 --
 
 DROP TABLE IF EXISTS `borrower_files`;
-CREATE TABLE IF NOT EXISTS `borrower_files` (
-  `file_id` int(11) NOT NULL AUTO_INCREMENT,
-  `borrowernumber` int(11) NOT NULL,
-  `file_name` varchar(255) NOT NULL,
-  `file_type` varchar(255) NOT NULL,
-  `file_description` varchar(255) DEFAULT NULL,
-  `file_content` longblob NOT NULL,
-  `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+CREATE TABLE IF NOT EXISTS `borrower_files` ( -- files attached to the patron/borrower record
+  `file_id` int(11) NOT NULL AUTO_INCREMENT, -- unique key
+  `borrowernumber` int(11) NOT NULL, -- foreign key linking to the patron via the borrowernumber
+  `file_name` varchar(255) NOT NULL, -- file name
+  `file_type` varchar(255) NOT NULL, -- type of file
+  `file_description` varchar(255) DEFAULT NULL, -- description given to the file
+  `file_content` longblob NOT NULL, -- the file
+  `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date and time the file was added
   PRIMARY KEY (`file_id`),
   KEY `borrowernumber` (`borrowernumber`),
   CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
@@ -2958,6 +2964,21 @@ CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisiti
 
 
 --
+-- Table structure for table aqorders_transfers
+--
+
+DROP TABLE IF EXISTS aqorders_transfers;
+CREATE TABLE aqorders_transfers (
+  ordernumber_from int(11) NULL,
+  ordernumber_to int(11) NULL,
+  timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  UNIQUE KEY ordernumber_from (ordernumber_from),
+  UNIQUE KEY ordernumber_to (ordernumber_to),
+  CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
+  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
 -- Table structure for table aqinvoices
 --
 
@@ -3013,12 +3034,12 @@ CREATE TABLE transport_cost (
 
 DROP TABLE IF EXISTS `biblioimages`;
 
-CREATE TABLE `biblioimages` (
- `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
- `biblionumber` int(11) NOT NULL,
- `mimetype` varchar(15) NOT NULL,
- `imagefile` mediumblob NOT NULL,
- `thumbnail` mediumblob NOT NULL,
+CREATE TABLE `biblioimages` ( -- local cover images
+ `imagenumber` int(11) NOT NULL AUTO_INCREMENT, -- unique identifier for the image
+ `biblionumber` int(11) NOT NULL, -- foreign key from biblio table to link to biblionumber
+ `mimetype` varchar(15) NOT NULL, -- image type
+ `imagefile` mediumblob NOT NULL, -- image file contents
+ `thumbnail` mediumblob NOT NULL, -- thumbnail file contents
  PRIMARY KEY (`imagenumber`),
  CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -3059,11 +3080,11 @@ CREATE TABLE ratings ( -- information related to the star ratings in the OPAC
 --
 
 DROP TABLE IF EXISTS quotes;
-CREATE TABLE `quotes` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `source` text DEFAULT NULL,
-  `text` mediumtext NOT NULL,
-  `timestamp` datetime NOT NULL,
+CREATE TABLE `quotes` ( -- data for the quote of the day feature
+  `id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the quote
+  `source` text DEFAULT NULL, -- source/credit for the quote
+  `text` mediumtext NOT NULL, -- text of the quote
+  `timestamp` datetime NOT NULL, -- date and time that the quote last appeared in the opac
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;