Bug 6716 - Document the systempreferences table
[koha_gimpoz] / installer / data / mysql / kohastructure.sql
index a75cb09..7d097fe 100644 (file)
 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
 --
--- Table structure for table `accountlines`
---
-
-DROP TABLE IF EXISTS `accountlines`;
-CREATE TABLE `accountlines` (
-  `borrowernumber` int(11) NOT NULL default 0,
-  `accountno` smallint(6) NOT NULL default 0,
-  `itemnumber` int(11) default NULL,
-  `date` date default NULL,
-  `amount` decimal(28,6) default NULL,
-  `description` mediumtext,
-  `dispute` mediumtext,
-  `accounttype` varchar(5) default NULL,
-  `amountoutstanding` decimal(28,6) default NULL,
-  `lastincrement` decimal(28,6) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `notify_id` int(11) NOT NULL default 0,
-  `notify_level` int(2) NOT NULL default 0,
-  KEY `acctsborridx` (`borrowernumber`),
-  KEY `timeidx` (`timestamp`),
-  KEY `itemnumber` (`itemnumber`),
-  CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `accountoffsets`
---
-
-DROP TABLE IF EXISTS `accountoffsets`;
-CREATE TABLE `accountoffsets` (
-  `borrowernumber` int(11) NOT NULL default 0,
-  `accountno` smallint(6) NOT NULL default 0,
-  `offsetaccount` smallint(6) NOT NULL default 0,
-  `offsetamount` decimal(28,6) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `action_logs`
---
-
-DROP TABLE IF EXISTS `action_logs`;
-CREATE TABLE `action_logs` (
-  `action_id` int(11) NOT NULL auto_increment,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `user` int(11) NOT NULL default 0,
-  `module` text,
-  `action` text,
-  `object` int(11) default NULL,
-  `info` text,
-  PRIMARY KEY (`action_id`),
-  KEY  (`timestamp`,`user`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `alert`
---
-
-DROP TABLE IF EXISTS `alert`;
-CREATE TABLE `alert` (
-  `alertid` int(11) NOT NULL auto_increment,
-  `borrowernumber` int(11) NOT NULL default 0,
-  `type` varchar(10) NOT NULL default '',
-  `externalid` varchar(20) NOT NULL default '',
-  PRIMARY KEY  (`alertid`),
-  KEY `borrowernumber` (`borrowernumber`),
-  KEY `type` (`type`,`externalid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqbasket`
---
-
-DROP TABLE IF EXISTS `aqbasket`;
-CREATE TABLE `aqbasket` (
-  `basketno` int(11) NOT NULL auto_increment,
-  `creationdate` date default NULL,
-  `closedate` date default NULL,
-  `booksellerid` int(11) NOT NULL default 1,
-  `authorisedby` varchar(10) default NULL,
-  `booksellerinvoicenumber` mediumtext,
-  PRIMARY KEY  (`basketno`),
-  KEY `booksellerid` (`booksellerid`),
-  CONSTRAINT `aqbasket_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqbookfund`
---
-
-DROP TABLE IF EXISTS `aqbookfund`;
-CREATE TABLE `aqbookfund` (
-  `bookfundid` varchar(10) NOT NULL default '',
-  `bookfundname` mediumtext,
-  `bookfundgroup` varchar(5) default NULL,
-  `branchcode` varchar(10) NOT NULL default '',
-  PRIMARY KEY  (`bookfundid`,`branchcode`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqbooksellers`
---
-
-DROP TABLE IF EXISTS `aqbooksellers`;
-CREATE TABLE `aqbooksellers` (
-  `id` int(11) NOT NULL auto_increment,
-  `name` mediumtext NOT NULL,
-  `address1` mediumtext,
-  `address2` mediumtext,
-  `address3` mediumtext,
-  `address4` mediumtext,
-  `phone` varchar(30) default NULL,
-  `accountnumber` mediumtext,
-  `othersupplier` mediumtext,
-  `currency` varchar(3) NOT NULL default '',
-  `deliverydays` smallint(6) default NULL,
-  `followupdays` smallint(6) default NULL,
-  `followupscancel` smallint(6) default NULL,
-  `specialty` mediumtext,
-  `booksellerfax` mediumtext,
-  `notes` mediumtext,
-  `bookselleremail` mediumtext,
-  `booksellerurl` mediumtext,
-  `contact` varchar(100) default NULL,
-  `postal` mediumtext,
-  `url` varchar(255) default NULL,
-  `contpos` varchar(100) default NULL,
-  `contphone` varchar(100) default NULL,
-  `contfax` varchar(100) default NULL,
-  `contaltphone` varchar(100) default NULL,
-  `contemail` varchar(100) default NULL,
-  `contnotes` mediumtext,
-  `active` tinyint(4) default NULL,
-  `listprice` varchar(10) default NULL,
-  `invoiceprice` varchar(10) default NULL,
-  `gstreg` tinyint(4) default NULL,
-  `listincgst` tinyint(4) default NULL,
-  `invoiceincgst` tinyint(4) default NULL,
-  `discount` float(6,4) default NULL,
-  `fax` varchar(50) default NULL,
-  `nocalc` int(11) default NULL,
-  `invoicedisc` float(6,4) default NULL,
-  PRIMARY KEY  (`id`),
-  KEY `listprice` (`listprice`),
-  KEY `invoiceprice` (`invoiceprice`),
-  CONSTRAINT `aqbooksellers_ibfk_1` FOREIGN KEY (`listprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `aqbooksellers_ibfk_2` FOREIGN KEY (`invoiceprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqbudget`
---
-
-DROP TABLE IF EXISTS `aqbudget`;
-CREATE TABLE `aqbudget` (
-  `bookfundid` varchar(10) NOT NULL default '',
-  `startdate` date NOT NULL default 0,
-  `enddate` date default NULL,
-  `budgetamount` decimal(13,2) default NULL,
-  `aqbudgetid` tinyint(4) NOT NULL auto_increment,
-  `branchcode` varchar(10) default NULL,
-  PRIMARY KEY  (`aqbudgetid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqorderbreakdown`
---
-
-DROP TABLE IF EXISTS `aqorderbreakdown`;
-CREATE TABLE `aqorderbreakdown` (
-  `ordernumber` int(11) default NULL,
-  `linenumber` int(11) default NULL,
-  `branchcode` varchar(10) default NULL,
-  `bookfundid` varchar(10) NOT NULL default '',
-  `allocation` smallint(6) default NULL,
-  KEY `ordernumber` (`ordernumber`),
-  KEY `bookfundid` (`bookfundid`),
-  CONSTRAINT `aqorderbreakdown_ibfk_1` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `aqorderbreakdown_ibfk_2` FOREIGN KEY (`bookfundid`) REFERENCES `aqbookfund` (`bookfundid`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqorderdelivery`
---
-
-DROP TABLE IF EXISTS `aqorderdelivery`;
-CREATE TABLE `aqorderdelivery` (
-  `ordernumber` date default NULL,
-  `deliverynumber` smallint(6) NOT NULL default 0,
-  `deliverydate` varchar(18) default NULL,
-  `qtydelivered` smallint(6) default NULL,
-  `deliverycomments` mediumtext
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `aqorders`
---
-
-DROP TABLE IF EXISTS `aqorders`;
-CREATE TABLE `aqorders` (
-  `ordernumber` int(11) NOT NULL auto_increment,
-  `biblionumber` int(11) default NULL,
-  `title` mediumtext,
-  `entrydate` date default NULL,
-  `quantity` smallint(6) default NULL,
-  `currency` varchar(3) default NULL,
-  `listprice` decimal(28,6) default NULL,
-  `totalamount` decimal(28,6) default NULL,
-  `datereceived` date default NULL,
-  `booksellerinvoicenumber` mediumtext,
-  `freight` decimal(28,6) default NULL,
-  `unitprice` decimal(28,6) default NULL,
-  `quantityreceived` smallint(6) default NULL,
-  `cancelledby` varchar(10) default NULL,
-  `datecancellationprinted` date default NULL,
-  `notes` mediumtext,
-  `supplierreference` mediumtext,
-  `purchaseordernumber` mediumtext,
-  `subscription` tinyint(1) default NULL,
-  `serialid` varchar(30) default NULL,
-  `basketno` int(11) default NULL,
-  `biblioitemnumber` int(11) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `rrp` decimal(13,2) default NULL,
-  `ecost` decimal(13,2) default NULL,
-  `gst` decimal(13,2) default NULL,
-  `budgetdate` date default NULL,
-  `sort1` varchar(80) default NULL,
-  `sort2` varchar(80) default NULL,
-  PRIMARY KEY  (`ordernumber`),
-  KEY `basketno` (`basketno`),
-  KEY `biblionumber` (`biblionumber`),
-  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
 -- Table structure for table `auth_header`
 --
 
@@ -294,7 +55,7 @@ CREATE TABLE `auth_subfield_structure` (
   `hidden` tinyint(3) NOT NULL default 0,
   `linkid` tinyint(1) NOT NULL default 0,
   `kohafield` varchar(45) NULL default '',
-  `frameworkcode` varchar(8) NOT NULL default '',
+  `frameworkcode` varchar(10) NOT NULL default '',
   PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
   KEY `tab` (`authtypecode`,`tab`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -334,14 +95,17 @@ CREATE TABLE `auth_types` (
 --
 
 DROP TABLE IF EXISTS `authorised_values`;
-CREATE TABLE `authorised_values` (
-  `id` int(11) NOT NULL auto_increment,
-  `category` varchar(10) NOT NULL default '',
-  `authorised_value` varchar(80) NOT NULL default '',
-  `lib` varchar(80) default NULL,
-  `imageurl` varchar(200) default NULL,
+CREATE TABLE `authorised_values` ( -- stores values for authorized values categories and values
+  `id` int(11) NOT NULL auto_increment, -- unique key, used to identify the authorized value
+  `category` varchar(10) NOT NULL default '', -- key used to identify the authorized value category
+  `authorised_value` varchar(80) NOT NULL default '', -- code use to identify the authorized value
+  `lib` varchar(80) default NULL, -- authorized value description as printed in the staff client
+  `lib_opac` VARCHAR(80) default NULL, -- authorized value description as printed in the OPAC
+  `imageurl` varchar(200) default NULL, -- authorized value URL
   PRIMARY KEY  (`id`),
-  KEY `name` (`category`)
+  KEY `name` (`category`),
+  KEY `lib` (`lib`),
+  KEY `auth_value_idx` (`authorised_value`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
@@ -349,19 +113,19 @@ CREATE TABLE `authorised_values` (
 --
 
 DROP TABLE IF EXISTS `biblio`;
-CREATE TABLE `biblio` (
-  `biblionumber` int(11) NOT NULL auto_increment,
-  `frameworkcode` varchar(4) NOT NULL default '',
-  `author` mediumtext,
-  `title` mediumtext,
-  `unititle` mediumtext,
-  `notes` mediumtext,
-  `serial` tinyint(1) default NULL,
+CREATE TABLE `biblio` ( -- table that stores bibliographic information
+  `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
+  `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
+  `author` mediumtext, -- statement of responsibility from MARC record (100 in MARC21)
+  `title` mediumtext, -- title (without the subtitle) from the MARC record (245 in MARC21)
+  `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240 in MARC21)
+  `notes` mediumtext, -- values from the general notes field in the MARC record (500 in MARC21) split by bar (|)
+  `serial` tinyint(1) default NULL, -- foreign key, linking to the subscriptionid in the serial table
   `seriestitle` mediumtext,
-  `copyrightdate` smallint(6) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `datecreated` DATE NOT NULL,
-  `abstract` mediumtext,
+  `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
+  `datecreated` DATE NOT NULL, -- the date this record was added to Koha
+  `abstract` mediumtext, -- summary from the MARC record (520 in MARC21)
   PRIMARY KEY  (`biblionumber`),
   KEY `blbnoidx` (`biblionumber`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -419,8 +183,8 @@ CREATE TABLE `biblioitems` (
   KEY `bibinoidx` (`biblioitemnumber`),
   KEY `bibnoidx` (`biblionumber`),
   KEY `isbn` (`isbn`),
-  KEY `publishercode` (`publishercode`),
   KEY `issn` (`issn`),
+  KEY `publishercode` (`publishercode`),
   CONSTRAINT `biblioitems_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -429,70 +193,79 @@ CREATE TABLE `biblioitems` (
 --
 
 DROP TABLE IF EXISTS `borrowers`;
-CREATE TABLE `borrowers` (
-  `borrowernumber` int(11) NOT NULL auto_increment,
-  `cardnumber` varchar(16) default NULL,
-  `surname` mediumtext NOT NULL,
-  `firstname` text,
-  `title` mediumtext,
-  `othernames` mediumtext,
-  `initials` text,
-  `streetnumber` varchar(10) default NULL,
-  `streettype` varchar(50) default NULL,
-  `address` mediumtext NOT NULL,
-  `address2` text,
-  `city` mediumtext NOT NULL,
-  `zipcode` varchar(25) default NULL,
-  `email` mediumtext,
-  `phone` text,
-  `mobile` varchar(50) default NULL,
-  `fax` mediumtext,
-  `emailpro` text,
-  `phonepro` text,
-  `B_streetnumber` varchar(10) default NULL,
-  `B_streettype` varchar(50) default NULL,
-  `B_address` varchar(100) default NULL,
-  `B_city` mediumtext,
-  `B_zipcode` varchar(25) default NULL,
-  `B_email` text,
-  `B_phone` mediumtext,
-  `dateofbirth` date default NULL,
-  `branchcode` varchar(10) NOT NULL default '',
-  `categorycode` varchar(10) NOT NULL default '',
-  `dateenrolled` date default NULL,
-  `dateexpiry` date default NULL,
-  `gonenoaddress` tinyint(1) default NULL,
-  `lost` tinyint(1) default NULL,
-  `debarred` tinyint(1) default NULL,
-  `contactname` mediumtext,
-  `contactfirstname` text,
-  `contacttitle` text,
-  `guarantorid` int(11) default NULL,
-  `borrowernotes` mediumtext,
-  `relationship` varchar(100) default NULL,
-  `ethnicity` varchar(50) default NULL,
-  `ethnotes` varchar(255) default NULL,
-  `sex` varchar(1) default NULL,
-  `password` varchar(30) default NULL,
-  `flags` int(11) default NULL,
-  `userid` varchar(30) default NULL,
-  `opacnote` mediumtext,
-  `contactnote` varchar(255) default NULL,
-  `sort1` varchar(80) default NULL,
-  `sort2` varchar(80) default NULL,
-  `altcontactfirstname` varchar(255) default NULL,
-  `altcontactsurname` varchar(255) default NULL,
-  `altcontactaddress1` varchar(255) default NULL,
-  `altcontactaddress2` varchar(255) default NULL,
-  `altcontactaddress3` varchar(255) default NULL,
-  `altcontactzipcode` varchar(50) default NULL,
-  `altcontactphone` varchar(50) default NULL,
-  `smsalertnumber` varchar(50) default NULL,
+CREATE TABLE `borrowers` ( -- this table includes information about your patrons/borrowers/members
+  `borrowernumber` int(11) NOT NULL auto_increment, -- primary key, Koha assigned ID number for patrons/borrowers
+  `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
+  `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
+  `firstname` text, -- patron/borrower's first name
+  `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
+  `othernames` mediumtext, -- any other names associated with the patron/borrower
+  `initials` text, -- initials for your patron/borrower
+  `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
+  `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
+  `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
+  `address2` text, -- the second address line for your patron/borrower's primary address
+  `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
+  `state` text default NULL, -- the state or province for your patron/borrower's primary address
+  `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
+  `country` text, -- the country for your patron/borrower's primary address
+  `email` mediumtext, -- the primary email address for your patron/borrower's primary address
+  `phone` text, -- the primary phone number for your patron/borrower's primary address
+  `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
+  `fax` mediumtext, -- the fax number for your patron/borrower's primary address
+  `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
+  `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
+  `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
+  `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
+  `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
+  `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
+  `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
+  `B_state` text default NULL, -- the state for your patron/borrower's alternate address
+  `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
+  `B_country` text, -- the country for your patron/borrower's alternate address
+  `B_email` text, -- the patron/borrower's alternate email address
+  `B_phone` mediumtext, -- the patron/borrower's alternate phone number
+  `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
+  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
+  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
+  `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
+  `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
+  `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address
+  `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
+  `debarred` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as being restricted
+  `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
+  `contactfirstname` text, -- used for children to include first name of guarentor
+  `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
+  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
+  `borrowernotes` mediumtext, -- a note on the patron/borroewr's account that is only visible in the staff client
+  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
+  `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
+  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
+  `userid` varchar(30) 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
+  `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
+  `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
+  `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
+  `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
+  `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
+  `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
+  `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
+  `altcontactaddress3` varchar(255) default NULL, -- the third address line for the alternate contact for the patron/borrower
+  `altcontactstate` text default NULL, -- the city and state for the alternate contact for the patron/borrower
+  `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
+  `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
+  `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
+  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
+  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
   UNIQUE KEY `cardnumber` (`cardnumber`),
   PRIMARY KEY `borrowernumber` (`borrowernumber`),
   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;
@@ -502,16 +275,17 @@ CREATE TABLE `borrowers` (
 --
 
 DROP TABLE IF EXISTS `borrower_attribute_types`;
-CREATE TABLE `borrower_attribute_types` (
-  `code` varchar(10) NOT NULL,
-  `description` varchar(255) NOT NULL,
-  `repeatable` tinyint(1) NOT NULL default 0,
-  `unique_id` tinyint(1) NOT NULL default 0,
-  `opac_display` tinyint(1) NOT NULL default 0,
-  `password_allowed` tinyint(1) NOT NULL default 0,
-  `staff_searchable` tinyint(1) NOT NULL default 0,
-  `authorised_value_category` varchar(10) default NULL,
-  PRIMARY KEY  (`code`)
+CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron fields known as extended patron attributes
+  `code` varchar(10) NOT NULL, -- unique key used to identify each custom field
+  `description` varchar(255) NOT NULL, -- description for each custom field
+  `repeatable` tinyint(1) NOT NULL default 0, -- defines whether one patron/borrower can have multiple values for this custom field  (1 for yes, 0 for no)
+  `unique_id` tinyint(1) NOT NULL default 0, -- defines if this value needs to be unique (1 for yes, 0 for no)
+  `opac_display` tinyint(1) NOT NULL default 0, -- defines if this field is visible to patrons on their account in the OPAC (1 for yes, 0 for no)
+  `password_allowed` tinyint(1) NOT NULL default 0, -- defines if it is possible to associate a password with this custom field (1 for yes, 0 for no)
+  `staff_searchable` tinyint(1) NOT NULL default 0, -- defines if this field is searchable via the patron search in the staff client (1 for yes, 0 for no)
+  `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
+  PRIMARY KEY  (`code`),
+  KEY `auth_val_cat_idx` (`authorised_value_category`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
@@ -519,11 +293,11 @@ CREATE TABLE `borrower_attribute_types` (
 --
 
 DROP TABLE IF EXISTS `borrower_attributes`;
-CREATE TABLE `borrower_attributes` (
-  `borrowernumber` int(11) NOT NULL,
-  `code` varchar(10) NOT NULL,
-  `attribute` varchar(64) default NULL,
-  `password` varchar(64) default NULL,
+CREATE TABLE `borrower_attributes` ( -- values of custom patron fields known as extended patron attributes linked to patrons/borrowers
+  `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines which patron/borrower has this attribute
+  `code` varchar(10) NOT NULL, -- foreign key from the borrower_attribute_types table, defines which custom field this value was entered for
+  `attribute` varchar(64) default NULL, -- custom patron field value
+  `password` varchar(64) default NULL, -- password associated with this field
   KEY `borrowernumber` (`borrowernumber`),
   KEY `code_attribute` (`code`, `attribute`),
   CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
@@ -532,6 +306,11 @@ CREATE TABLE `borrower_attributes` (
     ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `branch_item_rules`
+--
+
+DROP TABLE IF EXISTS `branch_item_rules`;
 CREATE TABLE `branch_item_rules` (
   `branchcode` varchar(10) NOT NULL,
   `itemtype` varchar(10) NOT NULL,
@@ -549,11 +328,11 @@ CREATE TABLE `branch_item_rules` (
 --
 
 DROP TABLE IF EXISTS `branchcategories`;
-CREATE TABLE `branchcategories` (
-  `categorycode` varchar(10) NOT NULL default '',
-  `categoryname` varchar(32),
-  `codedescription` mediumtext,
-  `categorytype` varchar(16),
+CREATE TABLE `branchcategories` ( -- information related to library/branch groups
+  `categorycode` varchar(10) NOT NULL default '', -- unique identifier for the library/branch group
+  `categoryname` varchar(32), -- name of the library/branch group
+  `codedescription` mediumtext, -- longer description of the library/branch group
+  `categorytype` varchar(16), -- says whether this is a search group or a properties group
   PRIMARY KEY  (`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -562,18 +341,24 @@ CREATE TABLE `branchcategories` (
 --
 
 DROP TABLE IF EXISTS `branches`;
-CREATE TABLE `branches` (
-  `branchcode` varchar(10) NOT NULL default '',
-  `branchname` mediumtext NOT NULL,
-  `branchaddress1` mediumtext,
-  `branchaddress2` mediumtext,
-  `branchaddress3` mediumtext,
-  `branchphone` mediumtext,
-  `branchfax` mediumtext,
-  `branchemail` mediumtext,
-  `issuing` tinyint(4) default NULL,
-  `branchip` varchar(15) default NULL,
-  `branchprinter` varchar(100) default NULL,
+CREATE TABLE `branches` ( -- information about your libraries or branches are stored here
+  `branchcode` varchar(10) NOT NULL default '', -- a unique key assigned to each branch
+  `branchname` mediumtext NOT NULL, -- the name of your library or branch
+  `branchaddress1` mediumtext, -- the first address line of for your library or branch
+  `branchaddress2` mediumtext, -- the second address line of for your library or branch
+  `branchaddress3` mediumtext, -- the third address line of for your library or branch
+  `branchzip` varchar(25) default NULL, -- the zip or postal code for your library or branch
+  `branchcity` mediumtext, -- the city or province for your library or branch
+  `branchstate` mediumtext, -- the state for your library or branch
+  `branchcountry` text, -- the county for your library or branch
+  `branchphone` mediumtext, -- the primary phone for your library or branch
+  `branchfax` mediumtext, -- the fax number for your library or branch
+  `branchemail` mediumtext, -- the primary email address for your library or branch
+  `branchurl` mediumtext, -- the URL for your library or branch's website
+  `issuing` tinyint(4) default NULL, --unused in Koha
+  `branchip` varchar(15) default NULL, -- the IP address for your library or branch
+  `branchprinter` varchar(100) default NULL, -- unused in Koha
+  `branchnotes` mediumtext, -- notes related to your library or branch
   UNIQUE KEY `branchcode` (`branchcode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -582,9 +367,9 @@ CREATE TABLE `branches` (
 --
 
 DROP TABLE IF EXISTS `branchrelations`;
-CREATE TABLE `branchrelations` (
-  `branchcode` varchar(10) NOT NULL default '',
-  `categorycode` varchar(10) NOT NULL default '',
+CREATE TABLE `branchrelations` ( -- this table links libraries/branches to groups
+  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to identify the branch
+  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the branchcategories table to identify the group
   PRIMARY KEY  (`branchcode`,`categorycode`),
   KEY `branchcode` (`branchcode`),
   KEY `categorycode` (`categorycode`),
@@ -634,6 +419,7 @@ CREATE TABLE `categories` (
   `categorycode` varchar(10) NOT NULL default '',
   `description` mediumtext,
   `enrolmentperiod` smallint(6) default NULL,
+  `enrolmentperioddate` DATE NULL DEFAULT NULL,
   `upperagelimit` smallint(6) default NULL,
   `dateofbirthrequired` tinyint(1) default NULL,
   `finetype` varchar(30) default NULL,
@@ -642,12 +428,36 @@ CREATE TABLE `categories` (
   `overduenoticerequired` tinyint(1) default NULL,
   `issuelimit` smallint(6) default NULL,
   `reservefee` decimal(28,6) default NULL,
+  `hidelostitems` tinyint(1) NOT NULL default '0',
   `category_type` varchar(1) NOT NULL default 'A',
   PRIMARY KEY  (`categorycode`),
   UNIQUE KEY `categorycode` (`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
+-- Table: collections
+--
+DROP TABLE IF EXISTS collections;
+CREATE TABLE collections (
+  colId integer(11) NOT NULL auto_increment,
+  colTitle varchar(100) NOT NULL DEFAULT '',
+  colDesc text NOT NULL,
+  colBranchcode varchar(4) DEFAULT NULL comment 'branchcode for branch where item should be held.',
+  PRIMARY KEY (colId)
+) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
+
+--
+-- Table: collections_tracking
+--
+DROP TABLE IF EXISTS collections_tracking;
+CREATE TABLE collections_tracking (
+  ctId integer(11) NOT NULL auto_increment,
+  colId integer(11) NOT NULL DEFAULT 0 comment 'collections.colId',
+  itemnumber integer(11) NOT NULL DEFAULT 0 comment 'items.itemnumber',
+  PRIMARY KEY (ctId)
+) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
+
+--
 -- Table structure for table `borrower_branch_circ_rules`
 --
 
@@ -693,7 +503,7 @@ CREATE TABLE `default_branch_circ_rules` (
 --
 -- Table structure for table `default_branch_item_rules`
 --
-
+DROP TABLE IF EXISTS `default_branch_item_rules`;
 CREATE TABLE `default_branch_item_rules` (
   `itemtype` varchar(10) NOT NULL,
   `holdallowed` tinyint(1) default NULL,
@@ -719,10 +529,12 @@ CREATE TABLE `default_circ_rules` (
 --
 
 DROP TABLE IF EXISTS `cities`;
-CREATE TABLE `cities` (
-  `cityid` int(11) NOT NULL auto_increment,
-  `city_name` varchar(100) NOT NULL default '',
-  `city_zipcode` varchar(20) default NULL,
+CREATE TABLE `cities` ( -- authorized values for cities/states/countries to choose when adding/editing a patron/borrower
+  `cityid` int(11) NOT NULL auto_increment, -- unique identifier added by Koha
+  `city_name` varchar(100) NOT NULL default '', -- name of the city
+  `city_state` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the state/province
+  `city_country` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the country
+  `city_zipcode` varchar(20) default NULL, -- zip or postal code
   PRIMARY KEY  (`cityid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -764,7 +576,8 @@ CREATE TABLE `currency` (
   `currency` varchar(10) NOT NULL default '',
   `symbol` varchar(5) default NULL,
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `rate` float(7,5) default NULL,
+  `rate` float(15,5) default NULL,
+  `active` tinyint(1) default NULL,
   PRIMARY KEY  (`currency`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -773,19 +586,19 @@ CREATE TABLE `currency` (
 --
 
 DROP TABLE IF EXISTS `deletedbiblio`;
-CREATE TABLE `deletedbiblio` (
-  `biblionumber` int(11) NOT NULL default 0,
-  `frameworkcode` varchar(4) NOT NULL default '',
-  `author` mediumtext,
-  `title` mediumtext,
-  `unititle` mediumtext,
-  `notes` mediumtext,
-  `serial` tinyint(1) default NULL,
+CREATE TABLE `deletedbiblio` ( -- stores information about bibliographic records that have been deleted
+  `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
+  `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
+  `author` mediumtext, -- statement of responsibility from MARC record (100 in MARC21)
+  `title` mediumtext, -- title (without the subtitle) from the MARC record (245 in MARC21)
+  `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240 in MARC21)
+  `notes` mediumtext, -- values from the general notes field in the MARC record (500 in MARC21) split by bar (|)
+  `serial` tinyint(1) default NULL, -- foreign key, linking to the subscriptionid in the serial table
   `seriestitle` mediumtext,
-  `copyrightdate` smallint(6) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `datecreated` DATE NOT NULL,
-  `abstract` mediumtext,
+  `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
+  `datecreated` DATE NOT NULL, -- the date this record was added to Koha
+  `abstract` mediumtext, -- summary from the MARC record (520 in MARC21)
   PRIMARY KEY  (`biblionumber`),
   KEY `blbnoidx` (`biblionumber`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -840,66 +653,73 @@ CREATE TABLE `deletedbiblioitems` (
 --
 
 DROP TABLE IF EXISTS `deletedborrowers`;
-CREATE TABLE `deletedborrowers` (
-  `borrowernumber` int(11) NOT NULL default 0,
-  `cardnumber` varchar(9) NOT NULL default '',
-  `surname` mediumtext NOT NULL,
-  `firstname` text,
-  `title` mediumtext,
-  `othernames` mediumtext,
-  `initials` text,
-  `streetnumber` varchar(10) default NULL,
-  `streettype` varchar(50) default NULL,
-  `address` mediumtext NOT NULL,
-  `address2` text,
-  `city` mediumtext NOT NULL,
-  `zipcode` varchar(25) default NULL,
-  `email` mediumtext,
-  `phone` text,
-  `mobile` varchar(50) default NULL,
-  `fax` mediumtext,
-  `emailpro` text,
-  `phonepro` text,
-  `B_streetnumber` varchar(10) default NULL,
-  `B_streettype` varchar(50) default NULL,
-  `B_address` varchar(100) default NULL,
-  `B_city` mediumtext,
-  `B_zipcode` varchar(25) default NULL,
-  `B_email` text,
-  `B_phone` mediumtext,
-  `dateofbirth` date default NULL,
-  `branchcode` varchar(10) NOT NULL default '',
-  `categorycode` varchar(10) default NULL,
-  `dateenrolled` date default NULL,
-  `dateexpiry` date default NULL,
-  `gonenoaddress` tinyint(1) default NULL,
-  `lost` tinyint(1) default NULL,
-  `debarred` tinyint(1) default NULL,
-  `contactname` mediumtext,
-  `contactfirstname` text,
-  `contacttitle` text,
-  `guarantorid` int(11) default NULL,
-  `borrowernotes` mediumtext,
-  `relationship` varchar(100) default NULL,
-  `ethnicity` varchar(50) default NULL,
-  `ethnotes` varchar(255) default NULL,
-  `sex` varchar(1) default NULL,
-  `password` varchar(30) default NULL,
-  `flags` int(11) default NULL,
-  `userid` varchar(30) default NULL,
-  `opacnote` mediumtext,
-  `contactnote` varchar(255) default NULL,
-  `sort1` varchar(80) default NULL,
-  `sort2` varchar(80) default NULL,
-  `altcontactfirstname` varchar(255) default NULL,
-  `altcontactsurname` varchar(255) default NULL,
-  `altcontactaddress1` varchar(255) default NULL,
-  `altcontactaddress2` varchar(255) default NULL,
-  `altcontactaddress3` varchar(255) default NULL,
-  `altcontactzipcode` varchar(50) default NULL,
-  `altcontactphone` varchar(50) default NULL,
-  `smsalertnumber` varchar(50) default NULL,
-  KEY `borrowernumber` (`borrowernumber`),
+CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrowers you have deleted
+  `borrowernumber` int(11) NOT NULL auto_increment, -- primary key, Koha assigned ID number for patrons/borrowers
+  `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
+  `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
+  `firstname` text, -- patron/borrower's first name
+  `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
+  `othernames` mediumtext, -- any other names associated with the patron/borrower
+  `initials` text, -- initials for your patron/borrower
+  `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
+  `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
+  `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
+  `address2` text, -- the second address line for your patron/borrower's primary address
+  `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
+  `state` text default NULL, -- the state or province for your patron/borrower's primary address
+  `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
+  `country` text, -- the country for your patron/borrower's primary address
+  `email` mediumtext, -- the primary email address for your patron/borrower's primary address
+  `phone` text, -- the primary phone number for your patron/borrower's primary address
+  `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
+  `fax` mediumtext, -- the fax number for your patron/borrower's primary address
+  `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
+  `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
+  `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
+  `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
+  `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
+  `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
+  `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
+  `B_state` text default NULL, -- the state for your patron/borrower's alternate address
+  `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
+  `B_country` text, -- the country for your patron/borrower's alternate address
+  `B_email` text, -- the patron/borrower's alternate email address
+  `B_phone` mediumtext, -- the patron/borrower's alternate phone number
+  `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
+  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
+  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
+  `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
+  `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
+  `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address
+  `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
+  `debarred` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as being restricted
+  `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
+  `contactfirstname` text, -- used for children to include first name of guarentor
+  `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
+  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
+  `borrowernotes` mediumtext, -- a note on the patron/borroewr's account that is only visible in the staff client
+  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
+  `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
+  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
+  `userid` varchar(30) 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
+  `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
+  `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
+  `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
+  `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
+  `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
+  `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
+  `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
+  `altcontactaddress3` varchar(255) default NULL, -- the third address line for the alternate contact for the patron/borrower
+  `altcontactstate` text default NULL, -- the city and state for the alternate contact for the patron/borrower
+  `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
+  `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
+  `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
+  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
+  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
   KEY `cardnumber` (`cardnumber`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -926,7 +746,7 @@ CREATE TABLE `deleteditems` (
   `damaged` tinyint(1) NOT NULL default 0,
   `itemlost` tinyint(1) NOT NULL default 0,
   `wthdrawn` tinyint(1) NOT NULL default 0,
-  `itemcallnumber` varchar(30) default NULL,
+  `itemcallnumber` varchar(255) default NULL,
   `issues` smallint(6) default NULL,
   `renewals` smallint(6) default NULL,
   `reserves` smallint(6) default NULL,
@@ -936,6 +756,7 @@ CREATE TABLE `deleteditems` (
   `paidfor` mediumtext,
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   `location` varchar(80) default NULL,
+  `permanent_location` varchar(80) default NULL,
   `onloan` date default NULL,
   `cn_source` varchar(10) default NULL,
   `cn_sort` varchar(30) default NULL,
@@ -944,11 +765,13 @@ CREATE TABLE `deleteditems` (
   `uri` varchar(255) default NULL,
   `itype` varchar(10) default NULL,
   `more_subfields_xml` longtext default NULL,
-  `enumchron` varchar(80) default NULL,
+  `enumchron` text default NULL,
   `copynumber` varchar(32) default NULL,
+  `stocknumber` varchar(32) default NULL,
   `marc` longblob,
   PRIMARY KEY  (`itemnumber`),
   KEY `delitembarcodeidx` (`barcode`),
+  KEY `delitemstocknumberidx` (`stocknumber`),
   KEY `delitembinoidx` (`biblioitemnumber`),
   KEY `delitembibnoidx` (`biblionumber`),
   KEY `delhomebranch` (`homebranch`),
@@ -967,6 +790,24 @@ CREATE TABLE `ethnicity` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
+-- Table structure for table `export_format`
+--
+
+DROP TABLE IF EXISTS `export_format`;
+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,
+  `csv_separator` varchar(2) NOT NULL,
+  `field_separator` varchar(2) NOT NULL,
+  `subfield_separator` varchar(2) NOT NULL,
+  `encoding` varchar(255) NOT NULL,
+  PRIMARY KEY  (`export_format_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
+
+
+--
 -- Table structure for table `hold_fill_targets`
 --
 
@@ -979,13 +820,13 @@ CREATE TABLE hold_fill_targets (
   `item_level_request` tinyint(4) NOT NULL default 0,
   PRIMARY KEY `itemnumber` (`itemnumber`),
   KEY `bib_branch` (`biblionumber`, `source_branchcode`),
-  CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`) 
+  CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
     REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`) 
+  CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
     REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`) 
+  CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
     REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`) 
+  CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
     REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1049,7 +890,7 @@ CREATE TABLE `import_record_matches` (
   `import_record_id` int(11) NOT NULL,
   `candidate_match_id` int(11) NOT NULL,
   `score` int(11) NOT NULL default 0,
-  CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`) 
+  CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
   KEY `record_score` (`import_record_id`, `score`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -1069,7 +910,7 @@ CREATE TABLE `import_biblios` (
   `isbn` varchar(30) default NULL,
   `issn` varchar(9) default NULL,
   `has_items` tinyint(1) NOT NULL default 0,
-  CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`) 
+  CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
   KEY `matched_biblionumber` (`matched_biblionumber`),
   KEY `title` (`title`),
@@ -1090,7 +931,7 @@ CREATE TABLE `import_items` (
   `marcxml` longtext NOT NULL,
   `import_error` mediumtext,
   PRIMARY KEY (`import_items_id`),
-  CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`) 
+  CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
   KEY `itemnumber` (`itemnumber`),
   KEY `branchcode` (`branchcode`)
@@ -1101,23 +942,22 @@ CREATE TABLE `import_items` (
 --
 
 DROP TABLE IF EXISTS `issues`;
-CREATE TABLE `issues` (
-  `borrowernumber` int(11) default NULL,
-  `itemnumber` int(11) default NULL,
-  `date_due` date default NULL,
-  `branchcode` varchar(10) default NULL,
+CREATE TABLE `issues` ( -- information related to check outs or issues
+  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
+  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
+  `date_due` date default NULL, -- date the item is due (yyyy-mm-dd)
+  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
   `issuingbranch` varchar(18) default NULL,
-  `returndate` date default NULL,
-  `lastreneweddate` date default NULL,
+  `returndate` date default NULL, -- date the item was returned, will be NULL until moved to old_issues
+  `lastreneweddate` date default NULL, -- date the item was last renewed
   `return` varchar(4) default NULL,
-  `renewals` tinyint(4) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `issuedate` date default NULL,
+  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
+  `issuedate` date default NULL, -- date the item was checked out or issued
   KEY `issuesborridx` (`borrowernumber`),
-  KEY `issuesitemidx` (`itemnumber`),
   KEY `bordate` (`borrowernumber`,`timestamp`),
-  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
-  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
+  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
+  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
@@ -1132,12 +972,17 @@ CREATE TABLE `issuingrules` (
   `rentaldiscount` decimal(28,6) default NULL,
   `reservecharge` decimal(28,6) default NULL,
   `fine` decimal(28,6) default NULL,
+  `finedays` int(11) default NULL,
   `firstremind` int(11) default NULL,
   `chargeperiod` int(11) default NULL,
   `accountsent` int(11) default NULL,
   `chargename` varchar(100) default NULL,
   `maxissueqty` int(4) default NULL,
   `issuelength` int(4) default NULL,
+  `hardduedate` date default NULL,
+  `hardduedatecompare` tinyint NOT NULL default "0",
+  `renewalsallowed` smallint(6) NOT NULL default "0",
+  `reservesallowed` smallint(6) NOT NULL default "0",
   `branchcode` varchar(10) NOT NULL default '',
   PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
   KEY `categorycode` (`categorycode`),
@@ -1167,7 +1012,7 @@ CREATE TABLE `items` (
   `damaged` tinyint(1) NOT NULL default 0,
   `itemlost` tinyint(1) NOT NULL default 0,
   `wthdrawn` tinyint(1) NOT NULL default 0,
-  `itemcallnumber` varchar(30) default NULL,
+  `itemcallnumber` varchar(255) default NULL,
   `issues` smallint(6) default NULL,
   `renewals` smallint(6) default NULL,
   `reserves` smallint(6) default NULL,
@@ -1177,6 +1022,7 @@ CREATE TABLE `items` (
   `paidfor` mediumtext,
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   `location` varchar(80) default NULL,
+  `permanent_location` varchar(80) default NULL,
   `onloan` date default NULL,
   `cn_source` varchar(10) default NULL,
   `cn_sort` varchar(30) default NULL,
@@ -1185,10 +1031,12 @@ CREATE TABLE `items` (
   `uri` varchar(255) default NULL,
   `itype` varchar(10) default NULL,
   `more_subfields_xml` longtext default NULL,
-  `enumchron` varchar(80) default NULL,
+  `enumchron` text default NULL,
   `copynumber` varchar(32) default NULL,
+  `stocknumber` varchar(32) default NULL,
   PRIMARY KEY  (`itemnumber`),
   UNIQUE KEY `itembarcodeidx` (`barcode`),
+  KEY `itemstocknumberidx` (`stocknumber`),
   KEY `itembinoidx` (`biblioitemnumber`),
   KEY `itembibnoidx` (`biblionumber`),
   KEY `homebranch` (`homebranch`),
@@ -1203,99 +1051,109 @@ CREATE TABLE `items` (
 --
 
 DROP TABLE IF EXISTS `itemtypes`;
-CREATE TABLE `itemtypes` (
-  `itemtype` varchar(10) NOT NULL default '',
-  `description` mediumtext,
-  `renewalsallowed` smallint(6) default NULL,
-  `rentalcharge` double(16,4) default NULL,
-  `notforloan` smallint(6) default NULL,
-  `imageurl` varchar(200) default NULL,
-  `summary` text,
+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
   PRIMARY KEY  (`itemtype`),
   UNIQUE KEY `itemtype` (`itemtype`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
--- Table structure for table `labels`
---
-
-DROP TABLE IF EXISTS `labels`;
-CREATE TABLE `labels` (
-  `labelid` int(11) NOT NULL auto_increment,
-  `batch_id` varchar(10) NOT NULL default 1,
-  `itemnumber` varchar(100) NOT NULL default '',
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  PRIMARY KEY  (`labelid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `labels_conf`
---
-
-DROP TABLE IF EXISTS `labels_conf`;
-CREATE TABLE `labels_conf` (
- `id` int(4) NOT NULL auto_increment,
-  `barcodetype` char(100) default '',
-  `title` int(1) default '0',
-  `subtitle` int(1) default '0',
-  `itemtype` int(1) default '0',
-  `barcode` int(1) default '0',
-  `dewey` int(1) default '0',
-  `classification` int(1) default NULL,
-  `subclass` int(1) default '0',
-  `itemcallnumber` int(1) default '0',
-  `author` int(1) default '0',
-  `issn` int(1) default '0',
-  `isbn` int(1) default '0',
-  `startlabel` int(2) NOT NULL default '1',
-  `printingtype` char(32) default 'BAR',
-  `formatstring` mediumtext default NULL,
-  `layoutname` char(20) NOT NULL default 'TEST',
-  `guidebox` int(1) default '0',
-  `active` tinyint(1) default '1',
-  `fonttype` char(10) collate utf8_unicode_ci default NULL,
-  `ccode` char(4) collate utf8_unicode_ci default NULL,
-  `callnum_split` int(1) default NULL,
-  `text_justify` char(1) collate utf8_unicode_ci default NULL,
-  PRIMARY KEY  (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `labels_profile`
---
-
-DROP TABLE IF EXISTS `labels_profile`;
-CREATE TABLE `labels_profile` (
-  `tmpl_id` int(4) NOT NULL,
-  `prof_id` int(4) NOT NULL,
-  UNIQUE KEY `tmpl_id` (`tmpl_id`),
-  UNIQUE KEY `prof_id` (`prof_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
---
--- Table structure for table `labels_templates`
---
-
-DROP TABLE IF EXISTS `labels_templates`;
-CREATE TABLE `labels_templates` (
-`tmpl_id` int(4) NOT NULL auto_increment,
-  `tmpl_code` char(100)  default '',
-  `tmpl_desc` char(100) default '',
-  `page_width` float default '0',
-  `page_height` float default '0',
-  `label_width` float default '0',
-  `label_height` float default '0',
-  `topmargin` float default '0',
-  `leftmargin` float default '0',
-  `cols` int(2) default '0',
-  `rows` int(2) default '0',
-  `colgap` float default '0',
-  `rowgap` float default '0',
-  `active` int(1) default NULL,
-  `units` char(20)  default 'PX',
-  `fontsize` int(4) NOT NULL default '3',
-  `font` char(10) NOT NULL default 'TR',
-  PRIMARY KEY  (`tmpl_id`)
+-- Table structure for table `creator_batches`
+--
+
+DROP TABLE IF EXISTS `creator_batches`;
+SET @saved_cs_client     = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `creator_batches` (
+  `label_id` int(11) NOT NULL AUTO_INCREMENT,
+  `batch_id` int(10) NOT NULL DEFAULT '1',
+  `item_number` int(11) DEFAULT NULL,
+  `borrower_number` int(11) DEFAULT NULL,
+  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `branch_code` varchar(10) NOT NULL DEFAULT 'NB',
+  `creator` char(15) NOT NULL DEFAULT 'Labels',
+  PRIMARY KEY (`label_id`),
+  KEY `branch_fk_constraint` (`branch_code`),
+  KEY `item_fk_constraint` (`item_number`),
+  KEY `borrower_fk_constraint` (`borrower_number`),
+  CONSTRAINT `creator_batches_ibfk_1` FOREIGN KEY (`borrower_number`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `creator_batches_ibfk_2` FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
+  CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `creator_images`
+--
+
+DROP TABLE IF EXISTS `creator_images`;
+SET @saved_cs_client     = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `creator_images` (
+  `image_id` int(4) NOT NULL AUTO_INCREMENT,
+  `imagefile` mediumblob,
+  `image_name` char(20) NOT NULL DEFAULT 'DEFAULT',
+  PRIMARY KEY (`image_id`),
+  UNIQUE KEY `image_name_index` (`image_name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `creator_layouts`
+--
+
+DROP TABLE IF EXISTS `creator_layouts`;
+SET @saved_cs_client     = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `creator_layouts` (
+  `layout_id` int(4) NOT NULL AUTO_INCREMENT,
+  `barcode_type` char(100) NOT NULL DEFAULT 'CODE39',
+  `start_label` int(2) NOT NULL DEFAULT '1',
+  `printing_type` char(32) NOT NULL DEFAULT 'BAR',
+  `layout_name` char(20) NOT NULL DEFAULT 'DEFAULT',
+  `guidebox` int(1) DEFAULT '0',
+  `font` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TR',
+  `font_size` int(4) NOT NULL DEFAULT '10',
+  `units` char(20) NOT NULL DEFAULT 'POINT',
+  `callnum_split` int(1) DEFAULT '0',
+  `text_justify` char(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'L',
+  `format_string` varchar(210) NOT NULL DEFAULT 'barcode',
+  `layout_xml` text NOT NULL,
+  `creator` char(15) NOT NULL DEFAULT 'Labels',
+  PRIMARY KEY (`layout_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `creator_templates`
+--
+
+DROP TABLE IF EXISTS `creator_templates`;
+SET @saved_cs_client     = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `creator_templates` (
+  `template_id` int(4) NOT NULL AUTO_INCREMENT,
+  `profile_id` int(4) DEFAULT NULL,
+  `template_code` char(100) NOT NULL DEFAULT 'DEFAULT TEMPLATE',
+  `template_desc` char(100) NOT NULL DEFAULT 'Default description',
+  `page_width` float NOT NULL DEFAULT '0',
+  `page_height` float NOT NULL DEFAULT '0',
+  `label_width` float NOT NULL DEFAULT '0',
+  `label_height` float NOT NULL DEFAULT '0',
+  `top_text_margin` float NOT NULL DEFAULT '0',
+  `left_text_margin` float NOT NULL DEFAULT '0',
+  `top_margin` float NOT NULL DEFAULT '0',
+  `left_margin` float NOT NULL DEFAULT '0',
+  `cols` int(2) NOT NULL DEFAULT '0',
+  `rows` int(2) NOT NULL DEFAULT '0',
+  `col_gap` float NOT NULL DEFAULT '0',
+  `row_gap` float NOT NULL DEFAULT '0',
+  `units` char(20) NOT NULL DEFAULT 'POINT',
+  `creator` char(15) NOT NULL DEFAULT 'Labels',
+  PRIMARY KEY (`template_id`),
+  KEY `template_profile_fk_constraint` (`profile_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
@@ -1303,12 +1161,12 @@ CREATE TABLE `labels_templates` (
 --
 
 DROP TABLE IF EXISTS `letter`;
-CREATE TABLE `letter` (
-  `module` varchar(20) NOT NULL default '',
-  `code` varchar(20) NOT NULL default '',
-  `name` varchar(100) NOT NULL default '',
-  `title` varchar(200) NOT NULL default '',
-  `content` text,
+CREATE TABLE `letter` ( -- table for all notice templates in Koha
+  `module` varchar(20) NOT NULL default '', -- Koha module that triggers this notice
+  `code` varchar(20) NOT NULL default '', -- unique identifier for this notice
+  `name` varchar(100) NOT NULL default '', -- plain text name for this notice
+  `title` varchar(200) NOT NULL default '', -- subject line of the notice
+  `content` text, -- body text for the notice
   PRIMARY KEY  (`module`,`code`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1471,37 +1329,37 @@ CREATE TABLE `notifys` (
 
 DROP TABLE IF EXISTS `nozebra`;
 CREATE TABLE `nozebra` (
-                `server` varchar(20)     NOT NULL,
-                `indexname` varchar(40)  NOT NULL,
-                `value` varchar(250)     NOT NULL,
-                `biblionumbers` longtext NOT NULL,
-                KEY `indexname` (`server`,`indexname`),
-                KEY `value` (`server`,`value`))
-                ENGINE=InnoDB DEFAULT CHARSET=utf8;
+  `server` varchar(20)     NOT NULL,
+  `indexname` varchar(40)  NOT NULL,
+  `value` varchar(250)     NOT NULL,
+  `biblionumbers` longtext NOT NULL,
+  KEY `indexname` (`server`,`indexname`),
+  KEY `value` (`server`,`value`))
+  ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
 -- Table structure for table `old_issues`
 --
 
 DROP TABLE IF EXISTS `old_issues`;
-CREATE TABLE `old_issues` (
-  `borrowernumber` int(11) default NULL,
-  `itemnumber` int(11) default NULL,
-  `date_due` date default NULL,
-  `branchcode` varchar(10) default NULL,
+CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
+  `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
+  `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
+  `date_due` date default NULL, -- date the item is due (yyyy-mm-dd)
+  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
   `issuingbranch` varchar(18) default NULL,
-  `returndate` date default NULL,
-  `lastreneweddate` date default NULL,
+  `returndate` date default NULL, -- date the item was returned
+  `lastreneweddate` date default NULL, -- date the item was last renewed
   `return` varchar(4) default NULL,
-  `renewals` tinyint(4) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  `issuedate` date default NULL,
+  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
+  `issuedate` date default NULL, -- date the item was checked out or issued
   KEY `old_issuesborridx` (`borrowernumber`),
   KEY `old_issuesitemidx` (`itemnumber`),
   KEY `old_bordate` (`borrowernumber`,`timestamp`),
-  CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) 
+  CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
     ON DELETE SET NULL ON UPDATE SET NULL,
-  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) 
+  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
     ON DELETE SET NULL ON UPDATE SET NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1524,15 +1382,17 @@ CREATE TABLE `old_reserves` (
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   `itemnumber` int(11) default NULL,
   `waitingdate` date default NULL,
+  `expirationdate` DATE DEFAULT NULL,
+  `lowestPriority` tinyint(1) NOT NULL,
   KEY `old_reserves_borrowernumber` (`borrowernumber`),
   KEY `old_reserves_biblionumber` (`biblionumber`),
   KEY `old_reserves_itemnumber` (`itemnumber`),
   KEY `old_reserves_branchcode` (`branchcode`),
-  CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) 
+  CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
     ON DELETE SET NULL ON UPDATE SET NULL,
-  CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) 
+  CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
     ON DELETE SET NULL ON UPDATE SET NULL,
-  CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) 
+  CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
     ON DELETE SET NULL ON UPDATE SET NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1541,14 +1401,14 @@ CREATE TABLE `old_reserves` (
 --
 
 DROP TABLE IF EXISTS `opac_news`;
-CREATE TABLE `opac_news` (
-  `idnew` int(10) unsigned NOT NULL auto_increment,
-  `title` varchar(250) NOT NULL default '',
-  `new` text NOT NULL,
-  `lang` varchar(25) NOT NULL default '',
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
-  `expirationdate` date default NULL,
-  `number` int(11) default NULL,
+CREATE TABLE `opac_news` ( -- data from the news tool
+  `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
+  `title` varchar(250) NOT NULL default '', -- title of the news article
+  `new` text NOT NULL, -- the body of your news article
+  `lang` varchar(25) NOT NULL default '', -- location for the article (koha is the staff client, slip is the circulation receipt and language codes are for the opac)
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time
+  `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible
+  `number` int(11) default NULL, -- the order in which this article appears in that specific location
   PRIMARY KEY  (`idnew`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1557,18 +1417,18 @@ CREATE TABLE `opac_news` (
 --
 
 DROP TABLE IF EXISTS `overduerules`;
-CREATE TABLE `overduerules` (
-  `branchcode` varchar(10) NOT NULL default '',
-  `categorycode` varchar(10) NOT NULL default '',
-  `delay1` int(4) default 0,
-  `letter1` varchar(20) default NULL,
-  `debarred1` varchar(1) default 0,
-  `delay2` int(4) default 0,
-  `debarred2` varchar(1) default 0,
-  `letter2` varchar(20) default NULL,
-  `delay3` int(4) default 0,
-  `letter3` varchar(20) default NULL,
-  `debarred3` int(1) default 0,
+CREATE TABLE `overduerules` ( -- overdue notice status and triggers
+  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to define which branch this rule is for (if blank it's all libraries)
+  `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
+  `delay1` int(4) default NULL, -- number of days after the item is overdue that the first notice is sent
+  `letter1` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the first notice
+  `debarred1` varchar(1) default 0, -- is the patron restricted when the first notice is sent (1 for yes, 0 for no)
+  `delay2` int(4) default NULL, -- number of days after the item is overdue that the second notice is sent
+  `debarred2` varchar(1) default 0, -- is the patron restricted when the second notice is sent (1 for yes, 0 for no)
+  `letter2` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the second notice
+  `delay3` int(4) default NULL, -- number of days after the item is overdue that the third notice is sent
+  `letter3` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the third notice
+  `debarred3` int(1) default 0, -- is the patron restricted when the third notice is sent (1 for yes, 0 for no)
   PRIMARY KEY  (`branchcode`,`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1618,18 +1478,18 @@ CREATE TABLE `printers` (
 
 DROP TABLE IF EXISTS `printers_profile`;
 CREATE TABLE `printers_profile` (
-  `prof_id` int(4) NOT NULL auto_increment,
-  `printername` varchar(40) NOT NULL,
-  `tmpl_id` int(4) NOT NULL,
-  `paper_bin` varchar(20) NOT NULL,
-  `offset_horz` float default NULL,
-  `offset_vert` float default NULL,
-  `creep_horz` float default NULL,
-  `creep_vert` float default NULL,
-  `unit` char(20) NOT NULL default 'POINT',
-  PRIMARY KEY  (`prof_id`),
-  UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
-  CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
+  `profile_id` int(4) NOT NULL auto_increment,
+  `printer_name` varchar(40) NOT NULL default 'Default Printer',
+  `template_id` int(4) NOT NULL default '0',
+  `paper_bin` varchar(20) NOT NULL default 'Bypass',
+  `offset_horz` float NOT NULL default '0',
+  `offset_vert` float NOT NULL default '0',
+  `creep_horz` float NOT NULL default '0',
+  `creep_vert` float NOT NULL default '0',
+  `units` char(20) NOT NULL default 'POINT',
+  `creator` char(15) NOT NULL DEFAULT 'Labels',
+  PRIMARY KEY  (`profile_id`),
+  UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`,`creator`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
@@ -1650,7 +1510,7 @@ CREATE TABLE `repeatable_holidays` (
 
 --
 -- Table structure for table `reports_dictionary`
--- 
+--
 
 DROP TABLE IF EXISTS `reports_dictionary`;
 CREATE TABLE reports_dictionary (
@@ -1697,6 +1557,9 @@ CREATE TABLE `reserves` (
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   `itemnumber` int(11) default NULL,
   `waitingdate` date default NULL,
+  `expirationdate` DATE DEFAULT NULL,
+  `lowestPriority` tinyint(1) NOT NULL,
+  KEY priorityfoundidx (priority,found),
   KEY `borrowernumber` (`borrowernumber`),
   KEY `biblionumber` (`biblionumber`),
   KEY `itemnumber` (`itemnumber`),
@@ -1712,13 +1575,13 @@ CREATE TABLE `reserves` (
 --
 
 DROP TABLE IF EXISTS `reviews`;
-CREATE TABLE `reviews` (
-  `reviewid` int(11) NOT NULL auto_increment,
-  `borrowernumber` int(11) default NULL,
-  `biblionumber` int(11) default NULL,
-  `review` text,
-  `approved` tinyint(4) default NULL,
-  `datereviewed` datetime default NULL,
+CREATE TABLE `reviews` ( -- patron opac comments
+  `reviewid` int(11) NOT NULL auto_increment, -- unique identifier for this comment
+  `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron left this comment
+  `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bibliographic record this comment is for
+  `review` text, -- the body of the comment
+  `approved` tinyint(4) default NULL, -- whether this comment has been approved by a librarian (1 for yes, 0 for no)
+  `datereviewed` datetime default NULL, -- the date the comment was left
   PRIMARY KEY  (`reviewid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1727,9 +1590,9 @@ CREATE TABLE `reviews` (
 --
 
 DROP TABLE IF EXISTS `roadtype`;
-CREATE TABLE `roadtype` (
-  `roadtypeid` int(11) NOT NULL auto_increment,
-  `road_type` varchar(100) NOT NULL default '',
+CREATE TABLE `roadtype` ( -- road types defined in administration and used in patron management
+  `roadtypeid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha for each road type
+  `road_type` varchar(100) NOT NULL default '', -- text for road type
   PRIMARY KEY  (`roadtypeid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1765,8 +1628,25 @@ CREATE TABLE saved_reports (
    `date_run` datetime default NULL,
    PRIMARY KEY  (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-                  
-                  
+
+
+--
+-- Table structure for table `search_history`
+--
+
+DROP TABLE IF EXISTS `search_history`;
+CREATE TABLE IF NOT EXISTS `search_history` (
+  `userid` int(11) NOT NULL,
+  `sessionid` varchar(32) NOT NULL,
+  `query_desc` varchar(255) NOT NULL,
+  `query_cgi` varchar(255) NOT NULL,
+  `total` int(11) NOT NULL,
+  `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  KEY `userid` (`userid`),
+  KEY `sessionid` (`sessionid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
+
+
 --
 -- Table structure for table `serial`
 --
@@ -1791,7 +1671,7 @@ CREATE TABLE `serial` (
 -- Table structure for table `sessions`
 --
 
-DROP TABLE IF EXISTS sessions;                         
+DROP TABLE IF EXISTS sessions;
 CREATE TABLE sessions (
   `id` varchar(32) NOT NULL,
   `a_session` text NOT NULL,
@@ -1820,17 +1700,17 @@ CREATE TABLE `special_holidays` (
 --
 
 DROP TABLE IF EXISTS `statistics`;
-CREATE TABLE `statistics` (
-  `datetime` datetime default NULL,
-  `branch` varchar(10) default NULL,
-  `proccode` varchar(4) default NULL,
-  `value` double(16,4) default NULL,
-  `type` varchar(16) default NULL,
+CREATE TABLE `statistics` ( -- information related to transactions (circulation and fines) in Koha
+  `datetime` datetime default NULL, -- date and time of the transaction
+  `branch` varchar(10) default NULL, -- foreign key, branch where the transaction occurred
+  `proccode` varchar(4) default NULL, -- proceedure code 
+  `value` double(16,4) default NULL, -- monetary value associated with the transaction
+  `type` varchar(16) default NULL, -- transaction type (locause, issue, return, renew, writeoff, payment, Credit*)
   `other` mediumtext,
   `usercode` varchar(10) default NULL,
-  `itemnumber` int(11) default NULL,
-  `itemtype` varchar(10) default NULL,
-  `borrowernumber` int(11) default NULL,
+  `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
+  `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
+  `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
   `associatedborrower` int(11) default NULL,
   KEY `timeidx` (`datetime`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -1892,12 +1772,15 @@ CREATE TABLE `subscription` (
   `distributedto` text,
   `internalnotes` longtext,
   `callnumber` text,
+  `location` varchar(80) NULL default '',
   `branchcode` varchar(10) NOT NULL default '',
   `hemisphere` tinyint(3) default 0,
   `lastbranch` varchar(10),
   `serialsadditems` tinyint(1) NOT NULL default '0',
   `staffdisplaycount` VARCHAR(10) NULL,
   `opacdisplaycount` VARCHAR(10) NULL,
+  `graceperiod` int(11) NOT NULL default '0',
+  `enddate` date default NULL,
   PRIMARY KEY  (`subscriptionid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1910,7 +1793,7 @@ CREATE TABLE `subscriptionhistory` (
   `biblionumber` int(11) NOT NULL default 0,
   `subscriptionid` int(11) NOT NULL default 0,
   `histstartdate` date default NULL,
-  `enddate` date default NULL,
+  `histenddate` date default NULL,
   `missinglist` longtext NOT NULL,
   `recievedlist` longtext NOT NULL,
   `opacnote` varchar(150) NOT NULL default '',
@@ -1926,10 +1809,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;
 
 --
@@ -1940,7 +1828,13 @@ DROP TABLE IF EXISTS `suggestions`;
 CREATE TABLE `suggestions` (
   `suggestionid` int(8) NOT NULL auto_increment,
   `suggestedby` int(11) NOT NULL default 0,
+  `suggesteddate` date NOT NULL default 0,
   `managedby` int(11) default NULL,
+  `manageddate` date default NULL,
+   acceptedby INT(11) default NULL,
+   accepteddate date default NULL,
+   rejectedby INT(11) default NULL,
+   rejecteddate date default NULL,
   `STATUS` varchar(10) NOT NULL default '',
   `note` mediumtext,
   `author` varchar(80) default NULL,
@@ -1955,6 +1849,14 @@ CREATE TABLE `suggestions` (
   `mailoverseeing` smallint(1) default 0,
   `biblionumber` int(11) default NULL,
   `reason` text,
+   budgetid INT(11),
+   branchcode VARCHAR(10) default NULL,
+   collectiontitle text default NULL,
+   itemtype VARCHAR(30) default NULL,
+       quantity SMALLINT(6) default NULL,
+       currency VARCHAR(3) default NULL,
+       price DECIMAL(28,6) default NULL,
+       total DECIMAL(28,6) default NULL,
   PRIMARY KEY  (`suggestionid`),
   KEY `suggestedby` (`suggestedby`),
   KEY `managedby` (`managedby`)
@@ -1965,12 +1867,12 @@ CREATE TABLE `suggestions` (
 --
 
 DROP TABLE IF EXISTS `systempreferences`;
-CREATE TABLE `systempreferences` (
-  `variable` varchar(50) NOT NULL default '',
-  `value` text,
-  `options` mediumtext,
-  `explanation` text,
-  `type` varchar(20) default NULL,
+CREATE TABLE `systempreferences` ( -- global system preferences
+  `variable` varchar(50) NOT NULL default '', -- system preference name
+  `value` text, -- system preference values
+  `options` mediumtext, -- options for multiple choice system preferences
+  `explanation` text, -- descriptive text for the system preference
+  `type` varchar(20) default NULL, -- type of question this preference asks (multiple choice, plain text, yes or no, etc)
   PRIMARY KEY  (`variable`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -2115,7 +2017,7 @@ CREATE TABLE `z3950servers` (
 DROP TABLE IF EXISTS `zebraqueue`;
 CREATE TABLE `zebraqueue` (
   `id` int(11) NOT NULL auto_increment,
-  `biblio_auth_number` int(11) NOT NULL default '0',
+  `biblio_auth_number` bigint(20) unsigned NOT NULL default '0',
   `operation` char(20) NOT NULL default '',
   `server` char(20) NOT NULL default '',
   `done` int(11) NOT NULL default '0',
@@ -2124,6 +2026,10 @@ CREATE TABLE `zebraqueue` (
   KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `services_throttle`
+--
+
 DROP TABLE IF EXISTS `services_throttle`;
 CREATE TABLE `services_throttle` (
   `service_type` varchar(10) NOT NULL default '',
@@ -2131,38 +2037,60 @@ CREATE TABLE `services_throttle` (
   PRIMARY KEY  (`service_type`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `language_subtag_registry`
 -- http://www.w3.org/International/articles/language-tags/
-
 -- RFC4646
+--
+
 DROP TABLE IF EXISTS language_subtag_registry;
 CREATE TABLE language_subtag_registry (
         subtag varchar(25),
         type varchar(25), -- language-script-region-variant-extension-privateuse
         description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
         added date,
+        id int(11) NOT NULL auto_increment,
+        PRIMARY KEY  (`id`),
         KEY `subtag` (`subtag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `language_rfc4646_to_iso639`
 -- TODO: add suppress_scripts
 -- this maps three letter codes defined in iso639.2 back to their
 -- two letter equivilents in rfc4646 (LOC maintains iso639+)
+--
+
 DROP TABLE IF EXISTS language_rfc4646_to_iso639;
 CREATE TABLE language_rfc4646_to_iso639 (
         rfc4646_subtag varchar(25),
         iso639_2_code varchar(25),
+        id int(11) NOT NULL auto_increment,
+        PRIMARY KEY  (`id`),
         KEY `rfc4646_subtag` (`rfc4646_subtag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `language_descriptions`
+--
+
 DROP TABLE IF EXISTS language_descriptions;
 CREATE TABLE language_descriptions (
         subtag varchar(25),
         type varchar(25),
         lang varchar(25),
         description varchar(255),
-        KEY `lang` (`lang`)
+        id int(11) NOT NULL auto_increment,
+        PRIMARY KEY  (`id`),
+        KEY `lang` (`lang`),
+        KEY `subtag_type_lang` (`subtag`, `type`, `lang`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `language_script_bidi`
 -- bi-directional support, keyed by script subcode
+--
+
 DROP TABLE IF EXISTS language_script_bidi;
 CREATE TABLE language_script_bidi (
         rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
@@ -2170,8 +2098,12 @@ CREATE TABLE language_script_bidi (
         KEY `rfc4646_subtag` (`rfc4646_subtag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `language_script_mapping`
 -- TODO: need to map language subtags to script subtags for detection
 -- of bidi when script is not specified (like ar, he)
+--
+
 DROP TABLE IF EXISTS language_script_mapping;
 CREATE TABLE language_script_mapping (
         language_subtag varchar(25),
@@ -2179,6 +2111,10 @@ CREATE TABLE language_script_mapping (
         KEY `language_subtag` (`language_subtag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `permissions`
+--
+
 DROP TABLE IF EXISTS `permissions`;
 CREATE TABLE `permissions` (
   `module_bit` int(11) NOT NULL DEFAULT 0,
@@ -2189,15 +2125,24 @@ CREATE TABLE `permissions` (
     ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `serialitems`
+--
+
 DROP TABLE IF EXISTS `serialitems`;
 CREATE TABLE `serialitems` (
        `itemnumber` int(11) NOT NULL,
        `serialid` int(11) NOT NULL,
        UNIQUE KEY `serialitemsidx` (`itemnumber`),
        KEY `serialitems_sfk_1` (`serialid`),
-       CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE
+       CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
+       CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-                 
+
+--
+-- Table structure for table `user_permissions`
+--
+
 DROP TABLE IF EXISTS `user_permissions`;
 CREATE TABLE `user_permissions` (
   `borrowernumber` int(11) NOT NULL DEFAULT 0,
@@ -2225,7 +2170,7 @@ CREATE TABLE `tmp_holdsqueue` (
   `cardnumber` varchar(16) default NULL,
   `reservedate` date default NULL,
   `title` mediumtext,
-  `itemcallnumber` varchar(30) default NULL,
+  `itemcallnumber` varchar(255) default NULL,
   `holdingbranch` varchar(10) default NULL,
   `pickbranch` varchar(10) default NULL,
   `notes` text,
@@ -2274,7 +2219,7 @@ CREATE TABLE `message_transport_types` (
 DROP TABLE IF EXISTS `message_attributes`;
 CREATE TABLE `message_attributes` (
   `message_attribute_id` int(11) NOT NULL auto_increment,
-  `message_name` varchar(20) NOT NULL default '',
+  `message_name` varchar(40) NOT NULL default '',
   `takes_days` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`message_attribute_id`),
   UNIQUE KEY `message_name` (`message_name`)
@@ -2306,15 +2251,18 @@ CREATE TABLE `message_transports` (
 DROP TABLE IF EXISTS `borrower_message_preferences`;
 CREATE TABLE `borrower_message_preferences` (
   `borrower_message_preference_id` int(11) NOT NULL auto_increment,
-  `borrowernumber` int(11) NOT NULL default '0',
+  `borrowernumber` int(11) default NULL,
+  `categorycode` varchar(10) default NULL,
   `message_attribute_id` int(11) default '0',
   `days_in_advance` int(11) default '0',
   `wants_digest` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`borrower_message_preference_id`),
   KEY `borrowernumber` (`borrowernumber`),
+  KEY `categorycode` (`categorycode`),
   KEY `message_attribute_id` (`message_attribute_id`),
   CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
+  CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 --
@@ -2338,10 +2286,10 @@ CREATE TABLE `borrower_message_transport_preferences` (
 DROP TABLE IF EXISTS `branch_transfer_limits`;
 CREATE TABLE branch_transfer_limits (
     limitId int(8) NOT NULL auto_increment,
-    toBranch varchar(4) NOT NULL,
-    fromBranch varchar(4) NOT NULL,
-    itemtype varchar(4) NULL,
-    ccode varchar(10) NULL,  
+    toBranch varchar(10) NOT NULL,
+    fromBranch varchar(10) NOT NULL,
+    itemtype varchar(10) NULL,
+    ccode varchar(10) NULL,
     PRIMARY KEY  (limitId)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -2360,6 +2308,351 @@ CREATE TABLE `item_circulation_alert_preferences` (
   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`, `notification`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+--
+-- Table structure for table `messages`
+--
+DROP TABLE IF EXISTS `messages`;
+CREATE TABLE `messages` (
+  `message_id` int(11) NOT NULL auto_increment,
+  `borrowernumber` int(11) NOT NULL,
+  `branchcode` varchar(10) default NULL,
+  `message_type` varchar(1) NOT NULL,
+  `message` text NOT NULL,
+  `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`message_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `accountlines`
+--
+
+DROP TABLE IF EXISTS `accountlines`;
+CREATE TABLE `accountlines` (
+  `borrowernumber` int(11) NOT NULL default 0,
+  `accountno` smallint(6) NOT NULL default 0,
+  `itemnumber` int(11) default NULL,
+  `date` date default NULL,
+  `amount` decimal(28,6) default NULL,
+  `description` mediumtext,
+  `dispute` mediumtext,
+  `accounttype` varchar(5) default NULL,
+  `amountoutstanding` decimal(28,6) default NULL,
+  `lastincrement` decimal(28,6) default NULL,
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `notify_id` int(11) NOT NULL default 0,
+  `notify_level` int(2) NOT NULL default 0,
+  `note` text NULL default NULL,
+  `manager_id` int(11) NULL,
+  KEY `acctsborridx` (`borrowernumber`),
+  KEY `timeidx` (`timestamp`),
+  KEY `itemnumber` (`itemnumber`),
+  CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `accountoffsets`
+--
+
+DROP TABLE IF EXISTS `accountoffsets`;
+CREATE TABLE `accountoffsets` (
+  `borrowernumber` int(11) NOT NULL default 0,
+  `accountno` smallint(6) NOT NULL default 0,
+  `offsetaccount` smallint(6) NOT NULL default 0,
+  `offsetamount` decimal(28,6) default NULL,
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `action_logs`
+--
+
+DROP TABLE IF EXISTS `action_logs`;
+CREATE TABLE `action_logs` (
+  `action_id` int(11) NOT NULL auto_increment,
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `user` int(11) NOT NULL default 0,
+  `module` text,
+  `action` text,
+  `object` int(11) default NULL,
+  `info` text,
+  PRIMARY KEY (`action_id`),
+  KEY  (`timestamp`,`user`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `alert`
+--
+
+DROP TABLE IF EXISTS `alert`;
+CREATE TABLE `alert` (
+  `alertid` int(11) NOT NULL auto_increment,
+  `borrowernumber` int(11) NOT NULL default 0,
+  `type` varchar(10) NOT NULL default '',
+  `externalid` varchar(20) NOT NULL default '',
+  PRIMARY KEY  (`alertid`),
+  KEY `borrowernumber` (`borrowernumber`),
+  KEY `type` (`type`,`externalid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `aqbasketgroups`
+--
+
+DROP TABLE IF EXISTS `aqbasketgroups`;
+CREATE TABLE `aqbasketgroups` (
+  `id` int(11) NOT NULL auto_increment,
+  `name` varchar(50) default NULL,
+  `closed` tinyint(1) default NULL,
+  `booksellerid` int(11) NOT NULL,
+  `deliveryplace` varchar(10) default NULL,
+  `freedeliveryplace` text default NULL,
+  `deliverycomment` varchar(255) default NULL,
+  `billingplace` varchar(10) default NULL,
+  PRIMARY KEY  (`id`),
+  KEY `booksellerid` (`booksellerid`),
+  CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `aqbasket`
+--
+
+DROP TABLE IF EXISTS `aqbasket`;
+CREATE TABLE `aqbasket` (
+  `basketno` int(11) NOT NULL auto_increment,
+  `basketname` varchar(50) default NULL,
+  `note` mediumtext,
+  `booksellernote` mediumtext,
+  `contractnumber` int(11),
+  `creationdate` date default NULL,
+  `closedate` date default NULL,
+  `booksellerid` int(11) NOT NULL default 1,
+  `authorisedby` varchar(10) default NULL,
+  `booksellerinvoicenumber` mediumtext,
+  `basketgroupid` int(11),
+  PRIMARY KEY  (`basketno`),
+  KEY `booksellerid` (`booksellerid`),
+  KEY `basketgroupid` (`basketgroupid`),
+  KEY `contractnumber` (`contractnumber`),
+  CONSTRAINT `aqbasket_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE,
+  CONSTRAINT `aqbasket_ibfk_2` FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`),
+  CONSTRAINT `aqbasket_ibfk_3` FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `aqbooksellers`
+--
+
+DROP TABLE IF EXISTS `aqbooksellers`;
+CREATE TABLE `aqbooksellers` (
+  `id` int(11) NOT NULL auto_increment,
+  `name` mediumtext NOT NULL,
+  `address1` mediumtext,
+  `address2` mediumtext,
+  `address3` mediumtext,
+  `address4` mediumtext,
+  `phone` varchar(30) default NULL,
+  `accountnumber` mediumtext,
+  `othersupplier` mediumtext,
+  `currency` varchar(3) NOT NULL default '',
+  `booksellerfax` mediumtext,
+  `notes` mediumtext,
+  `bookselleremail` mediumtext,
+  `booksellerurl` mediumtext,
+  `contact` varchar(100) default NULL,
+  `postal` mediumtext,
+  `url` varchar(255) default NULL,
+  `contpos` varchar(100) default NULL,
+  `contphone` varchar(100) default NULL,
+  `contfax` varchar(100) default NULL,
+  `contaltphone` varchar(100) default NULL,
+  `contemail` varchar(100) default NULL,
+  `contnotes` mediumtext,
+  `active` tinyint(4) default NULL,
+  `listprice` varchar(10) default NULL,
+  `invoiceprice` varchar(10) default NULL,
+  `gstreg` tinyint(4) default NULL,
+  `listincgst` tinyint(4) default NULL,
+  `invoiceincgst` tinyint(4) default NULL,
+  `gstrate` decimal(6,4) default NULL,
+  `discount` float(6,4) default NULL,
+  `fax` varchar(50) default NULL,
+  PRIMARY KEY  (`id`),
+  KEY `listprice` (`listprice`),
+  KEY `invoiceprice` (`invoiceprice`),
+  CONSTRAINT `aqbooksellers_ibfk_1` FOREIGN KEY (`listprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `aqbooksellers_ibfk_2` FOREIGN KEY (`invoiceprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `aqbudgets`
+--
+
+DROP TABLE IF EXISTS `aqbudgets`;
+CREATE TABLE `aqbudgets` (
+  `budget_id` int(11) NOT NULL auto_increment,
+  `budget_parent_id` int(11) default NULL,
+  `budget_code` varchar(30) default NULL,
+  `budget_name` varchar(80) default NULL,
+  `budget_branchcode` varchar(10) default NULL,
+  `budget_amount` decimal(28,6) NULL default '0.00',
+  `budget_encumb` decimal(28,6) NULL default '0.00',
+  `budget_expend` decimal(28,6) NULL default '0.00',
+  `budget_notes` mediumtext,
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `budget_period_id` int(11) default NULL,
+  `sort1_authcat` varchar(80) default NULL,
+  `sort2_authcat` varchar(80) default NULL,
+  `budget_owner_id` int(11) default NULL,
+  `budget_permission` int(1) default '0',
+  PRIMARY KEY  (`budget_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+--
+-- Table structure for table `aqbudgetperiods`
+--
+
+
+DROP TABLE IF EXISTS `aqbudgetperiods`;
+CREATE TABLE `aqbudgetperiods` (
+  `budget_period_id` int(11) NOT NULL auto_increment,
+  `budget_period_startdate` date NOT NULL,
+  `budget_period_enddate` date NOT NULL,
+  `budget_period_active` tinyint(1) default '0',
+  `budget_period_description` mediumtext,
+  `budget_period_total` decimal(28,6),
+  `budget_period_locked` tinyint(1) default NULL,
+  `sort1_authcat` varchar(10) default NULL,
+  `sort2_authcat` varchar(10) default NULL,
+  PRIMARY KEY  (`budget_period_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `aqbudgets_planning`
+--
+
+DROP TABLE IF EXISTS `aqbudgets_planning`;
+CREATE TABLE `aqbudgets_planning` (
+  `plan_id` int(11) NOT NULL auto_increment,
+  `budget_id` int(11) NOT NULL,
+  `budget_period_id` int(11) NOT NULL,
+  `estimated_amount` decimal(28,6) default NULL,
+  `authcat` varchar(30) NOT NULL,
+  `authvalue` varchar(30) NOT NULL,
+  `display` tinyint(1) DEFAULT 1,
+  PRIMARY KEY  (`plan_id`),
+  CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table 'aqcontract'
+--
+
+DROP TABLE IF EXISTS `aqcontract`;
+CREATE TABLE `aqcontract` (
+  `contractnumber` int(11) NOT NULL auto_increment,
+  `contractstartdate` date default NULL,
+  `contractenddate` date default NULL,
+  `contractname` varchar(50) default NULL,
+  `contractdescription` mediumtext,
+  `booksellerid` int(11) not NULL,
+  PRIMARY KEY  (`contractnumber`),
+  CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
+       REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+--
+-- Table structure for table `aqorderdelivery`
+--
+
+DROP TABLE IF EXISTS `aqorderdelivery`;
+CREATE TABLE `aqorderdelivery` (
+  `ordernumber` date default NULL,
+  `deliverynumber` smallint(6) NOT NULL default 0,
+  `deliverydate` varchar(18) default NULL,
+  `qtydelivered` smallint(6) default NULL,
+  `deliverycomments` mediumtext
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `aqorders`
+--
+
+DROP TABLE IF EXISTS `aqorders`;
+CREATE TABLE `aqorders` (
+  `ordernumber` int(11) NOT NULL auto_increment,
+  `biblionumber` int(11) default NULL,
+  `entrydate` date default NULL,
+  `quantity` smallint(6) default NULL,
+  `currency` varchar(3) default NULL,
+  `listprice` decimal(28,6) default NULL,
+  `totalamount` decimal(28,6) default NULL,
+  `datereceived` date default NULL,
+  `booksellerinvoicenumber` mediumtext,
+  `freight` decimal(28,6) default NULL,
+  `unitprice` decimal(28,6) default NULL,
+  `quantityreceived` smallint(6) NOT NULL default 0,
+  `cancelledby` varchar(10) default NULL,
+  `datecancellationprinted` date default NULL,
+  `notes` mediumtext,
+  `supplierreference` mediumtext,
+  `purchaseordernumber` mediumtext,
+  `subscription` tinyint(1) default NULL,
+  `serialid` varchar(30) default NULL,
+  `basketno` int(11) default NULL,
+  `biblioitemnumber` int(11) default NULL,
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `rrp` decimal(13,2) default NULL,
+  `ecost` decimal(13,2) default NULL,
+  `gst` decimal(13,2) default NULL,
+  `budget_id` int(11) NOT NULL,
+  `budgetgroup_id` int(11) NOT NULL,
+  `budgetdate` date default NULL,
+  `sort1` varchar(80) default NULL,
+  `sort2` varchar(80) default NULL,
+  `sort1_authcat` varchar(10) default NULL,
+  `sort2_authcat` varchar(10) default NULL,
+  `uncertainprice` tinyint(1),
+  PRIMARY KEY  (`ordernumber`),
+  KEY `basketno` (`basketno`),
+  KEY `biblionumber` (`biblionumber`),
+  KEY `budget_id` (`budget_id`),
+  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+--
+-- Table structure for table `aqorders_items`
+--
+
+DROP TABLE IF EXISTS `aqorders_items`;
+CREATE TABLE `aqorders_items` (
+  `ordernumber` int(11) NOT NULL,
+  `itemnumber` int(11) NOT NULL,
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  PRIMARY KEY  (`itemnumber`),
+  KEY `ordernumber` (`ordernumber`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table structure for table `fieldmapping`
+--
+
+DROP TABLE IF EXISTS `fieldmapping`;
+CREATE TABLE `fieldmapping` (
+  `id` int(11) NOT NULL auto_increment,
+  `field` varchar(255) NOT NULL,
+  `frameworkcode` char(4) NOT NULL default '',
+  `fieldcode` char(3) NOT NULL,
+  `subfieldcode` char(1) NOT NULL,
+  PRIMARY KEY  (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;