Bug 15685: Allow creation of items (AcqCreateItem) to be customizable per-basket
[koha.git] / installer / data / mysql / kohastructure.sql
index a4d6c39..14c82e7 100644 (file)
@@ -34,6 +34,19 @@ CREATE TABLE `auth_header` (
   KEY `origincode` (`origincode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
+--
+-- Table structure for table `auth_types`
+--
+
+DROP TABLE IF EXISTS `auth_types`;
+CREATE TABLE `auth_types` (
+  `authtypecode` varchar(10) NOT NULL default '',
+  `authtypetext` varchar(255) NOT NULL default '',
+  `auth_tag_to_report` varchar(3) NOT NULL default '',
+  `summary` mediumtext NOT NULL,
+  PRIMARY KEY  (`authtypecode`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
 --
 -- Table structure for table `auth_subfield_structure`
 --
@@ -56,7 +69,7 @@ CREATE TABLE `auth_subfield_structure` (
   `linkid` tinyint(1) NOT NULL default 0,
   `kohafield` varchar(45) NULL default '',
   `frameworkcode` varchar(10) NOT NULL default '',
-  `defaultvalue` TEXT DEFAULT '',
+  `defaultvalue` TEXT,
   PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
   KEY `tab` (`authtypecode`,`tab`),
   CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
@@ -79,17 +92,15 @@ CREATE TABLE `auth_tag_structure` (
   CONSTRAINT `auth_tag_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
+
 --
--- Table structure for table `auth_types`
+-- Table structure for table `authorised_value_categories`
 --
 
-DROP TABLE IF EXISTS `auth_types`;
-CREATE TABLE `auth_types` (
-  `authtypecode` varchar(10) NOT NULL default '',
-  `authtypetext` varchar(255) NOT NULL default '',
-  `auth_tag_to_report` varchar(3) NOT NULL default '',
-  `summary` mediumtext NOT NULL,
-  PRIMARY KEY  (`authtypecode`)
+DROP TABLE IF EXISTS `authorised_value_categories`;
+CREATE TABLE `authorised_value_categories` (
+  `category_name` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
+  PRIMARY KEY (`category_name`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -107,7 +118,8 @@ CREATE TABLE `authorised_values` ( -- stores values for authorized values catego
   PRIMARY KEY  (`id`),
   KEY `name` (`category`),
   KEY `lib` (`lib`),
-  KEY `auth_value_idx` (`authorised_value`)
+  KEY `auth_value_idx` (`authorised_value`),
+  CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -156,7 +168,7 @@ CREATE TABLE `biblioitems` ( -- information related to bibliographic records in
   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
   `isbn` mediumtext, -- ISBN (MARC21 020$a)
   `issn` mediumtext, -- ISSN (MARC21 022$a)
-  `ean` varchar(13) default NULL,
+  `ean` mediumtext default NULL,
   `publicationyear` text,
   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
   `volumedate` date default NULL,
@@ -173,7 +185,6 @@ CREATE TABLE `biblioitems` ( -- information related to bibliographic records in
   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
-  `marc` longblob, -- full bibliographic MARC record
   `url` text default NULL, -- url (MARC21 856$u)
   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
   `cn_class` varchar(30) default NULL,
@@ -182,105 +193,18 @@ CREATE TABLE `biblioitems` ( -- information related to bibliographic records in
   `cn_sort` varchar(255) default NULL, -- normalized version of the call number used for sorting
   `agerestriction` varchar(255) default NULL, -- target audience/age restriction from the bib record (MARC21 521$a)
   `totalissues` int(10),
-  `marcxml` longtext, -- full bibliographic MARC record in MARCXML
   PRIMARY KEY  (`biblioitemnumber`),
   KEY `bibinoidx` (`biblioitemnumber`),
   KEY `bibnoidx` (`biblionumber`),
   KEY `itemtype_idx` (`itemtype`),
   KEY `isbn` (`isbn`(255)),
   KEY `issn` (`issn`(255)),
+  KEY `ean` (`ean`(255)),
   KEY `publishercode` (`publishercode`),
+  KEY `timestamp` (`timestamp`),
   CONSTRAINT `biblioitems_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `borrowers`
---
-
-DROP TABLE IF EXISTS `borrowers`;
-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` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)
-  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
-  `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/borrower's account that is only visible in the staff client
-  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
-  `sex` varchar(1) default NULL, -- patron/borrower's gender
-  `password` varchar(60) default NULL, -- patron/borrower's encrypted password
-  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
-  `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
-  `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
-  `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 city for the alternate contact for the patron/borrower
-  `altcontactstate` text default NULL, -- the 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)
-  `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
-  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
-  `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
-  UNIQUE KEY `cardnumber` (`cardnumber`),
-  PRIMARY KEY `borrowernumber` (`borrowernumber`),
-  KEY `categorycode` (`categorycode`),
-  KEY `branchcode` (`branchcode`),
-  UNIQUE KEY `userid` (`userid`),
-  KEY `guarantorid` (`guarantorid`),
-  KEY `surname_idx` (`surname`(255)),
-  KEY `firstname_idx` (`firstname`(255)),
-  KEY `othernames_idx` (`othernames`(255)),
-  KEY `sms_provider_id` (`sms_provider_id`),
-  CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
-  CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`),
-  CONSTRAINT `borrowers_ibfk_3` FOREIGN KEY (`sms_provider_id`) REFERENCES `sms_providers` (`id`) ON UPDATE CASCADE ON DELETE SET NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `borrower_attribute_types`
 --
@@ -292,6 +216,7 @@ CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron 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)
+  `opac_editable` tinyint(1) NOT NULL default 0, -- defines if this field is editable by patrons on their account in the OPAC (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(32) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
   `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
@@ -301,63 +226,6 @@ CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron field
   KEY `auth_val_cat_idx` (`authorised_value_category`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `borrower_attributes`
---
-
-DROP TABLE IF EXISTS `borrower_attributes`;
-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(255) default NULL, -- custom patron field value
-  KEY `borrowernumber` (`borrowernumber`),
-  KEY `code_attribute` (`code`, `attribute`),
-  CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
-    ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `borrower_debarments`
---
-
-DROP TABLE IF EXISTS `borrower_debarments`;
-CREATE TABLE borrower_debarments ( -- tracks restrictions on the patron's record
-  borrower_debarment_id int(11) NOT NULL AUTO_INCREMENT, -- unique key for the restriction
-  borrowernumber int(11) NOT NULL, -- foreign key for borrowers.borrowernumber for patron who is restricted
-  expiration date DEFAULT NULL, -- expiration date of the restriction
-  `type` enum('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL', -- type of restriction
-  `comment` text, -- comments about the restriction
-  manager_id int(11) DEFAULT NULL, -- foreign key for borrowers.borrowernumber for the librarian managing the restriction
-  created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date the restriction was added
-  updated timestamp NULL DEFAULT NULL, -- date the restriction was updated
-  PRIMARY KEY (borrower_debarment_id),
-  KEY borrowernumber (borrowernumber),
-  CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-
---
--- Table structure for table `branch_item_rules`
---
-
-DROP TABLE IF EXISTS `branch_item_rules`;
-CREATE TABLE `branch_item_rules` ( -- information entered in the circulation and fine rules under 'Holds policy by item type'
-  `branchcode` varchar(10) NOT NULL, -- the branch this rule is for (branches.branchcode)
-  `itemtype` varchar(10) NOT NULL, -- the item type this rule applies to (items.itype)
-  `holdallowed` tinyint(1) default NULL, -- the number of holds allowed
-  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
-  `returnbranch` varchar(15) default NULL, -- the branch the item returns to (homebranch, holdingbranch, noreturn)
-  PRIMARY KEY  (`itemtype`,`branchcode`),
-  KEY `branch_item_rules_ibfk_2` (`branchcode`),
-  CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
-    ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `borrower_password_recovery`
 --
@@ -371,25 +239,6 @@ CREATE TABLE IF NOT EXISTS `borrower_password_recovery` ( -- holds information a
   KEY borrowernumber (borrowernumber)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table borrower_sync
---
-
-DROP TABLE IF EXISTS `borrower_sync`;
-CREATE TABLE borrower_sync (
-  borrowersyncid int(11) NOT NULL AUTO_INCREMENT, -- Primary key, unique identifier
-  borrowernumber int(11) NOT NULL, -- Connects data about synchronisations to a borrower
-  synctype varchar(32) NOT NULL, -- There could potentially be more than one kind of syncing going on, a text string here can be used to tell them apart. E.g.: The Norwegian national patron database uses 'norwegianpatrondb' in this column
-  sync tinyint(1) NOT NULL DEFAULT '0', -- A boolean (1/0) for turning syncing off and on for individual borrowers
-  syncstatus varchar(10) DEFAULT NULL, -- The sync status for any given borrower. Could be text strings like 'new', 'edited', 'synced' etc. The values used here will depend on the actual syncing being done.
-  lastsync varchar(50) DEFAULT NULL, -- Date of the last successfull sync. The date format might be different depending on the service that is being used, so no special date format is being enforced here.
-  hashed_pin varchar(64) DEFAULT NULL, -- Perhaps specific to The Norwegian national patron database, this column holds a hashed PIN code
-  PRIMARY KEY (borrowersyncid),
-  KEY borrowernumber (borrowernumber),
-  CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-
 --
 -- Table structure for table `branchcategories`
 --
@@ -431,6 +280,8 @@ CREATE TABLE `branches` ( -- information about your libraries or branches are st
   `branchprinter` varchar(100) default NULL, -- unused in Koha
   `branchnotes` mediumtext, -- notes related to your library or branch
   opac_info text, -- HTML that displays in OPAC
+  `geolocation` VARCHAR(255) default NULL, -- geolocation of your library
+  `marcorgcode` VARCHAR(16) default NULL, -- MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode
   PRIMARY KEY (`branchcode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
@@ -449,27 +300,6 @@ CREATE TABLE `branchrelations` ( -- this table links libraries/branches to group
   CONSTRAINT `branchrelations_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `branchcategories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `branchtransfers`
---
-
-DROP TABLE IF EXISTS `branchtransfers`;
-CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
-  `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
-  `datesent` datetime default NULL, -- the date the transfer was initialized
-  `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
-  `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
-  `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
-  `comments` mediumtext, -- any comments related to the transfer
-  KEY `frombranch` (`frombranch`),
-  KEY `tobranch` (`tobranch`),
-  KEY `itemnumber` (`itemnumber`),
-  CONSTRAINT `branchtransfers_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `branchtransfers_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-
 --
 -- Table structure for table `browser`
 --
@@ -504,6 +334,7 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr
   `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
   `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
   `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
+  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron category if this item has previously been checked out to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'.
   PRIMARY KEY  (`categorycode`),
   UNIQUE KEY `categorycode` (`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -529,6 +360,7 @@ ALTER TABLE `collections`
 --
 -- Table: collections_tracking
 --
+
 DROP TABLE IF EXISTS collections_tracking;
 CREATE TABLE collections_tracking (
   collections_tracking_id integer(11) NOT NULL auto_increment,
@@ -538,142 +370,38 @@ CREATE TABLE collections_tracking (
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `courses`
+-- Table structure for table `branch_borrower_circ_rules`
 --
 
--- The courses table stores the courses created for the
--- course reserves feature.
-
-DROP TABLE IF EXISTS courses;
-CREATE TABLE `courses` (
-  `course_id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the course
-  `department` varchar(80) DEFAULT NULL, -- the authorised value for the DEPARTMENT
-  `course_number` varchar(255) DEFAULT NULL, -- the "course number" assigned to a course
-  `section` varchar(255) DEFAULT NULL, -- the 'section' of a course
-  `course_name` varchar(255) DEFAULT NULL, -- the name of the course
-  `term` varchar(80) DEFAULT NULL, -- the authorised value for the TERM
-  `staff_note` mediumtext, -- the text of the staff only note
-  `public_note` mediumtext, -- the text of the public / opac note
-  `students_count` varchar(20) DEFAULT NULL, -- how many students will be taking this course/section
-  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes', -- determines whether the course is active
-  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-   PRIMARY KEY (`course_id`)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+DROP TABLE IF EXISTS `branch_borrower_circ_rules`;
+CREATE TABLE `branch_borrower_circ_rules` ( -- includes default circulation rules for patron categories found under "Checkout limit by patron category"
+  `branchcode` VARCHAR(10) NOT NULL, -- the branch this rule applies to (branches.branchcode)
+  `categorycode` VARCHAR(10) NOT NULL, -- the patron category this rule applies to (categories.categorycode)
+  `maxissueqty` int(4) default NULL, -- the maximum number of checkouts this patron category can have at this branch
+  `maxonsiteissueqty` int(4) default NULL, -- the maximum number of on-site checkouts this patron category can have at this branch
+  PRIMARY KEY (`categorycode`, `branchcode`),
+  CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
+    ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
+    ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `course_instructors`
+-- Table structure for table `default_borrower_circ_rules`
 --
 
--- The course instructors table links Koha borrowers to the
--- courses they are teaching. Many instructors can teach many
--- courses. course_instructors is just a many-to-many join table.
-
-DROP TABLE IF EXISTS course_instructors;
-CREATE TABLE `course_instructors` (
-  `course_id` int(11) NOT NULL, -- foreign key to link to courses.course_id
-  `borrowernumber` int(11) NOT NULL, -- foreign key to link to borrowers.borrowernumber for instructor information
-  PRIMARY KEY (`course_id`,`borrowernumber`),
-  KEY `borrowernumber` (`borrowernumber`)
+DROP TABLE IF EXISTS `default_borrower_circ_rules`;
+CREATE TABLE `default_borrower_circ_rules` ( -- default checkout rules found under "Default checkout, hold and return policy"
+  `categorycode` VARCHAR(10) NOT NULL, -- patron category this rul
+  `maxissueqty` int(4) default NULL,
+  `maxonsiteissueqty` int(4) default NULL,
+  PRIMARY KEY (`categorycode`),
+  CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
+    ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Constraints for table `course_instructors`
---
-ALTER TABLE `course_instructors`
-  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
-  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
-
---
--- Table structure for table `course_items`
---
-
--- If an item is placed on course reserve for one or more courses
--- it will have an entry in this table. No matter how many courses an item
--- is part of, it will only have one row in this table.
-
-DROP TABLE IF EXISTS course_items;
-CREATE TABLE `course_items` (
-  `ci_id` int(11) NOT NULL AUTO_INCREMENT, -- course item id
-  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
-  `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
-  `ccode` varchar(10) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
-  `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
-  `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
-  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- if at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
-  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-   PRIMARY KEY (`ci_id`),
-   UNIQUE KEY `itemnumber` (`itemnumber`),
-   KEY `holdingbranch` (`holdingbranch`)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Constraints for table `course_items`
---
-ALTER TABLE `course_items`
-  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
-  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
-
---
--- Table structure for table `course_reserves`
---
-
--- This table connects an item placed on course reserve to a course it is on reserve for.
--- There will be a row in this table for each course an item is on reserve for.
-
-DROP TABLE IF EXISTS course_reserves;
-CREATE TABLE `course_reserves` (
-  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
-  `course_id` int(11) NOT NULL, -- foreign key to link to courses.course_id
-  `ci_id` int(11) NOT NULL, -- foreign key to link to courses_items.ci_id
-  `staff_note` mediumtext, -- staff only note
-  `public_note` mediumtext, -- public, OPAC visible note
-  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-   PRIMARY KEY (`cr_id`),
-   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
-   KEY `course_id` (`course_id`)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Constraints for table `course_reserves`
---
-ALTER TABLE `course_reserves`
-  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
-  ADD CONSTRAINT `course_reserves_ibfk_2` FOREIGN KEY (`ci_id`) REFERENCES `course_items` (`ci_id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
-
---
--- Table structure for table `branch_borrower_circ_rules`
---
-
-DROP TABLE IF EXISTS `branch_borrower_circ_rules`;
-CREATE TABLE `branch_borrower_circ_rules` ( -- includes default circulation rules for patron categories found under "Checkout limit by patron category"
-  `branchcode` VARCHAR(10) NOT NULL, -- the branch this rule applies to (branches.branchcode)
-  `categorycode` VARCHAR(10) NOT NULL, -- the patron category this rule applies to (categories.categorycode)
-  `maxissueqty` int(4) default NULL, -- the maximum number of checkouts this patron category can have at this branch
-  `maxonsiteissueqty` int(4) default NULL, -- the maximum number of on-site checkouts this patron category can have at this branch
-  PRIMARY KEY (`categorycode`, `branchcode`),
-  CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
-    ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `default_borrower_circ_rules`
---
-
-DROP TABLE IF EXISTS `default_borrower_circ_rules`;
-CREATE TABLE `default_borrower_circ_rules` ( -- default checkout rules found under "Default checkout, hold and return policy"
-  `categorycode` VARCHAR(10) NOT NULL, -- patron category this rul
-  `maxissueqty` int(4) default NULL,
-  `maxonsiteissueqty` int(4) default NULL,
-  PRIMARY KEY (`categorycode`),
-  CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `default_branch_circ_rules`
+-- Table structure for table `default_branch_circ_rules`
 --
 
 DROP TABLE IF EXISTS `default_branch_circ_rules`;
@@ -689,20 +417,6 @@ CREATE TABLE `default_branch_circ_rules` (
     ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- 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,
-  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
-  `returnbranch` varchar(15) default NULL,
-  PRIMARY KEY  (`itemtype`),
-  CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `default_circ_rules`
 --
@@ -812,7 +526,7 @@ CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records t
   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
   `isbn` mediumtext default NULL, -- ISBN (MARC21 020$a)
   `issn` mediumtext default NULL, -- ISSN (MARC21 022$a)
-  `ean` varchar(13) default NULL,
+  `ean` mediumtext default NULL,
   `publicationyear` text,
   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
   `volumedate` date default NULL,
@@ -829,7 +543,6 @@ CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records t
   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
-  `marc` longblob, -- full bibliographic MARC record
   `url` text default NULL, -- url (MARC21 856$u)
   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
   `cn_class` varchar(30) default NULL,
@@ -838,13 +551,14 @@ CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records t
   `cn_sort` varchar(255) default NULL, -- normalized version of the call number used for sorting
   `agerestriction` varchar(255) default NULL, -- target audience/age restriction from the bib record (MARC21 521$a)
   `totalissues` int(10),
-  `marcxml` longtext, -- full bibliographic MARC record in MARCXML
   PRIMARY KEY  (`biblioitemnumber`),
   KEY `bibinoidx` (`biblioitemnumber`),
   KEY `bibnoidx` (`biblionumber`),
   KEY `itemtype_idx` (`itemtype`),
   KEY `isbn` (`isbn`(255)),
-  KEY `publishercode` (`publishercode`)
+  KEY `ean` (`ean`(255)),
+  KEY `publishercode` (`publishercode`),
+  KEY `timestamp` (`timestamp`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -889,16 +603,17 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
   `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)
+  `date_renewed` date default NULL, -- date the patron/borrower's card was last renewed
   `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` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)
+  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)
   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
-  `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
+  `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarantor or organization name
+  `contactfirstname` text, -- used for children to include first name of guarantor
+  `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarantor
+  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
   `borrowernotes` mediumtext, -- a note on the patron/borrower's account that is only visible in the staff client
-  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
+  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
   `sex` varchar(1) default NULL, -- patron/borrower's gender
   `password` varchar(60) default NULL, -- patron/borrower's encrypted password
   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
@@ -916,10 +631,16 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/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)
+  `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SMS turned on)
   `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
   `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
+  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron if this item has previously been checked out to this patron if 'yes', not if 'no', defer to category setting if 'inherit'.
+  `updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- time of last change could be useful for synchronization with external systems (among others)
+  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
+  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
+  `login_attempts` int(4) default 0, -- number of failed login attemps
+  `overdrive_auth_token` text default NULL, -- persist OverDrive auth token
   KEY borrowernumber (borrowernumber),
   KEY `cardnumber` (`cardnumber`),
   KEY `sms_provider_id` (`sms_provider_id`)
@@ -963,7 +684,7 @@ CREATE TABLE `deleteditems` (
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
-  `onloan` date default NULL, -- defines if item is checked out (NULL for not checked out, and checkout date for checked out)
+  `onloan` date default NULL, -- defines if item is checked out (NULL for not checked out, and due date for checked out)
   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
   `cn_sort` varchar(255) default NULL, -- normalized form of the call number (MARC21 952$o) used for sorting
   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
@@ -982,7 +703,8 @@ CREATE TABLE `deleteditems` (
   KEY `delitembibnoidx` (`biblionumber`),
   KEY `delhomebranch` (`homebranch`),
   KEY `delholdingbranch` (`holdingbranch`),
-  KEY `itype_idx` (`itype`)
+  KEY `itype_idx` (`itype`),
+  KEY `timestamp` (`timestamp`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -1000,33 +722,10 @@ CREATE TABLE `export_format` (
   `subfield_separator` varchar(2) NOT NULL,
   `encoding` varchar(255) NOT NULL,
   `type` varchar(255) DEFAULT 'marc',
+  `used_for` varchar(255) DEFAULT 'export_records',
   PRIMARY KEY  (`export_format_id`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Used for CSV export';
 
-
---
--- Table structure for table `hold_fill_targets`
---
-
-DROP TABLE IF EXISTS `hold_fill_targets`;
-CREATE TABLE hold_fill_targets (
-  `borrowernumber` int(11) NOT NULL,
-  `biblionumber` int(11) NOT NULL,
-  `itemnumber` int(11) NOT NULL,
-  `source_branchcode`  varchar(10) default NULL,
-  `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`)
-    REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  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`)
-    REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
-    REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `import_batches`
 --
@@ -1152,35 +851,6 @@ CREATE TABLE `import_items` (
   KEY `branchcode` (`branchcode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `issues`
---
-
-DROP TABLE IF EXISTS `issues`;
-CREATE TABLE `issues` ( -- information related to check outs or issues
-  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
-  `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` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
-  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
-  `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
-  `lastreneweddate` datetime default NULL, -- date the item was last renewed
-  `return` varchar(4) default NULL,
-  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
-  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
-  `issuedate` datetime default NULL, -- date the item was checked out or issued
-  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
-  PRIMARY KEY (`issue_id`),
-  UNIQUE KEY `itemnumber` (`itemnumber`),
-  KEY `issuesborridx` (`borrowernumber`),
-  KEY `itemnumber_idx` (`itemnumber`),
-  KEY `branchcode_idx` (`branchcode`),
-  KEY `bordate` (`borrowernumber`,`timestamp`),
-  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 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `issuingrules`
 --
@@ -1210,23 +880,38 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules
   `renewalperiod` int(4) default NULL, -- renewal period in the unit set in issuingrules.lengthunit
   `norenewalbefore` int(4) default NULL, -- no renewal allowed until X days or hours before due date.
   `auto_renew` BOOLEAN default FALSE, -- automatic renewal
+  `no_auto_renewal_after` int(4) default NULL, -- no auto renewal allowed after X days or hours after the issue date
+  `no_auto_renewal_after_hard_limit` date default NULL, -- no auto renewal allowed after a given date
   `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
+  `holds_per_record` SMALLINT(6) NOT NULL DEFAULT 1, -- How many holds a patron can have on a given bib
   `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
   overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
   cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
   onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
   opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
+  article_requests enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed,
   PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
   KEY `categorycode` (`categorycode`),
   KEY `itemtype` (`itemtype`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
+--
+-- Table structure for table `refund_lost_item_fee_rules`
+--
+
+DROP TABLE IF EXISTS `refund_lost_item_fee_rules`;
+CREATE TABLE `refund_lost_item_fee_rules` ( -- refund lost item fee rules tbale
+  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
+  `refund` tinyint(1) NOT NULL default 0, -- control wether to refund lost item fees on return
+  PRIMARY KEY  (`branchcode`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
 --
 -- Table structure for table `items`
 --
 
 DROP TABLE IF EXISTS `items`;
-CREATE TABLE `items` ( -- holdings/item information 
+CREATE TABLE `items` ( -- holdings/item information
   `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha
   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
@@ -1259,7 +944,7 @@ CREATE TABLE `items` ( -- holdings/item information
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
-  `onloan` date default NULL, -- defines if item is checked out (NULL for not checked out, and checkout date for checked out)
+  `onloan` date default NULL, -- defines if item is checked out (NULL for not checked out, and due date for checked out)
   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
   `cn_sort` varchar(255) default NULL,  -- normalized form of the call number (MARC21 952$o) used for sorting
   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
@@ -1282,25 +967,11 @@ CREATE TABLE `items` ( -- holdings/item information
   KEY `items_location` (`location`),
   KEY `items_ccode` (`ccode`),
   KEY `itype_idx` (`itype`),
+  KEY `timestamp` (`timestamp`),
   CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
-  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `items_last_borrower`
---
-
-CREATE TABLE IF NOT EXISTS `items_last_borrower` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `itemnumber` int(11) NOT NULL,
-  `borrowernumber` int(11) NOT NULL,
-  `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `itemnumber` (`itemnumber`),
-  KEY `borrowernumber` (`borrowernumber`),
-  CONSTRAINT `items_last_borrower_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `items_last_borrower_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
+  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
+  CONSTRAINT `items_ibfk_4` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -1325,27 +996,59 @@ CREATE TABLE `itemtypes` ( -- defines the item types
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `creator_batches`
+-- Table structure for table `default_branch_item_rules`
 --
 
-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
+DROP TABLE IF EXISTS `default_branch_item_rules`;
+CREATE TABLE `default_branch_item_rules` (
+  `itemtype` varchar(10) NOT NULL,
+  `holdallowed` tinyint(1) default NULL,
+  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
+  `returnbranch` varchar(15) default NULL,
+  PRIMARY KEY  (`itemtype`),
+  CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
+    ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `branchtransfers`
+--
+
+DROP TABLE IF EXISTS `branchtransfers`;
+CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
+  `branchtransfer_id` int(12) NOT NULL auto_increment, -- primary key
+  `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
+  `datesent` datetime default NULL, -- the date the transfer was initialized
+  `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
+  `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
+  `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
+  `comments` mediumtext, -- any comments related to the transfer
+  PRIMARY KEY (`branchtransfer_id`),
+  KEY `frombranch` (`frombranch`),
+  KEY `tobranch` (`tobranch`),
+  KEY `itemnumber` (`itemnumber`),
+  CONSTRAINT `branchtransfers_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `branchtransfers_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `branch_item_rules`
+--
+
+DROP TABLE IF EXISTS `branch_item_rules`;
+CREATE TABLE `branch_item_rules` ( -- information entered in the circulation and fine rules under 'Holds policy by item type'
+  `branchcode` varchar(10) NOT NULL, -- the branch this rule is for (branches.branchcode)
+  `itemtype` varchar(10) NOT NULL, -- the item type this rule applies to (items.itype)
+  `holdallowed` tinyint(1) default NULL, -- the number of holds allowed
+  hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode
+  `returnbranch` varchar(15) default NULL, -- the branch the item returns to (homebranch, holdingbranch, noreturn)
+  PRIMARY KEY  (`itemtype`,`branchcode`),
+  KEY `branch_item_rules_ibfk_2` (`branchcode`),
+  CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
+    ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
+    ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -1375,7 +1078,7 @@ CREATE TABLE `creator_layouts` (
   `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',
+  `layout_name` char(25) NOT NULL DEFAULT 'DEFAULT',
   `guidebox` int(1) DEFAULT '0',
   `oblique_title` int(1) DEFAULT '1',
   `font` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TR',
@@ -1420,26 +1123,7 @@ CREATE TABLE `creator_templates` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `letter`
---
-
-DROP TABLE IF EXISTS `letter`;
-CREATE TABLE `letter` ( -- table for all notice templates in Koha
-  `module` varchar(20) NOT NULL default '', -- Koha module that triggers this notice or slip
-  `code` varchar(20) NOT NULL default '', -- unique identifier for this notice or slip
-  `branchcode` varchar(10) default NULL, -- the branch this notice or slip is used at (branches.branchcode)
-  `name` varchar(100) NOT NULL default '', -- plain text name for this notice or slip
-  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
-  `title` varchar(200) NOT NULL default '', -- subject line of the notice
-  `content` text, -- body text for the notice or slip
-  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
-  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
-  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
-  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `marc_subfield_structure`
+-- Table structure for table `marc_subfield_structure`
 --
 
 DROP TABLE IF EXISTS `marc_subfield_structure`;
@@ -1452,7 +1136,7 @@ CREATE TABLE `marc_subfield_structure` (
   `mandatory` tinyint(4) NOT NULL default 0,
   `kohafield` varchar(40) default NULL,
   `tab` tinyint(1) default NULL,
-  `authorised_value` varchar(20) default NULL,
+  `authorised_value` varchar(32) default NULL,
   `authtypecode` varchar(20) default NULL,
   `value_builder` varchar(80) default NULL,
   `isurl` tinyint(1) default NULL,
@@ -1465,7 +1149,8 @@ CREATE TABLE `marc_subfield_structure` (
   PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
   KEY `kohafield_2` (`kohafield`),
   KEY `tab` (`frameworkcode`,`tab`),
-  KEY `kohafield` (`frameworkcode`,`kohafield`)
+  KEY `kohafield` (`frameworkcode`,`kohafield`),
+  CONSTRAINT `marc_subfield_structure_ibfk_1` FOREIGN KEY (`authorised_value`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -1582,10 +1267,15 @@ CREATE TABLE `matchchecks` (
 --
 
 DROP TABLE IF EXISTS `need_merge_authorities`;
-CREATE TABLE `need_merge_authorities` ( -- keeping track of authority records still to be merged by merge_authority cron job (used only if pref dontmerge is ON)
+CREATE TABLE `need_merge_authorities` ( -- keeping track of authority records still to be merged by merge_authority cron job
   `id` int NOT NULL auto_increment PRIMARY KEY, -- unique id
-  `authid` bigint NOT NULL, -- reference to authority record
-  `done` tinyint DEFAULT 0  -- indication whether merge has been executed (0=not done, 1= done, 2= in progress)
+  `authid` bigint NOT NULL, -- reference to original authority record
+  `authid_new` bigint, -- reference to optional new authority record
+  `reportxml` text, -- xml showing original reporting tag
+  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date and time last modified
+  `done` tinyint DEFAULT 0  -- indication whether merge has been executed (0=not done, 1=done, 2=in progress)
+-- Note: authid and authid_new should NOT be FOREIGN keys !
+-- authid may have been deleted; authid_new may be zero
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -1652,97 +1342,6 @@ CREATE TABLE `oai_sets_biblios` (
   CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `old_issues`
---
-
-DROP TABLE IF EXISTS `old_issues`;
-CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
-  `issue_id` int(11) NOT NULL, -- primary key for issues table
-  `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` datetime 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
-  `returndate` datetime default NULL, -- date the item was returned
-  `lastreneweddate` datetime default NULL, -- date the item was last renewed
-  `return` varchar(4) default NULL,
-  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
-  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
-  `issuedate` datetime default NULL, -- date the item was checked out or issued
-  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
-  PRIMARY KEY (`issue_id`),
-  KEY `old_issuesborridx` (`borrowernumber`),
-  KEY `old_issuesitemidx` (`itemnumber`),
-  KEY `branchcode_idx` (`branchcode`),
-  KEY `old_bordate` (`borrowernumber`,`timestamp`),
-  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`)
-    ON DELETE SET NULL ON UPDATE SET NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `old_reserves`
---
-DROP TABLE IF EXISTS `old_reserves`;
-CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have been completed (either filled or cancelled)
-  `reserve_id` int(11) NOT NULL, -- primary key
-  `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron this hold is for
-  `reservedate` date default NULL, -- the date the hold was places
-  `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bib record this hold is on
-  `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
-  `notificationdate` date default NULL, -- currently unused
-  `reminderdate` date default NULL, -- currently unused
-  `cancellationdate` date default NULL, -- the date this hold was cancelled
-  `reservenotes` mediumtext, -- notes related to this hold
-  `priority` smallint(6) default NULL, -- where in the queue the patron sits
-  `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
-  `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
-  `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
-  `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
-  `lowestPriority` tinyint(1) NOT NULL, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no)
-  `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no)
-  `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely)
-  `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting
-  PRIMARY KEY (`reserve_id`),
-  KEY `old_reserves_borrowernumber` (`borrowernumber`),
-  KEY `old_reserves_biblionumber` (`biblionumber`),
-  KEY `old_reserves_itemnumber` (`itemnumber`),
-  KEY `old_reserves_branchcode` (`branchcode`),
-  KEY `old_reserves_itemtype` (`itemtype`),
-  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`)
-    ON DELETE SET NULL ON UPDATE SET NULL,
-  CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
-    ON DELETE SET NULL ON UPDATE SET NULL,
-  CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
-    ON DELETE SET NULL ON UPDATE SET NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `opac_news`
---
-
-DROP TABLE IF EXISTS `opac_news`;
-CREATE TABLE `opac_news` ( -- data from the news tool
-  `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
-  `branchcode` varchar(10) default NULL, -- branch code users to create branch specific news, NULL is every branch.
-  `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
-  `borrowernumber` int(11) default NULL, -- The user who created the news article
-  PRIMARY KEY  (`idnew`),
-  CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
-  CONSTRAINT opac_news_branchcode_ibfk FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
-    ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `overduerules`
 --
@@ -1765,19 +1364,6 @@ CREATE TABLE `overduerules` ( -- overdue notice status and triggers
   UNIQUE KEY `overduerules_branch_cat` (`branchcode`,`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `patronimage`
---
-
-DROP TABLE IF EXISTS `patronimage`;
-CREATE TABLE `patronimage` ( -- information related to patron images
-  `borrowernumber` int(11) NOT NULL, -- the borrowernumber of the patron this image is attached to (borrowers.borrowernumber)
-  `mimetype` varchar(15) NOT NULL, -- the format of the image (png, jpg, etc)
-  `imagefile` mediumblob NOT NULL, -- the image
-  PRIMARY KEY  (`borrowernumber`),
-  CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 -- Table structure for table `pending_offline_operations`
 --
 -- this table is MyISAM, InnoDB tables are growing only and this table is filled/emptied/filled/emptied...
@@ -1862,62 +1448,6 @@ CREATE TABLE reports_dictionary ( -- definitions (or snippets of SQL) stored for
    KEY dictionary_area_idx (report_area)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `reserves`
---
-
-DROP TABLE IF EXISTS `reserves`;
-CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
-  `reserve_id` int(11) NOT NULL auto_increment, -- primary key
-  `borrowernumber` int(11) NOT NULL default 0, -- foreign key from the borrowers table defining which patron this hold is for
-  `reservedate` date default NULL, -- the date the hold was places
-  `biblionumber` int(11) NOT NULL default 0, -- foreign key from the biblio table defining which bib record this hold is on
-  `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
-  `notificationdate` date default NULL, -- currently unused
-  `reminderdate` date default NULL, -- currently unused
-  `cancellationdate` date default NULL, -- the date this hold was cancelled
-  `reservenotes` mediumtext, -- notes related to this hold
-  `priority` smallint(6) default NULL, -- where in the queue the patron sits
-  `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
-  `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
-  `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
-  `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
-  `lowestPriority` tinyint(1) NOT NULL,
-  `suspend` BOOLEAN NOT NULL DEFAULT 0,
-  `suspend_until` DATETIME NULL DEFAULT NULL,
-  `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting
-  PRIMARY KEY (`reserve_id`),
-  KEY priorityfoundidx (priority,found),
-  KEY `borrowernumber` (`borrowernumber`),
-  KEY `biblionumber` (`biblionumber`),
-  KEY `itemnumber` (`itemnumber`),
-  KEY `branchcode` (`branchcode`),
-  KEY `itemtype` (`itemtype`),
-  CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `reviews`
---
-
-DROP TABLE IF EXISTS `reviews`;
-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`),
-  CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
-  CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `saved_sql`
 --
@@ -1966,7 +1496,7 @@ CREATE TABLE `search_field` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
   `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
-  `type` ENUM('string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
+  `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
   PRIMARY KEY (`id`),
   UNIQUE KEY (`name`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -2070,91 +1600,476 @@ CREATE TABLE `sms_providers` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `special_holidays`
---
-
-DROP TABLE IF EXISTS `special_holidays`;
-CREATE TABLE `special_holidays` ( -- non repeatable holidays/library closings
-  `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
-  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
-  `day` smallint(6) NOT NULL default 0, -- day of the month this closing is on
-  `month` smallint(6) NOT NULL default 0, -- month this closing is in
-  `year` smallint(6) NOT NULL default 0, -- year this closing is in
-  `isexception` smallint(1) NOT NULL default 1, -- is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)
-  `title` varchar(50) NOT NULL default '', -- title for this closing
-  `description` text NOT NULL, -- description of this closing
-  PRIMARY KEY  (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `statistics`
---
-
-DROP TABLE IF EXISTS `statistics`;
-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, -- type of procedure used when making payments (does not appear in the 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, -- used by SIP
-  `usercode` varchar(10) default NULL, -- unused in Koha
-  `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, -- unused in Koha
-  `ccode` varchar(10) default NULL, -- foreign key from the items table, links transaction to a specific collection code
-  KEY `timeidx` (`datetime`),
-  KEY `branch_idx` (`branch`),
-  KEY `proccode_idx` (`proccode`),
-  KEY `type_idx` (`type`),
-  KEY `usercode_idx` (`usercode`),
-  KEY `itemnumber_idx` (`itemnumber`),
-  KEY `itemtype_idx` (`itemtype`),
-  KEY `borrowernumber_idx` (`borrowernumber`),
-  KEY `associatedborrower_idx` (`associatedborrower`),
-  KEY `ccode_idx` (`ccode`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table subscription_frequencies
---
-
-DROP TABLE IF EXISTS subscription_frequencies;
-CREATE TABLE subscription_frequencies (
-    id INTEGER NOT NULL AUTO_INCREMENT,
-    description TEXT NOT NULL,
-    displayorder INT DEFAULT NULL,
-    unit ENUM('day','week','month','year') DEFAULT NULL,
-    unitsperissue INTEGER NOT NULL DEFAULT '1',
-    issuesperunit INTEGER NOT NULL DEFAULT '1',
-    PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table subscription_numberpatterns
+-- Table structure for table `borrowers`
 --
 
-DROP TABLE IF EXISTS subscription_numberpatterns;
-CREATE TABLE subscription_numberpatterns (
-    id INTEGER NOT NULL AUTO_INCREMENT,
-    label VARCHAR(255) NOT NULL,
-    displayorder INTEGER DEFAULT NULL,
-    description TEXT NOT NULL,
-    numberingmethod VARCHAR(255) NOT NULL,
-    label1 VARCHAR(255) DEFAULT NULL,
-    add1 INTEGER DEFAULT NULL,
-    every1 INTEGER DEFAULT NULL,
-    whenmorethan1 INTEGER DEFAULT NULL,
-    setto1 INTEGER DEFAULT NULL,
-    numbering1 VARCHAR(255) DEFAULT NULL,
-    label2 VARCHAR(255) DEFAULT NULL,
-    add2 INTEGER DEFAULT NULL,
-    every2 INTEGER DEFAULT NULL,
-    whenmorethan2 INTEGER DEFAULT NULL,
-    setto2 INTEGER DEFAULT NULL,
-    numbering2 VARCHAR(255) DEFAULT NULL,
-    label3 VARCHAR(255) DEFAULT NULL,
+DROP TABLE IF EXISTS `borrowers`;
+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)
+  `date_renewed` date default NULL, -- date the patron/borrower's card was last renewed
+  `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` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)
+  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
+  `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarantor or organization name
+  `contactfirstname` text, -- used for children to include first name of guarantor
+  `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarantor
+  `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarantors or organizations
+  `borrowernotes` mediumtext, -- a note on the patron/borrower's account that is only visible in the staff client
+  `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor
+  `sex` varchar(1) default NULL, -- patron/borrower's gender
+  `password` varchar(60) default NULL, -- patron/borrower's Bcrypt encrypted password
+  `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
+  `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
+  `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
+  `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 city for the alternate contact for the patron/borrower
+  `altcontactstate` text default NULL, -- the 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 SMS turned on)
+  `sms_provider_id` int(11) DEFAULT NULL, -- the provider of the mobile phone number defined in smsalertnumber
+  `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
+  `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT '0', -- controls if relatives can see this patron's checkouts
+  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron if this item has previously been checked out to this patron if 'yes', not if 'no', defer to category setting if 'inherit'.
+  `updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- time of last change could be useful for synchronization with external systems (among others)
+  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
+  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
+  `login_attempts` int(4) default 0, -- number of failed login attemps
+  `overdrive_auth_token` text default NULL, -- persist OverDrive auth token
+  UNIQUE KEY `cardnumber` (`cardnumber`),
+  PRIMARY KEY `borrowernumber` (`borrowernumber`),
+  KEY `categorycode` (`categorycode`),
+  KEY `branchcode` (`branchcode`),
+  UNIQUE KEY `userid` (`userid`),
+  KEY `guarantorid` (`guarantorid`),
+  KEY `surname_idx` (`surname`(255)),
+  KEY `firstname_idx` (`firstname`(255)),
+  KEY `othernames_idx` (`othernames`(255)),
+  KEY `sms_provider_id` (`sms_provider_id`),
+  CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
+  CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`),
+  CONSTRAINT `borrowers_ibfk_3` FOREIGN KEY (`sms_provider_id`) REFERENCES `sms_providers` (`id`) ON UPDATE CASCADE ON DELETE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `borrower_attributes`
+--
+
+DROP TABLE IF EXISTS `borrower_attributes`;
+CREATE TABLE `borrower_attributes` ( -- values of custom patron fields known as extended patron attributes linked to patrons/borrowers
+  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, -- Row id field
+  `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(255) default NULL, -- custom patron field value
+  KEY `borrowernumber` (`borrowernumber`),
+  KEY `code_attribute` (`code`, `attribute`),
+  CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+    ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
+    ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `borrower_debarments`
+--
+
+DROP TABLE IF EXISTS `borrower_debarments`;
+CREATE TABLE borrower_debarments ( -- tracks restrictions on the patron's record
+  borrower_debarment_id int(11) NOT NULL AUTO_INCREMENT, -- unique key for the restriction
+  borrowernumber int(11) NOT NULL, -- foreign key for borrowers.borrowernumber for patron who is restricted
+  expiration date DEFAULT NULL, -- expiration date of the restriction
+  `type` enum('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL', -- type of restriction
+  `comment` text, -- comments about the restriction
+  manager_id int(11) DEFAULT NULL, -- foreign key for borrowers.borrowernumber for the librarian managing the restriction
+  created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date the restriction was added
+  updated timestamp NULL DEFAULT NULL, -- date the restriction was updated
+  PRIMARY KEY (borrower_debarment_id),
+  KEY borrowernumber (borrowernumber),
+  CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+    ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table borrower_sync
+--
+
+DROP TABLE IF EXISTS `borrower_sync`;
+CREATE TABLE borrower_sync (
+  borrowersyncid int(11) NOT NULL AUTO_INCREMENT, -- Primary key, unique identifier
+  borrowernumber int(11) NOT NULL, -- Connects data about synchronisations to a borrower
+  synctype varchar(32) NOT NULL, -- There could potentially be more than one kind of syncing going on, a text string here can be used to tell them apart. E.g.: The Norwegian national patron database uses 'norwegianpatrondb' in this column
+  sync tinyint(1) NOT NULL DEFAULT '0', -- A boolean (1/0) for turning syncing off and on for individual borrowers
+  syncstatus varchar(10) DEFAULT NULL, -- The sync status for any given borrower. Could be text strings like 'new', 'edited', 'synced' etc. The values used here will depend on the actual syncing being done.
+  lastsync varchar(50) DEFAULT NULL, -- Date of the last successfull sync. The date format might be different depending on the service that is being used, so no special date format is being enforced here.
+  hashed_pin varchar(64) DEFAULT NULL, -- Perhaps specific to The Norwegian national patron database, this column holds a hashed PIN code
+  PRIMARY KEY (borrowersyncid),
+  KEY borrowernumber (borrowernumber),
+  CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `issues`
+--
+
+DROP TABLE IF EXISTS `issues`;
+CREATE TABLE `issues` ( -- information related to check outs or issues
+  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
+  `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` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
+  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
+  `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
+  `lastreneweddate` datetime default NULL, -- date the item was last renewed
+  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
+  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
+  `auto_renew_error` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, -- automatic renewal error
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
+  `issuedate` datetime default NULL, -- date the item was checked out or issued
+  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
+  `note` mediumtext default NULL, -- issue note text
+  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
+  PRIMARY KEY (`issue_id`),
+  UNIQUE KEY `itemnumber` (`itemnumber`),
+  KEY `issuesborridx` (`borrowernumber`),
+  KEY `itemnumber_idx` (`itemnumber`),
+  KEY `branchcode_idx` (`branchcode`),
+  KEY `bordate` (`borrowernumber`,`timestamp`),
+  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 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `old_issues`
+--
+
+DROP TABLE IF EXISTS `old_issues`;
+CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
+  `issue_id` int(11) NOT NULL, -- primary key for issues table
+  `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` datetime 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
+  `returndate` datetime default NULL, -- date the item was returned
+  `lastreneweddate` datetime default NULL, -- date the item was last renewed
+  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
+  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
+  `auto_renew_error` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, -- automatic renewal error
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
+  `issuedate` datetime default NULL, -- date the item was checked out or issued
+  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
+  `note` mediumtext default NULL, -- issue note text
+  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
+  PRIMARY KEY (`issue_id`),
+  KEY `old_issuesborridx` (`borrowernumber`),
+  KEY `old_issuesitemidx` (`itemnumber`),
+  KEY `branchcode_idx` (`branchcode`),
+  KEY `old_bordate` (`borrowernumber`,`timestamp`),
+  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`)
+    ON DELETE SET NULL ON UPDATE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `items_last_borrower`
+--
+
+CREATE TABLE IF NOT EXISTS `items_last_borrower` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `itemnumber` int(11) NOT NULL,
+  `borrowernumber` int(11) NOT NULL,
+  `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `itemnumber` (`itemnumber`),
+  KEY `borrowernumber` (`borrowernumber`),
+  CONSTRAINT `items_last_borrower_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `items_last_borrower_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- 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 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `opac_news`
+--
+
+DROP TABLE IF EXISTS `opac_news`;
+CREATE TABLE `opac_news` ( -- data from the news tool
+  `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
+  `branchcode` varchar(10) default NULL, -- branch code users to create branch specific news, NULL is every branch.
+  `title` varchar(250) NOT NULL default '', -- title of the news article
+  `content` 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
+  `borrowernumber` int(11) default NULL, -- The user who created the news article
+  PRIMARY KEY  (`idnew`),
+  CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
+  CONSTRAINT opac_news_branchcode_ibfk FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
+    ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `patronimage`
+--
+
+DROP TABLE IF EXISTS `patronimage`;
+CREATE TABLE `patronimage` ( -- information related to patron images
+  `borrowernumber` int(11) NOT NULL, -- the borrowernumber of the patron this image is attached to (borrowers.borrowernumber)
+  `mimetype` varchar(15) NOT NULL, -- the format of the image (png, jpg, etc)
+  `imagefile` mediumblob NOT NULL, -- the image
+  PRIMARY KEY  (`borrowernumber`),
+  CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `reserves`
+--
+
+DROP TABLE IF EXISTS `reserves`;
+CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
+  `reserve_id` int(11) NOT NULL auto_increment, -- primary key
+  `borrowernumber` int(11) NOT NULL default 0, -- foreign key from the borrowers table defining which patron this hold is for
+  `reservedate` date default NULL, -- the date the hold was places
+  `biblionumber` int(11) NOT NULL default 0, -- foreign key from the biblio table defining which bib record this hold is on
+  `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
+  `notificationdate` date default NULL, -- currently unused
+  `reminderdate` date default NULL, -- currently unused
+  `cancellationdate` date default NULL, -- the date this hold was cancelled
+  `reservenotes` mediumtext, -- notes related to this hold
+  `priority` smallint(6) default NULL, -- where in the queue the patron sits
+  `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
+  `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
+  `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
+  `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
+  `lowestPriority` tinyint(1) NOT NULL,
+  `suspend` BOOLEAN NOT NULL DEFAULT 0,
+  `suspend_until` DATETIME NULL DEFAULT NULL,
+  `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting
+  PRIMARY KEY (`reserve_id`),
+  KEY priorityfoundidx (priority,found),
+  KEY `borrowernumber` (`borrowernumber`),
+  KEY `biblionumber` (`biblionumber`),
+  KEY `itemnumber` (`itemnumber`),
+  KEY `branchcode` (`branchcode`),
+  KEY `itemtype` (`itemtype`),
+  CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `old_reserves`
+--
+
+DROP TABLE IF EXISTS `old_reserves`;
+CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have been completed (either filled or cancelled)
+  `reserve_id` int(11) NOT NULL, -- primary key
+  `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron this hold is for
+  `reservedate` date default NULL, -- the date the hold was places
+  `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bib record this hold is on
+  `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
+  `notificationdate` date default NULL, -- currently unused
+  `reminderdate` date default NULL, -- currently unused
+  `cancellationdate` date default NULL, -- the date this hold was cancelled
+  `reservenotes` mediumtext, -- notes related to this hold
+  `priority` smallint(6) default NULL, -- where in the queue the patron sits
+  `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
+  `itemnumber` int(11) default NULL, -- foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
+  `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
+  `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
+  `lowestPriority` tinyint(1) NOT NULL, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no)
+  `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no)
+  `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely)
+  `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting
+  PRIMARY KEY (`reserve_id`),
+  KEY `old_reserves_borrowernumber` (`borrowernumber`),
+  KEY `old_reserves_biblionumber` (`biblionumber`),
+  KEY `old_reserves_itemnumber` (`itemnumber`),
+  KEY `old_reserves_branchcode` (`branchcode`),
+  KEY `old_reserves_itemtype` (`itemtype`),
+  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`)
+    ON DELETE SET NULL ON UPDATE SET NULL,
+  CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
+    ON DELETE SET NULL ON UPDATE SET NULL,
+  CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
+    ON DELETE SET NULL ON UPDATE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `reviews`
+--
+
+DROP TABLE IF EXISTS `reviews`;
+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 0, -- 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`),
+  CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
+  CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `special_holidays`
+--
+
+DROP TABLE IF EXISTS `special_holidays`;
+CREATE TABLE `special_holidays` ( -- non repeatable holidays/library closings
+  `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
+  `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
+  `day` smallint(6) NOT NULL default 0, -- day of the month this closing is on
+  `month` smallint(6) NOT NULL default 0, -- month this closing is in
+  `year` smallint(6) NOT NULL default 0, -- year this closing is in
+  `isexception` smallint(1) NOT NULL default 1, -- is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)
+  `title` varchar(50) NOT NULL default '', -- title for this closing
+  `description` text NOT NULL, -- description of this closing
+  PRIMARY KEY  (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `statistics`
+--
+
+DROP TABLE IF EXISTS `statistics`;
+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, -- type of procedure used when making payments (does not appear in the 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, -- used by SIP
+  `usercode` varchar(10) default NULL, -- unused in Koha
+  `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, -- unused in Koha
+  `ccode` varchar(10) default NULL, -- foreign key from the items table, links transaction to a specific collection code
+  KEY `timeidx` (`datetime`),
+  KEY `branch_idx` (`branch`),
+  KEY `proccode_idx` (`proccode`),
+  KEY `type_idx` (`type`),
+  KEY `usercode_idx` (`usercode`),
+  KEY `itemnumber_idx` (`itemnumber`),
+  KEY `itemtype_idx` (`itemtype`),
+  KEY `borrowernumber_idx` (`borrowernumber`),
+  KEY `associatedborrower_idx` (`associatedborrower`),
+  KEY `ccode_idx` (`ccode`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table subscription_frequencies
+--
+
+DROP TABLE IF EXISTS subscription_frequencies;
+CREATE TABLE subscription_frequencies (
+    id INTEGER NOT NULL AUTO_INCREMENT,
+    description TEXT NOT NULL,
+    displayorder INT DEFAULT NULL,
+    unit ENUM('day','week','month','year') DEFAULT NULL,
+    unitsperissue INTEGER NOT NULL DEFAULT '1',
+    issuesperunit INTEGER NOT NULL DEFAULT '1',
+    PRIMARY KEY (id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table subscription_numberpatterns
+--
+
+DROP TABLE IF EXISTS subscription_numberpatterns;
+CREATE TABLE subscription_numberpatterns (
+    id INTEGER NOT NULL AUTO_INCREMENT,
+    label VARCHAR(255) NOT NULL,
+    displayorder INTEGER DEFAULT NULL,
+    description TEXT NOT NULL,
+    numberingmethod VARCHAR(255) NOT NULL,
+    label1 VARCHAR(255) DEFAULT NULL,
+    add1 INTEGER DEFAULT NULL,
+    every1 INTEGER DEFAULT NULL,
+    whenmorethan1 INTEGER DEFAULT NULL,
+    setto1 INTEGER DEFAULT NULL,
+    numbering1 VARCHAR(255) DEFAULT NULL,
+    label2 VARCHAR(255) DEFAULT NULL,
+    add2 INTEGER DEFAULT NULL,
+    every2 INTEGER DEFAULT NULL,
+    whenmorethan2 INTEGER DEFAULT NULL,
+    setto2 INTEGER DEFAULT NULL,
+    numbering2 VARCHAR(255) DEFAULT NULL,
+    label3 VARCHAR(255) DEFAULT NULL,
     add3 INTEGER DEFAULT NULL,
     every3 INTEGER DEFAULT NULL,
     whenmorethan3 INTEGER DEFAULT NULL,
@@ -2209,6 +2124,8 @@ CREATE TABLE `subscription` ( -- information related to the subscription
   `enddate` date default NULL, -- subscription end date
   `closed` INT(1) NOT NULL DEFAULT 0, -- yes / no if the subscription is closed
   `reneweddate` date default NULL, -- date of last renewal for the subscription
+  `itemtype` VARCHAR( 10 ) NULL,
+  `previousitemtype` VARCHAR( 10 ) NULL,
   PRIMARY KEY  (`subscriptionid`),
   CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
@@ -2250,52 +2167,6 @@ CREATE TABLE `subscriptionroutinglist` ( -- information related to the routing l
     ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- Table structure for table `suggestions`
---
-
-DROP TABLE IF EXISTS `suggestions`;
-CREATE TABLE `suggestions` ( -- purchase suggestions
-  `suggestionid` int(8) NOT NULL auto_increment, -- unique identifier assigned automatically by Koha
-  `suggestedby` int(11) NOT NULL default 0, -- borrowernumber for the person making the suggestion, foreign key linking to the borrowers table
-  `suggesteddate` date NOT NULL, -- date the suggestion was submitted
-  `managedby` int(11) default NULL, -- borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table
-  `manageddate` date default NULL, -- date the suggestion was updated
-   acceptedby INT(11) default NULL, -- borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table
-   accepteddate date default NULL, -- date the suggestion was marked as accepted
-   rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table
-   rejecteddate date default NULL, -- date the suggestion was marked as rejected
-  `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)
-  `note` mediumtext, -- note entered on the suggestion
-  `author` varchar(80) default NULL, -- author of the suggested item
-  `title` varchar(255) default NULL, -- title of the suggested item
-  `copyrightdate` smallint(6) default NULL, -- copyright date of the suggested item
-  `publishercode` varchar(255) default NULL, -- publisher of the suggested item
-  `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  -- date and time the suggestion was updated
-  `volumedesc` varchar(255) default NULL,
-  `publicationyear` smallint(6) default 0,
-  `place` varchar(255) default NULL, -- publication place of the suggested item
-  `isbn` varchar(30) default NULL, -- isbn of the suggested item
-  `biblionumber` int(11) default NULL, -- foreign key linking the suggestion to the biblio table after the suggestion has been ordered
-  `reason` text, -- reason for accepting or rejecting the suggestion
-  `patronreason` text, -- reason for making the suggestion
-   budgetid INT(11), -- foreign key linking the suggested budget to the aqbudgets table
-   branchcode VARCHAR(10) default NULL, -- foreign key linking the suggested branch to the branches table
-   collectiontitle text default NULL, -- collection name for the suggested item
-   itemtype VARCHAR(30) default NULL, -- suggested item type 
-   quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased
-   currency VARCHAR(10) default NULL, -- suggested currency for the suggested price
-   price DECIMAL(28,6) default NULL, -- suggested price
-   total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
-  PRIMARY KEY  (`suggestionid`),
-  KEY `suggestedby` (`suggestedby`),
-  KEY `managedby` (`managedby`),
-  KEY `status` (`STATUS`),
-  KEY `biblionumber` (`biblionumber`),
-  KEY `branchcode` (`branchcode`),
-  CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `systempreferences`
 --
@@ -2394,17 +2265,16 @@ CREATE TABLE `userflags` (
 --
 
 DROP TABLE IF EXISTS `virtualshelves`;
-CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) 
+CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves)
   `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
   `shelfname` varchar(255) default NULL, -- name of the list
   `owner` int default NULL, -- foreign key linking to the borrowers table (using borrowernumber) for the creator of this list (changed from varchar(80) to int)
   `category` varchar(1) default NULL, -- type of list (private [1], public [2])
   `sortfield` varchar(16) default 'title', -- the field this list is sorted on
   `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
-  `created_on` TIMESTAMP NOT NULL, -- creation time
-  `allow_add` tinyint(1) default 0, -- permission for adding entries to list
-  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
-  `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
+  `created_on` datetime NOT NULL, -- creation time
+  `allow_change_from_owner` tinyint(1) default 1, -- can owner change contents?
+  `allow_change_from_others` tinyint(1) default 0, -- can others change contents?
   PRIMARY KEY  (`shelfnumber`),
   CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -2576,7 +2446,7 @@ CREATE TABLE language_script_mapping (
 DROP TABLE IF EXISTS `permissions`;
 CREATE TABLE `permissions` (
   `module_bit` int(11) NOT NULL DEFAULT 0,
-  `code` varchar(64) DEFAULT NULL,
+  `code` varchar(64) NOT NULL DEFAULT '',
   `description` varchar(255) DEFAULT NULL,
   PRIMARY KEY  (`module_bit`, `code`),
   CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
@@ -2591,7 +2461,7 @@ DROP TABLE IF EXISTS `serialitems`;
 CREATE TABLE `serialitems` (
        `itemnumber` int(11) NOT NULL,
        `serialid` int(11) NOT NULL,
-       UNIQUE KEY `serialitemsidx` (`itemnumber`),
+    PRIMARY KEY (`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_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
@@ -2635,6 +2505,16 @@ CREATE TABLE `tmp_holdsqueue` (
   `item_level_request` tinyint(4) NOT NULL default 0
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
+--
+-- Table structure for table `message_transport_types`
+--
+
+DROP TABLE IF EXISTS `message_transport_types`;
+CREATE TABLE `message_transport_types` (
+  `message_transport_type` varchar(20) NOT NULL,
+  PRIMARY KEY  (`message_transport_type`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
 --
 -- Table structure for table `message_queue`
 --
@@ -2661,13 +2541,23 @@ CREATE TABLE `message_queue` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `message_transport_types`
+-- Table structure for table `letter`
 --
 
-DROP TABLE IF EXISTS `message_transport_types`;
-CREATE TABLE `message_transport_types` (
-  `message_transport_type` varchar(20) NOT NULL,
-  PRIMARY KEY  (`message_transport_type`)
+DROP TABLE IF EXISTS `letter`;
+CREATE TABLE `letter` ( -- table for all notice templates in Koha
+  `module` varchar(20) NOT NULL default '', -- Koha module that triggers this notice or slip
+  `code` varchar(20) NOT NULL default '', -- unique identifier for this notice or slip
+  `branchcode` varchar(10) NOT NULL default '', -- the branch this notice or slip is used at (branches.branchcode)
+  `name` varchar(100) NOT NULL default '', -- plain text name for this notice or slip
+  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
+  `title` varchar(200) NOT NULL default '', -- subject line of the notice
+  `content` text, -- body text for the notice or slip
+  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
+  `lang` varchar(25) NOT NULL DEFAULT 'default', -- lang of the notice
+  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`, `lang`),
+  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
+  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -2714,8 +2604,7 @@ CREATE TABLE `message_transports` (
   KEY `message_transport_type` (`message_transport_type`),
   KEY `letter_module` (`letter_module`,`letter_code`),
   CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`, `branchcode`) REFERENCES `letter` (`module`, `code`, `branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
+  CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -2811,7 +2700,9 @@ CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou
   `message_type` varchar(1) NOT NULL, -- whether the message is for the librarians (L) or the patron (B)
   `message` text NOT NULL, -- the text of the message
   `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- the date and time the message was written
-  PRIMARY KEY (`message_id`)
+  `manager_id` int(11) default NULL, -- creator of message
+  PRIMARY KEY (`message_id`),
+  CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -2872,13 +2763,15 @@ CREATE TABLE `action_logs` ( -- logs of actions taken in Koha (requires that the
   `action` text, -- the action (includes things like DELETED, ADDED, MODIFY, etc)
   `object` int(11) default NULL, -- the object that the action was taken against (could be a borrowernumber, itemnumber, etc)
   `info` text, -- information about the action (usually includes SQL statement)
+  `interface` VARCHAR(30) DEFAULT NULL, -- the context this action was taken in
   PRIMARY KEY (`action_id`),
   KEY `timestamp_idx` (`timestamp`),
   KEY `user_idx` (`user`),
   KEY `module_idx` (`module`(255)),
   KEY `action_idx` (`action`(255)),
   KEY `object_idx` (`object`),
-  KEY `info_idx` (`info`(255))
+  KEY `info_idx` (`info`(255)),
+  KEY `interface` (`interface`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
@@ -2896,70 +2789,6 @@ CREATE TABLE `alert` (
   KEY `type` (`type`,`externalid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
---
--- 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 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table `aqbasket`
---
-
-DROP TABLE IF EXISTS `aqbasket`;
-CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions
-  `basketno` int(11) NOT NULL auto_increment, -- primary key, Koha defined number
-  `basketname` varchar(50) default NULL, -- name given to the basket at creation
-  `note` mediumtext, -- the internal note added at basket creation
-  `booksellernote` mediumtext, -- the vendor note added at basket creation
-  `contractnumber` int(11), -- links this basket to the aqcontract table (aqcontract.contractnumber)
-  `creationdate` date default NULL, -- the date the basket was created
-  `closedate` date default NULL, -- the date the basket was closed
-  `booksellerid` int(11) NOT NULL default 1, -- the Koha assigned ID for the vendor (aqbooksellers.id)
-  `authorisedby` varchar(10) default NULL, -- the borrowernumber of the person who created the basket
-  `booksellerinvoicenumber` mediumtext, -- appears to always be NULL
-  `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
-  `deliveryplace` varchar(10) default NULL, -- basket delivery place
-  `billingplace` varchar(10) default NULL, -- basket billing place
-  branch varchar(10) default NULL, -- basket branch
-  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
-  PRIMARY KEY  (`basketno`),
-  KEY `booksellerid` (`booksellerid`),
-  KEY `basketgroupid` (`basketgroupid`),
-  KEY `contractnumber` (`contractnumber`),
-  KEY `authorisedby` (`authorisedby`),
-  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,
-  CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table aqbasketusers
---
-
-DROP TABLE IF EXISTS aqbasketusers;
-CREATE TABLE aqbasketusers (
-  basketno int(11) NOT NULL,
-  borrowernumber int(11) NOT NULL,
-  PRIMARY KEY (basketno,borrowernumber),
-  CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON UPDATE CASCADE ON DELETE CASCADE,
-  CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
 --
 -- Table structure for table `aqbooksellers`
 --
@@ -2988,16 +2817,35 @@ CREATE TABLE `aqbooksellers` ( -- information about the vendors listed in acquis
   `gstreg` tinyint(4) default NULL, -- is your library charged tax (1 for yes, 0 for no)
   `listincgst` tinyint(4) default NULL, -- is tax included in list prices (1 for yes, 0 for no)
   `invoiceincgst` tinyint(4) default NULL, -- is tax included in invoice prices (1 for yes, 0 for no)
-  `gstrate` decimal(6,4) default NULL, -- the tax rate the library is charged
+  `tax_rate` decimal(6,4) default NULL, -- the tax rate the library is charged
   `discount` float(6,4) default NULL, -- discount offered on all items ordered from this vendor
   `fax` varchar(50) default NULL, -- vendor fax number
   deliverytime int(11) default NULL, -- vendor delivery time
   PRIMARY KEY  (`id`),
-  KEY `listprice` (`listprice`),
-  KEY `invoiceprice` (`invoiceprice`),
-  KEY `name` (`name`(255)),
-  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
+  KEY `listprice` (`listprice`),
+  KEY `invoiceprice` (`invoiceprice`),
+  KEY `name` (`name`(255)),
+  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 COLLATE=utf8_unicode_ci;
+
+--
+-- 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 COLLATE=utf8_unicode_ci;
 
 --
@@ -3097,6 +2945,7 @@ CREATE TABLE aqcontacts (
   fax varchar(100) default NULL,  -- contact's fax number
   email varchar(100) default NULL, -- contact's email address
   notes mediumtext, -- notes related to the contact
+  orderacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisition orders
   claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims
   claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims
   acqprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for acquisitions messages
@@ -3124,6 +2973,176 @@ CREATE TABLE `aqcontract` (
        REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
 
+--
+-- Table structure for table `aqbasket`
+--
+
+DROP TABLE IF EXISTS `aqbasket`;
+CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions
+  `basketno` int(11) NOT NULL auto_increment, -- primary key, Koha defined number
+  `basketname` varchar(50) default NULL, -- name given to the basket at creation
+  `note` mediumtext, -- the internal note added at basket creation
+  `booksellernote` mediumtext, -- the vendor note added at basket creation
+  `contractnumber` int(11), -- links this basket to the aqcontract table (aqcontract.contractnumber)
+  `creationdate` date default NULL, -- the date the basket was created
+  `closedate` date default NULL, -- the date the basket was closed
+  `booksellerid` int(11) NOT NULL default 1, -- the Koha assigned ID for the vendor (aqbooksellers.id)
+  `authorisedby` varchar(10) default NULL, -- the borrowernumber of the person who created the basket
+  `booksellerinvoicenumber` mediumtext, -- appears to always be NULL
+  `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
+  `deliveryplace` varchar(10) default NULL, -- basket delivery place
+  `billingplace` varchar(10) default NULL, -- basket billing place
+  create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL; -- when items should be created for orders in this basket
+  branch varchar(10) default NULL, -- basket branch
+  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
+  PRIMARY KEY  (`basketno`),
+  KEY `booksellerid` (`booksellerid`),
+  KEY `basketgroupid` (`basketgroupid`),
+  KEY `contractnumber` (`contractnumber`),
+  KEY `authorisedby` (`authorisedby`),
+  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,
+  CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table aqbasketusers
+--
+
+DROP TABLE IF EXISTS aqbasketusers;
+CREATE TABLE aqbasketusers (
+  basketno int(11) NOT NULL,
+  borrowernumber int(11) NOT NULL,
+  PRIMARY KEY (basketno,borrowernumber),
+  CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `suggestions`
+--
+
+DROP TABLE IF EXISTS `suggestions`;
+CREATE TABLE `suggestions` ( -- purchase suggestions
+  `suggestionid` int(8) NOT NULL auto_increment, -- unique identifier assigned automatically by Koha
+  `suggestedby` int(11) NOT NULL default 0, -- borrowernumber for the person making the suggestion, foreign key linking to the borrowers table
+  `suggesteddate` date NOT NULL, -- date the suggestion was submitted
+  `managedby` int(11) default NULL, -- borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table
+  `manageddate` date default NULL, -- date the suggestion was updated
+   acceptedby INT(11) default NULL, -- borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table
+   accepteddate date default NULL, -- date the suggestion was marked as accepted
+   rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table
+   rejecteddate date default NULL, -- date the suggestion was marked as rejected
+  `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)
+  `note` mediumtext, -- note entered on the suggestion
+  `author` varchar(80) default NULL, -- author of the suggested item
+  `title` varchar(255) default NULL, -- title of the suggested item
+  `copyrightdate` smallint(6) default NULL, -- copyright date of the suggested item
+  `publishercode` varchar(255) default NULL, -- publisher of the suggested item
+  `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  -- date and time the suggestion was updated
+  `volumedesc` varchar(255) default NULL,
+  `publicationyear` smallint(6) default 0,
+  `place` varchar(255) default NULL, -- publication place of the suggested item
+  `isbn` varchar(30) default NULL, -- isbn of the suggested item
+  `biblionumber` int(11) default NULL, -- foreign key linking the suggestion to the biblio table after the suggestion has been ordered
+  `reason` text, -- reason for accepting or rejecting the suggestion
+  `patronreason` text, -- reason for making the suggestion
+   budgetid INT(11), -- foreign key linking the suggested budget to the aqbudgets table
+   branchcode VARCHAR(10) default NULL, -- foreign key linking the suggested branch to the branches table
+   collectiontitle text default NULL, -- collection name for the suggested item
+   itemtype VARCHAR(30) default NULL, -- suggested item type
+   quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased
+   currency VARCHAR(10) default NULL, -- suggested currency for the suggested price
+   price DECIMAL(28,6) default NULL, -- suggested price
+   total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
+  PRIMARY KEY  (`suggestionid`),
+  KEY `suggestedby` (`suggestedby`),
+  KEY `managedby` (`managedby`),
+  KEY `status` (`STATUS`),
+  KEY `biblionumber` (`biblionumber`),
+  KEY `branchcode` (`branchcode`),
+  CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table vendor_edi_accounts
+--
+
+DROP TABLE IF EXISTS vendor_edi_accounts;
+CREATE TABLE IF NOT EXISTS vendor_edi_accounts (
+  id INT(11) NOT NULL auto_increment,
+  description TEXT NOT NULL,
+  host VARCHAR(40),
+  username VARCHAR(40),
+  password VARCHAR(40),
+  last_activity DATE,
+  vendor_id INT(11) REFERENCES aqbooksellers( id ),
+  download_directory TEXT,
+  upload_directory TEXT,
+  san VARCHAR(20),
+  id_code_qualifier VARCHAR(3) default '14',
+  transport VARCHAR(6) default 'FTP',
+  quotes_enabled TINYINT(1) not null default 0,
+  invoices_enabled TINYINT(1) not null default 0,
+  orders_enabled TINYINT(1) not null default 0,
+  responses_enabled TINYINT(1) not null default 0,
+  auto_orders TINYINT(1) not null default 0,
+  shipment_budget INTEGER(11) REFERENCES aqbudgets( budget_id ),
+  plugin varchar(256) NOT NULL DEFAULT "",
+  PRIMARY KEY  (id),
+  KEY vendorid (vendor_id),
+  KEY shipmentbudget (shipment_budget),
+  CONSTRAINT vfk_vendor_id FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ),
+  CONSTRAINT vfk_shipment_budget FOREIGN KEY ( shipment_budget ) REFERENCES aqbudgets ( budget_id )
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table edifact_messages
+--
+
+DROP TABLE IF EXISTS edifact_messages;
+CREATE TABLE IF NOT EXISTS edifact_messages (
+  id INT(11) NOT NULL auto_increment,
+  message_type VARCHAR(10) NOT NULL,
+  transfer_date DATE,
+  vendor_id INT(11) REFERENCES aqbooksellers( id ),
+  edi_acct  INTEGER REFERENCES vendor_edi_accounts( id ),
+  status TEXT,
+  basketno INT(11) REFERENCES aqbasket( basketno),
+  raw_msg MEDIUMTEXT,
+  filename TEXT,
+  deleted BOOLEAN NOT NULL DEFAULT 0,
+  PRIMARY KEY  (id),
+  KEY vendorid ( vendor_id),
+  KEY ediacct (edi_acct),
+  KEY basketno ( basketno),
+  CONSTRAINT emfk_vendor FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT emfk_edi_acct FOREIGN KEY ( edi_acct ) REFERENCES vendor_edi_accounts ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT emfk_basketno FOREIGN KEY ( basketno ) REFERENCES aqbasket ( basketno ) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table aqinvoices
+--
+
+DROP TABLE IF EXISTS aqinvoices;
+CREATE TABLE aqinvoices (
+  invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
+  invoicenumber mediumtext NOT NULL,    -- Name of invoice
+  booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
+  shipmentdate date default NULL,   -- date of shipment
+  billingdate date default NULL,    -- date of billing
+  closedate date default NULL,  -- invoice close date, NULL means the invoice is open
+  shipmentcost decimal(28,6) default NULL,  -- shipment cost
+  shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
+  message_id int(11) default NULL, -- foreign key to edifact invoice message
+  PRIMARY KEY (invoiceid),
+  CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT edifact_msg_fk FOREIGN KEY ( message_id ) REFERENCES edifact_messages ( id ) ON DELETE SET NULL,
+  CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
 --
 -- Table structure for table `aqorders`
 --
@@ -3138,8 +3157,10 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items
   `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
   `datereceived` date default NULL, -- the date this order was received
   invoiceid int(11) default NULL, -- id of invoice
-  `freight` decimal(28,6) default NULL, -- shipping costs (not used)
-  `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
+  `freight` decimal(28,6) DEFAULT NULL, -- shipping costs (not used)
+  `unitprice` decimal(28,6) DEFAULT NULL, -- the actual cost entered when receiving this line item
+  `unitprice_tax_excluded` decimal(28,6) default NULL, -- the unit price excluding tax (on receiving)
+  `unitprice_tax_included` decimal(28,6) default NULL, -- the unit price including tax (on receiving)
   `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
   `datecancellationprinted` date default NULL, -- the date the line item was deleted
   `cancellationreason` text default NULL, -- reason of cancellation
@@ -3148,12 +3169,20 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items
   `purchaseordernumber` mediumtext, -- not used? always NULL
   `basketno` int(11) default NULL, -- links this order line to a specific basket (aqbasket.basketno)
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order line was last modified
-  `rrp` decimal(13,2) default NULL, -- the replacement cost for this line item
-  `ecost` decimal(13,2) default NULL, -- the estimated cost for this line item
-  `gstrate` decimal(6,4) default NULL, -- the tax rate for this line item
-  `discount` float(6,4) default NULL, -- the discount for this line item
+  `rrp` decimal(13,2) DEFAULT NULL, -- the replacement cost for this line item
+  `rrp_tax_excluded` decimal(28,6) default NULL, -- the replacement cost excluding tax
+  `rrp_tax_included` decimal(28,6) default NULL, -- the replacement cost including tax
+  `ecost` decimal(13,2) DEFAULT NULL, -- the replacement cost for this line item
+  `ecost_tax_excluded` decimal(28,6) default NULL, -- the estimated cost excluding tax
+  `ecost_tax_included` decimal(28,6) default NULL, -- the estimated cost including tax
+  `tax_rate_bak` decimal(6,4) DEFAULT NULL, -- the tax rate for this line item (%)
+  `tax_rate_on_ordering` decimal(6,4) DEFAULT NULL, -- the tax rate on ordering for this line item (%)
+  `tax_rate_on_receiving` decimal(6,4) DEFAULT NULL, -- the tax rate on receiving for this line item (%)
+  `tax_value_bak` decimal(28,6) default NULL, -- the tax value for this line item
+  `tax_value_on_ordering` decimal(28,6) DEFAULT NULL, -- the tax value on ordering for this line item
+  `tax_value_on_receiving` decimal(28,6) DEFAULT NULL, -- the tax value on receiving for this line item
+  `discount` float(6,4) default NULL, -- the discount for this line item (%)
   `budget_id` int(11) NOT NULL, -- the fund this order goes against (aqbudgets.budget_id)
-  `budgetgroup_id` int(11) NOT NULL, -- not used? always zero
   `budgetdate` date default NULL, -- not used? always NULL
   `sort1` varchar(80) default NULL, -- statistical field
   `sort2` varchar(80) default NULL, -- second statistical field
@@ -3203,108 +3232,28 @@ CREATE TABLE aqorder_users ( -- Mapping orders to patrons for notification sendi
 DROP TABLE IF EXISTS `aqorders_items`;
 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisitions process
   `ordernumber` int(11) NOT NULL, -- the order this item is attached to (aqorders.ordernumber)
-  `itemnumber` int(11) NOT NULL, -- the item number for this item (items.itemnumber)
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order item was last touched
-  PRIMARY KEY  (`itemnumber`),
-  KEY `ordernumber` (`ordernumber`),
-  CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-
---
--- Table structure for table aqorders_transfers
---
-
-DROP TABLE IF EXISTS aqorders_transfers;
-CREATE TABLE aqorders_transfers (
-  ordernumber_from int(11) NULL,
-  ordernumber_to int(11) NULL,
-  timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  UNIQUE KEY ordernumber_from (ordernumber_from),
-  UNIQUE KEY ordernumber_to (ordernumber_to),
-  CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
-  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table vendor_edi_accounts
---
-
-DROP TABLE IF EXISTS vendor_edi_accounts;
-CREATE TABLE IF NOT EXISTS vendor_edi_accounts (
-  id INT(11) NOT NULL auto_increment,
-  description TEXT NOT NULL,
-  host VARCHAR(40),
-  username VARCHAR(40),
-  password VARCHAR(40),
-  last_activity DATE,
-  vendor_id INT(11) REFERENCES aqbooksellers( id ),
-  download_directory TEXT,
-  upload_directory TEXT,
-  san VARCHAR(20),
-  id_code_qualifier VARCHAR(3) default '14',
-  transport VARCHAR(6) default 'FTP',
-  quotes_enabled TINYINT(1) not null default 0,
-  invoices_enabled TINYINT(1) not null default 0,
-  orders_enabled TINYINT(1) not null default 0,
-  responses_enabled TINYINT(1) not null default 0,
-  auto_orders TINYINT(1) not null default 0,
-  shipment_budget INTEGER(11) REFERENCES aqbudgets( budget_id ),
-  plugin varchar(256) NOT NULL DEFAULT "",
-  PRIMARY KEY  (id),
-  KEY vendorid (vendor_id),
-  KEY shipmentbudget (shipment_budget),
-  CONSTRAINT vfk_vendor_id FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ),
-  CONSTRAINT vfk_shipment_budget FOREIGN KEY ( shipment_budget ) REFERENCES aqbudgets ( budget_id )
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
---
--- Table structure for table edifact_messages
---
-
-DROP TABLE IF EXISTS edifact_messages;
-CREATE TABLE IF NOT EXISTS edifact_messages (
-  id INT(11) NOT NULL auto_increment,
-  message_type VARCHAR(10) NOT NULL,
-  transfer_date DATE,
-  vendor_id INT(11) REFERENCES aqbooksellers( id ),
-  edi_acct  INTEGER REFERENCES vendor_edi_accounts( id ),
-  status TEXT,
-  basketno INT(11) REFERENCES aqbasket( basketno),
-  raw_msg MEDIUMTEXT,
-  filename TEXT,
-  deleted BOOLEAN NOT NULL DEFAULT 0,
-  PRIMARY KEY  (id),
-  KEY vendorid ( vendor_id),
-  KEY ediacct (edi_acct),
-  KEY basketno ( basketno),
-  CONSTRAINT emfk_vendor FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT emfk_edi_acct FOREIGN KEY ( edi_acct ) REFERENCES vendor_edi_accounts ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT emfk_basketno FOREIGN KEY ( basketno ) REFERENCES aqbasket ( basketno ) ON DELETE CASCADE ON UPDATE CASCADE
+  `itemnumber` int(11) NOT NULL, -- the item number for this item (items.itemnumber)
+  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order item was last touched
+  PRIMARY KEY  (`itemnumber`),
+  KEY `ordernumber` (`ordernumber`),
+  CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table aqinvoices
+-- Table structure for table aqorders_transfers
 --
 
-DROP TABLE IF EXISTS aqinvoices;
-CREATE TABLE aqinvoices (
-  invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
-  invoicenumber mediumtext NOT NULL,    -- Name of invoice
-  booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
-  shipmentdate date default NULL,   -- date of shipment
-  billingdate date default NULL,    -- date of billing
-  closedate date default NULL,  -- invoice close date, NULL means the invoice is open
-  shipmentcost decimal(28,6) default NULL,  -- shipment cost
-  shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
-  message_id int(11) default NULL, -- foreign key to edifact invoice message
-  PRIMARY KEY (invoiceid),
-  CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT edifact_msg_fk FOREIGN KEY ( message_id ) REFERENCES edifact_messages ( id ) ON DELETE SET NULL,
-  CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
+DROP TABLE IF EXISTS aqorders_transfers;
+CREATE TABLE aqorders_transfers (
+  ordernumber_from int(11) NULL,
+  ordernumber_to int(11) NULL,
+  timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  UNIQUE KEY ordernumber_from (ordernumber_from),
+  UNIQUE KEY ordernumber_to (ordernumber_to),
+  CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
+  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
-
 --
 -- Table structure for table `fieldmapping`
 --
@@ -3475,6 +3424,7 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` (
   `categorycode` varchar(10) DEFAULT NULL,
   `dateenrolled` date DEFAULT NULL,
   `dateexpiry` date DEFAULT NULL,
+  `date_renewed` date default NULL,
   `gonenoaddress` tinyint(1) DEFAULT NULL,
   `lost` tinyint(1) DEFAULT NULL,
   `debarred` date DEFAULT NULL,
@@ -3504,6 +3454,7 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` (
   `altcontactphone` varchar(50) DEFAULT NULL,
   `smsalertnumber` varchar(50) DEFAULT NULL,
   `privacy` int(11) DEFAULT NULL,
+  `extended_attributes` text DEFAULT NULL,
   PRIMARY KEY (`verification_token`,`borrowernumber`),
   KEY `verification_token` (`verification_token`),
   KEY `borrowernumber` (`borrowernumber`)
@@ -3683,7 +3634,7 @@ CREATE TABLE items_search_fields (
   authorised_values_category VARCHAR(32) NULL DEFAULT NULL,
   PRIMARY KEY(name),
   CONSTRAINT items_search_fields_authorised_values_category
-    FOREIGN KEY (authorised_values_category) REFERENCES authorised_values (category)
+    FOREIGN KEY (authorised_values_category) REFERENCES authorised_value_categories (category_name)
     ON DELETE SET NULL ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
@@ -3707,6 +3658,7 @@ CREATE TABLE discharges (
 -- This table add the ability to add new fields for a record
 --
 
+DROP TABLE IF EXISTS additional_fields;
 CREATE TABLE `additional_fields` (
   `id` int(11) NOT NULL AUTO_INCREMENT, -- primary key identifier
   `tablename` varchar(255) NOT NULL DEFAULT '', -- tablename of the new field
@@ -3723,6 +3675,7 @@ CREATE TABLE `additional_fields` (
 -- This table store values for additional fields
 --
 
+DROP TABLE IF EXISTS additional_field_values;
 CREATE TABLE `additional_field_values` (
   `id` int(11) NOT NULL AUTO_INCREMENT, -- primary key identifier
   `field_id` int(11) NOT NULL, -- foreign key references additional_fields(id)
@@ -3776,6 +3729,383 @@ CREATE TABLE IF NOT EXISTS edifact_ean (
   CONSTRAINT efk_branchcode FOREIGN KEY ( branchcode ) REFERENCES branches ( branchcode )
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
+--
+-- Table structure for table `courses`
+--
+
+-- The courses table stores the courses created for the
+-- course reserves feature.
+
+DROP TABLE IF EXISTS courses;
+CREATE TABLE `courses` (
+  `course_id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the course
+  `department` varchar(80) DEFAULT NULL, -- the authorised value for the DEPARTMENT
+  `course_number` varchar(255) DEFAULT NULL, -- the "course number" assigned to a course
+  `section` varchar(255) DEFAULT NULL, -- the 'section' of a course
+  `course_name` varchar(255) DEFAULT NULL, -- the name of the course
+  `term` varchar(80) DEFAULT NULL, -- the authorised value for the TERM
+  `staff_note` mediumtext, -- the text of the staff only note
+  `public_note` mediumtext, -- the text of the public / opac note
+  `students_count` varchar(20) DEFAULT NULL, -- how many students will be taking this course/section
+  `enabled` enum('yes','no') NOT NULL DEFAULT 'yes', -- determines whether the course is active
+  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+   PRIMARY KEY (`course_id`)
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `course_instructors`
+--
+
+-- The course instructors table links Koha borrowers to the
+-- courses they are teaching. Many instructors can teach many
+-- courses. course_instructors is just a many-to-many join table.
+
+DROP TABLE IF EXISTS course_instructors;
+CREATE TABLE `course_instructors` (
+  `course_id` int(11) NOT NULL, -- foreign key to link to courses.course_id
+  `borrowernumber` int(11) NOT NULL, -- foreign key to link to borrowers.borrowernumber for instructor information
+  PRIMARY KEY (`course_id`,`borrowernumber`),
+  KEY `borrowernumber` (`borrowernumber`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Constraints for table `course_instructors`
+--
+ALTER TABLE `course_instructors`
+  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
+  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+--
+-- Table structure for table `course_items`
+--
+
+-- If an item is placed on course reserve for one or more courses
+-- it will have an entry in this table. No matter how many courses an item
+-- is part of, it will only have one row in this table.
+
+DROP TABLE IF EXISTS course_items;
+CREATE TABLE `course_items` (
+  `ci_id` int(11) NOT NULL AUTO_INCREMENT, -- course item id
+  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
+  `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
+  `ccode` varchar(10) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
+  `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
+  `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
+  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- if at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
+  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+   PRIMARY KEY (`ci_id`),
+   UNIQUE KEY `itemnumber` (`itemnumber`),
+   KEY `holdingbranch` (`holdingbranch`)
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Constraints for table `course_items`
+--
+ALTER TABLE `course_items`
+  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
+  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+--
+-- Table structure for table `course_reserves`
+--
+
+-- This table connects an item placed on course reserve to a course it is on reserve for.
+-- There will be a row in this table for each course an item is on reserve for.
+
+DROP TABLE IF EXISTS course_reserves;
+CREATE TABLE `course_reserves` (
+  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
+  `course_id` int(11) NOT NULL, -- foreign key to link to courses.course_id
+  `ci_id` int(11) NOT NULL, -- foreign key to link to courses_items.ci_id
+  `staff_note` mediumtext, -- staff only note
+  `public_note` mediumtext, -- public, OPAC visible note
+  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+   PRIMARY KEY (`cr_id`),
+   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
+   KEY `course_id` (`course_id`)
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Constraints for table `course_reserves`
+--
+ALTER TABLE `course_reserves`
+  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
+  ADD CONSTRAINT `course_reserves_ibfk_2` FOREIGN KEY (`ci_id`) REFERENCES `course_items` (`ci_id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+--
+-- Table structure for table `hold_fill_targets`
+--
+
+DROP TABLE IF EXISTS `hold_fill_targets`;
+CREATE TABLE `hold_fill_targets` (
+  `borrowernumber` int(11) NOT NULL,
+  `biblionumber` int(11) NOT NULL,
+  `itemnumber` int(11) NOT NULL,
+  `source_branchcode`  varchar(10) default NULL,
+  `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`)
+    REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  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`)
+    REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
+    REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `housebound_profile`
+--
+
+DROP TABLE IF EXISTS `housebound_profile`;
+CREATE TABLE `housebound_profile` (
+  `borrowernumber` int(11) NOT NULL, -- Number of the borrower associated with this profile.
+  `day` text NOT NULL,  -- The preferred day of the week for delivery.
+  `frequency` text NOT NULL, -- The Authorised_Value definining the pattern for delivery.
+  `fav_itemtypes` text default NULL, -- Free text describing preferred itemtypes.
+  `fav_subjects` text default NULL, -- Free text describing preferred subjects.
+  `fav_authors` text default NULL, -- Free text describing preferred authors.
+  `referral` text default NULL, -- Free text indicating how the borrower was added to the service.
+  `notes` text default NULL, -- Free text for additional notes.
+  PRIMARY KEY  (`borrowernumber`),
+  CONSTRAINT `housebound_profile_bnfk`
+    FOREIGN KEY (`borrowernumber`)
+    REFERENCES `borrowers` (`borrowernumber`)
+    ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `housebound_visit`
+--
+
+DROP TABLE IF EXISTS `housebound_visit`;
+CREATE TABLE `housebound_visit` (
+  `id` int(11) NOT NULL auto_increment, -- ID of the visit.
+  `borrowernumber` int(11) NOT NULL, -- Number of the borrower, & the profile, linked to this visit.
+  `appointment_date` date default NULL, -- Date of visit.
+  `day_segment` varchar(10),  -- Rough time frame: 'morning', 'afternoon' 'evening'
+  `chooser_brwnumber` int(11) default NULL, -- Number of the borrower to choose items  for delivery.
+  `deliverer_brwnumber` int(11) default NULL, -- Number of the borrower to deliver items.
+  PRIMARY KEY  (`id`),
+  CONSTRAINT `houseboundvisit_bnfk`
+    FOREIGN KEY (`borrowernumber`)
+    REFERENCES `housebound_profile` (`borrowernumber`)
+    ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT `houseboundvisit_bnfk_1`
+    FOREIGN KEY (`chooser_brwnumber`)
+    REFERENCES `borrowers` (`borrowernumber`)
+    ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT `houseboundvisit_bnfk_2`
+    FOREIGN KEY (`deliverer_brwnumber`)
+    REFERENCES `borrowers` (`borrowernumber`)
+    ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `housebound_role`
+--
+
+DROP TABLE IF EXISTS `housebound_role`;
+CREATE TABLE IF NOT EXISTS `housebound_role` (
+  `borrowernumber_id` int(11) NOT NULL, -- borrowernumber link
+  `housebound_chooser` tinyint(1) NOT NULL DEFAULT 0, -- set to 1 to indicate this patron is a housebound chooser volunteer
+  `housebound_deliverer` tinyint(1) NOT NULL DEFAULT 0, -- set to 1 to indicate this patron is a housebound deliverer volunteer
+  PRIMARY KEY (`borrowernumber_id`),
+  CONSTRAINT `houseboundrole_bnfk`
+    FOREIGN KEY (`borrowernumber_id`)
+    REFERENCES `borrowers` (`borrowernumber`)
+    ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'article_requests'
+--
+
+CREATE TABLE `article_requests` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `borrowernumber` int(11) NOT NULL,
+  `biblionumber` int(11) NOT NULL,
+  `itemnumber` int(11) DEFAULT NULL,
+  `branchcode` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
+  `title` text,
+  `author` text,
+  `volume` text,
+  `issue` text,
+  `date` text,
+  `pages` text,
+  `chapters` text,
+  `patron_notes` text,
+  `status` enum('PENDING','PROCESSING','COMPLETED','CANCELED') NOT NULL DEFAULT 'PENDING',
+  `notes` text,
+  `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `updated_on` timestamp NULL DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `borrowernumber` (`borrowernumber`),
+  KEY `biblionumber` (`biblionumber`),
+  KEY `itemnumber` (`itemnumber`),
+  KEY `branchcode` (`branchcode`),
+  CONSTRAINT `article_requests_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `article_requests_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `article_requests_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
+  CONSTRAINT `article_requests_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `biblio_metadata`
+--
+
+CREATE TABLE biblio_metadata (
+    `id` INT(11) NOT NULL AUTO_INCREMENT,
+    `biblionumber` INT(11) NOT NULL,
+    `format` VARCHAR(16) NOT NULL,
+    `marcflavour` VARCHAR(16) NOT NULL,
+    `metadata` LONGTEXT NOT NULL,
+    PRIMARY KEY(id),
+    UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`),
+    CONSTRAINT `record_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table `deletedbiblio_metadata`
+--
+
+CREATE TABLE deletedbiblio_metadata (
+    `id` INT(11) NOT NULL AUTO_INCREMENT,
+    `biblionumber` INT(11) NOT NULL,
+    `format` VARCHAR(16) NOT NULL,
+    `marcflavour` VARCHAR(16) NOT NULL,
+    `metadata` LONGTEXT NOT NULL,
+    PRIMARY KEY(id),
+    UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`),
+    CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'club_templates'
+--
+
+CREATE TABLE IF NOT EXISTS club_templates (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  `name` tinytext NOT NULL,
+  description text,
+  is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
+  is_email_required tinyint(1) NOT NULL DEFAULT '0',
+  branchcode varchar(10) NULL DEFAULT NULL,
+  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  date_updated timestamp NULL DEFAULT NULL,
+  is_deletable tinyint(1) NOT NULL DEFAULT '1',
+  PRIMARY KEY (id),
+  KEY ct_branchcode (branchcode),
+  CONSTRAINT `club_templates_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'clubs'
+--
+
+CREATE TABLE IF NOT EXISTS clubs (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  club_template_id int(11) NOT NULL,
+  `name` tinytext NOT NULL,
+  description text,
+  date_start date DEFAULT NULL,
+  date_end date DEFAULT NULL,
+  branchcode varchar(10) NULL DEFAULT NULL,
+  date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  date_updated timestamp NULL DEFAULT NULL,
+  PRIMARY KEY (id),
+  KEY club_template_id (club_template_id),
+  KEY branchcode (branchcode),
+  CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'club_enrollments'
+--
+
+CREATE TABLE IF NOT EXISTS club_enrollments (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  club_id int(11) NOT NULL,
+  borrowernumber int(11) NOT NULL,
+  date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  date_canceled timestamp NULL DEFAULT NULL,
+  date_created timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+  date_updated timestamp NULL DEFAULT NULL,
+  branchcode varchar(10) NULL DEFAULT NULL,
+  PRIMARY KEY (id),
+  KEY club_id (club_id),
+  KEY borrowernumber (borrowernumber),
+  KEY branchcode (branchcode),
+  CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'club_template_enrollment_fields'
+--
+
+CREATE TABLE IF NOT EXISTS club_template_enrollment_fields (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  club_template_id int(11) NOT NULL,
+  `name` tinytext NOT NULL,
+  description text,
+  authorised_value_category varchar(16) DEFAULT NULL,
+  PRIMARY KEY (id),
+  KEY club_template_id (club_template_id),
+  CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'club_enrollment_fields'
+--
+
+CREATE TABLE IF NOT EXISTS club_enrollment_fields (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  club_enrollment_id int(11) NOT NULL,
+  club_template_enrollment_field_id int(11) NOT NULL,
+  `value` text NOT NULL,
+  PRIMARY KEY (id),
+  KEY club_enrollment_id (club_enrollment_id),
+  KEY club_template_enrollment_field_id (club_template_enrollment_field_id),
+  CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment_id) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field_id) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'club_template_fields'
+--
+
+CREATE TABLE IF NOT EXISTS club_template_fields (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  club_template_id int(11) NOT NULL,
+  `name` tinytext NOT NULL,
+  description text,
+  authorised_value_category varchar(16) DEFAULT NULL,
+  PRIMARY KEY (id),
+  KEY club_template_id (club_template_id),
+  CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+--
+-- Table structure for table 'club_fields'
+--
+
+CREATE TABLE IF NOT EXISTS club_fields (
+  id int(11) NOT NULL AUTO_INCREMENT,
+  club_template_field_id int(11) NOT NULL,
+  club_id int(11) NOT NULL,
+  `value` text,
+  PRIMARY KEY (id),
+  KEY club_template_field_id (club_template_field_id),
+  KEY club_id (club_id),
+  CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field_id) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;