Increment version for 3.22.11 release
[koha.git] / installer / data / mysql / kohastructure.sql
1 -- MySQL dump 10.9
2 --
3 -- Host: localhost    Database: koha30test
4 -- ------------------------------------------------------
5 -- Server version    4.1.22
6
7 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10 /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
11 /*!40101 SET NAMES utf8 */;
12 /*!40103 SET TIME_ZONE='+00:00' */;
13 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17
18 --
19 -- Table structure for table `auth_header`
20 --
21
22 DROP TABLE IF EXISTS `auth_header`;
23 CREATE TABLE `auth_header` (
24   `authid` bigint(20) unsigned NOT NULL auto_increment,
25   `authtypecode` varchar(10) NOT NULL default '',
26   `datecreated` date default NULL,
27   `modification_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
28   `origincode` varchar(20) default NULL,
29   `authtrees` mediumtext,
30   `marc` blob,
31   `linkid` bigint(20) default NULL,
32   `marcxml` longtext NOT NULL,
33   PRIMARY KEY  (`authid`),
34   KEY `origincode` (`origincode`)
35 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
36
37 --
38 -- Table structure for table `auth_types`
39 --
40
41 DROP TABLE IF EXISTS `auth_types`;
42 CREATE TABLE `auth_types` (
43   `authtypecode` varchar(10) NOT NULL default '',
44   `authtypetext` varchar(255) NOT NULL default '',
45   `auth_tag_to_report` varchar(3) NOT NULL default '',
46   `summary` mediumtext NOT NULL,
47   PRIMARY KEY  (`authtypecode`)
48 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
49
50 --
51 -- Table structure for table `auth_subfield_structure`
52 --
53
54 DROP TABLE IF EXISTS `auth_subfield_structure`;
55 CREATE TABLE `auth_subfield_structure` (
56   `authtypecode` varchar(10) NOT NULL default '',
57   `tagfield` varchar(3) NOT NULL default '',
58   `tagsubfield` varchar(1) NOT NULL default '',
59   `liblibrarian` varchar(255) NOT NULL default '',
60   `libopac` varchar(255) NOT NULL default '',
61   `repeatable` tinyint(4) NOT NULL default 0,
62   `mandatory` tinyint(4) NOT NULL default 0,
63   `tab` tinyint(1) default NULL,
64   `authorised_value` varchar(10) default NULL,
65   `value_builder` varchar(80) default NULL,
66   `seealso` varchar(255) default NULL,
67   `isurl` tinyint(1) default NULL,
68   `hidden` tinyint(3) NOT NULL default 0,
69   `linkid` tinyint(1) NOT NULL default 0,
70   `kohafield` varchar(45) NULL default '',
71   `frameworkcode` varchar(10) NOT NULL default '',
72   `defaultvalue` TEXT,
73   PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
74   KEY `tab` (`authtypecode`,`tab`),
75   CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
76 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
77
78 --
79 -- Table structure for table `auth_tag_structure`
80 --
81
82 DROP TABLE IF EXISTS `auth_tag_structure`;
83 CREATE TABLE `auth_tag_structure` (
84   `authtypecode` varchar(10) NOT NULL default '',
85   `tagfield` varchar(3) NOT NULL default '',
86   `liblibrarian` varchar(255) NOT NULL default '',
87   `libopac` varchar(255) NOT NULL default '',
88   `repeatable` tinyint(4) NOT NULL default 0,
89   `mandatory` tinyint(4) NOT NULL default 0,
90   `authorised_value` varchar(10) default NULL,
91   PRIMARY KEY  (`authtypecode`,`tagfield`),
92   CONSTRAINT `auth_tag_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
93 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
94
95 --
96 -- Table structure for table `authorised_values`
97 --
98
99 DROP TABLE IF EXISTS `authorised_values`;
100 CREATE TABLE `authorised_values` ( -- stores values for authorized values categories and values
101   `id` int(11) NOT NULL auto_increment, -- unique key, used to identify the authorized value
102   `category` varchar(32) NOT NULL default '', -- key used to identify the authorized value category
103   `authorised_value` varchar(80) NOT NULL default '', -- code use to identify the authorized value
104   `lib` varchar(200) default NULL, -- authorized value description as printed in the staff client
105   `lib_opac` varchar(200) default NULL, -- authorized value description as printed in the OPAC
106   `imageurl` varchar(200) default NULL, -- authorized value URL
107   PRIMARY KEY  (`id`),
108   KEY `name` (`category`),
109   KEY `lib` (`lib`),
110   KEY `auth_value_idx` (`authorised_value`)
111 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
112
113 --
114 -- Table structure for table `biblio`
115 --
116
117 DROP TABLE IF EXISTS `biblio`;
118 CREATE TABLE `biblio` ( -- table that stores bibliographic information
119   `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
120   `frameworkcode` varchar(4) NOT NULL default '', -- foreign key from the biblio_framework table to identify which framework was used in cataloging this record
121   `author` mediumtext, -- statement of responsibility from MARC record (100$a in MARC21)
122   `title` mediumtext, -- title (without the subtitle) from the MARC record (245$a in MARC21)
123   `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
124   `notes` mediumtext, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
125   `serial` tinyint(1) default NULL, -- Boolean indicating whether biblio is for a serial
126   `seriestitle` mediumtext,
127   `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
128   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
129   `datecreated` DATE NOT NULL, -- the date this record was added to Koha
130   `abstract` mediumtext, -- summary from the MARC record (520$a in MARC21)
131   PRIMARY KEY  (`biblionumber`),
132   KEY `blbnoidx` (`biblionumber`)
133 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
134
135 --
136 -- Table structure for table `biblio_framework`
137 --
138
139 DROP TABLE IF EXISTS `biblio_framework`;
140 CREATE TABLE `biblio_framework` ( -- information about MARC frameworks
141   `frameworkcode` varchar(4) NOT NULL default '', -- the unique code assigned to the framework
142   `frameworktext` varchar(255) NOT NULL default '', -- the description/name given to the framework
143   PRIMARY KEY  (`frameworkcode`)
144 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
145
146 --
147 -- Table structure for table `biblioitems`
148 --
149
150 DROP TABLE IF EXISTS `biblioitems`;
151 CREATE TABLE `biblioitems` ( -- information related to bibliographic records in Koha
152   `biblioitemnumber` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha
153   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking this table to the biblio table
154   `volume` mediumtext,
155   `number` mediumtext,
156   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
157   `isbn` mediumtext, -- ISBN (MARC21 020$a)
158   `issn` mediumtext, -- ISSN (MARC21 022$a)
159   `ean` varchar(13) default NULL,
160   `publicationyear` text,
161   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
162   `volumedate` date default NULL,
163   `volumedesc` text, -- volume information (MARC21 362$a)
164   `collectiontitle` mediumtext default NULL,
165   `collectionissn` text default NULL,
166   `collectionvolume` mediumtext default NULL,
167   `editionstatement` text default NULL,
168   `editionresponsibility` text default NULL,
169   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
170   `illus` varchar(255) default NULL, -- illustrations (MARC21 300$b)
171   `pages` varchar(255) default NULL, -- number of pages (MARC21 300$c)
172   `notes` mediumtext,
173   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
174   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
175   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
176   `marc` longblob, -- full bibliographic MARC record
177   `url` text default NULL, -- url (MARC21 856$u)
178   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
179   `cn_class` varchar(30) default NULL,
180   `cn_item` varchar(10) default NULL,
181   `cn_suffix` varchar(10) default NULL,
182   `cn_sort` varchar(255) default NULL, -- normalized version of the call number used for sorting
183   `agerestriction` varchar(255) default NULL, -- target audience/age restriction from the bib record (MARC21 521$a)
184   `totalissues` int(10),
185   `marcxml` longtext, -- full bibliographic MARC record in MARCXML
186   PRIMARY KEY  (`biblioitemnumber`),
187   KEY `bibinoidx` (`biblioitemnumber`),
188   KEY `bibnoidx` (`biblionumber`),
189   KEY `itemtype_idx` (`itemtype`),
190   KEY `isbn` (`isbn`(255)),
191   KEY `issn` (`issn`(255)),
192   KEY `publishercode` (`publishercode`),
193   CONSTRAINT `biblioitems_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
194 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
195
196 --
197 -- Table structure for table `borrower_attribute_types`
198 --
199
200 DROP TABLE IF EXISTS `borrower_attribute_types`;
201 CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron fields known as extended patron attributes
202   `code` varchar(10) NOT NULL, -- unique key used to identify each custom field
203   `description` varchar(255) NOT NULL, -- description for each custom field
204   `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)
205   `unique_id` tinyint(1) NOT NULL default 0, -- defines if this value needs to be unique (1 for yes, 0 for no)
206   `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)
207   `password_allowed` tinyint(1) NOT NULL default 0, -- defines if it is possible to associate a password with this custom field (1 for yes, 0 for no)
208   `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)
209   `authorised_value_category` varchar(32) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
210   `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
211   `category_code` VARCHAR(10) NULL DEFAULT NULL,-- defines a category for an attribute_type
212   `class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type
213   PRIMARY KEY  (`code`),
214   KEY `auth_val_cat_idx` (`authorised_value_category`)
215 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
216
217 --
218 -- Table structure for table `branchcategories`
219 --
220
221 DROP TABLE IF EXISTS `branchcategories`;
222 CREATE TABLE `branchcategories` ( -- information related to library/branch groups
223   `categorycode` varchar(10) NOT NULL default '', -- unique identifier for the library/branch group
224   `categoryname` varchar(32), -- name of the library/branch group
225   `codedescription` mediumtext, -- longer description of the library/branch group
226   `categorytype` varchar(16), -- says whether this is a search group or a properties group
227   `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled
228   PRIMARY KEY  (`categorycode`),
229   KEY `show_in_pulldown` (`show_in_pulldown`)
230 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
231
232 --
233 -- Table structure for table `branches`
234 --
235
236 DROP TABLE IF EXISTS `branches`;
237 CREATE TABLE `branches` ( -- information about your libraries or branches are stored here
238   `branchcode` varchar(10) NOT NULL default '', -- a unique key assigned to each branch
239   `branchname` mediumtext NOT NULL, -- the name of your library or branch
240   `branchaddress1` mediumtext, -- the first address line of for your library or branch
241   `branchaddress2` mediumtext, -- the second address line of for your library or branch
242   `branchaddress3` mediumtext, -- the third address line of for your library or branch
243   `branchzip` varchar(25) default NULL, -- the zip or postal code for your library or branch
244   `branchcity` mediumtext, -- the city or province for your library or branch
245   `branchstate` mediumtext, -- the state for your library or branch
246   `branchcountry` text, -- the county for your library or branch
247   `branchphone` mediumtext, -- the primary phone for your library or branch
248   `branchfax` mediumtext, -- the fax number for your library or branch
249   `branchemail` mediumtext, -- the primary email address for your library or branch
250   `branchreplyto` mediumtext, -- the email to be used as a Reply-To
251   `branchreturnpath` mediumtext, -- the email to be used as Return-Path
252   `branchurl` mediumtext, -- the URL for your library or branch's website
253   `issuing` tinyint(4) default NULL, -- unused in Koha
254   `branchip` varchar(15) default NULL, -- the IP address for your library or branch
255   `branchprinter` varchar(100) default NULL, -- unused in Koha
256   `branchnotes` mediumtext, -- notes related to your library or branch
257   opac_info text, -- HTML that displays in OPAC
258   PRIMARY KEY (`branchcode`)
259 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
260
261 --
262 -- Table structure for table `branchrelations`
263 --
264
265 DROP TABLE IF EXISTS `branchrelations`;
266 CREATE TABLE `branchrelations` ( -- this table links libraries/branches to groups
267   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to identify the branch
268   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the branchcategories table to identify the group
269   PRIMARY KEY  (`branchcode`,`categorycode`),
270   KEY `branchcode` (`branchcode`),
271   KEY `categorycode` (`categorycode`),
272   CONSTRAINT `branchrelations_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
273   CONSTRAINT `branchrelations_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `branchcategories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
274 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
275
276 --
277 -- Table structure for table `browser`
278 --
279 DROP TABLE IF EXISTS `browser`;
280 CREATE TABLE `browser` (
281   `level` int(11) NOT NULL,
282   `classification` varchar(20) NOT NULL,
283   `description` varchar(255) NOT NULL,
284   `number` bigint(20) NOT NULL,
285   `endnode` tinyint(4) NOT NULL
286 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
287
288 --
289 -- Table structure for table `categories`
290 --
291
292 DROP TABLE IF EXISTS `categories`;
293 CREATE TABLE `categories` ( -- this table shows information related to Koha patron categories
294   `categorycode` varchar(10) NOT NULL default '', -- unique primary key used to idenfity the patron category
295   `description` mediumtext, -- description of the patron category
296   `enrolmentperiod` smallint(6) default NULL, -- number of months the patron is enrolled for (will be NULL if enrolmentperioddate is set)
297   `enrolmentperioddate` DATE NULL DEFAULT NULL, -- date the patron is enrolled until (will be NULL if enrolmentperiod is set)
298   `upperagelimit` smallint(6) default NULL, -- age limit for the patron
299   `dateofbirthrequired` tinyint(1) default NULL, -- the minimum age required for the patron category
300   `finetype` varchar(30) default NULL, -- unused in Koha
301   `bulk` tinyint(1) default NULL,
302   `enrolmentfee` decimal(28,6) default NULL, -- enrollment fee for the patron
303   `overduenoticerequired` tinyint(1) default NULL, -- are overdue notices sent to this patron category (1 for yes, 0 for no)
304   `issuelimit` smallint(6) default NULL, -- unused in Koha
305   `reservefee` decimal(28,6) default NULL, -- cost to place holds
306   `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
307   `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
308   `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
309   `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
310   PRIMARY KEY  (`categorycode`),
311   UNIQUE KEY `categorycode` (`categorycode`)
312 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
313
314 --
315 -- Table: collections
316 --
317 DROP TABLE IF EXISTS collections;
318 CREATE TABLE collections (
319   colId integer(11) NOT NULL auto_increment,
320   colTitle varchar(100) NOT NULL DEFAULT '',
321   colDesc text NOT NULL,
322   colBranchcode varchar(10) DEFAULT NULL, -- 'branchcode for branch where item should be held.'
323   PRIMARY KEY (colId)
324 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
325
326 --
327 -- Constraints for table `collections`
328 --
329 ALTER TABLE `collections`
330   ADD CONSTRAINT `collections_ibfk_1` FOREIGN KEY (`colBranchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE;
331
332 --
333 -- Table: collections_tracking
334 --
335
336 DROP TABLE IF EXISTS collections_tracking;
337 CREATE TABLE collections_tracking (
338   collections_tracking_id integer(11) NOT NULL auto_increment,
339   colId integer(11) NOT NULL DEFAULT 0 comment 'collections.colId',
340   itemnumber integer(11) NOT NULL DEFAULT 0 comment 'items.itemnumber',
341   PRIMARY KEY (collections_tracking_id)
342 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
343
344 --
345 -- Table structure for table `branch_borrower_circ_rules`
346 --
347
348 DROP TABLE IF EXISTS `branch_borrower_circ_rules`;
349 CREATE TABLE `branch_borrower_circ_rules` ( -- includes default circulation rules for patron categories found under "Checkout limit by patron category"
350   `branchcode` VARCHAR(10) NOT NULL, -- the branch this rule applies to (branches.branchcode)
351   `categorycode` VARCHAR(10) NOT NULL, -- the patron category this rule applies to (categories.categorycode)
352   `maxissueqty` int(4) default NULL, -- the maximum number of checkouts this patron category can have at this branch
353   `maxonsiteissueqty` int(4) default NULL, -- the maximum number of on-site checkouts this patron category can have at this branch
354   PRIMARY KEY (`categorycode`, `branchcode`),
355   CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
356     ON DELETE CASCADE ON UPDATE CASCADE,
357   CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
358     ON DELETE CASCADE ON UPDATE CASCADE
359 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
360
361 --
362 -- Table structure for table `default_borrower_circ_rules`
363 --
364
365 DROP TABLE IF EXISTS `default_borrower_circ_rules`;
366 CREATE TABLE `default_borrower_circ_rules` ( -- default checkout rules found under "Default checkout, hold and return policy"
367   `categorycode` VARCHAR(10) NOT NULL, -- patron category this rul
368   `maxissueqty` int(4) default NULL,
369   `maxonsiteissueqty` int(4) default NULL,
370   PRIMARY KEY (`categorycode`),
371   CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
372     ON DELETE CASCADE ON UPDATE CASCADE
373 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
374
375 --
376 -- Table structure for table `default_branch_circ_rules`
377 --
378
379 DROP TABLE IF EXISTS `default_branch_circ_rules`;
380 CREATE TABLE `default_branch_circ_rules` (
381   `branchcode` VARCHAR(10) NOT NULL,
382   `maxissueqty` int(4) default NULL,
383   `maxonsiteissueqty` int(4) default NULL,
384   `holdallowed` tinyint(1) default NULL,
385   `returnbranch` varchar(15) default NULL,
386   PRIMARY KEY (`branchcode`),
387   CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
388     ON DELETE CASCADE ON UPDATE CASCADE
389 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
390
391 --
392 -- Table structure for table `default_circ_rules`
393 --
394
395 DROP TABLE IF EXISTS `default_circ_rules`;
396 CREATE TABLE `default_circ_rules` (
397     `singleton` enum('singleton') NOT NULL default 'singleton',
398     `maxissueqty` int(4) default NULL,
399     `maxonsiteissueqty` int(4) default NULL,
400     `holdallowed` int(1) default NULL,
401     `returnbranch` varchar(15) default NULL,
402     PRIMARY KEY (`singleton`)
403 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
404
405 --
406 -- Table structure for table `cities`
407 --
408
409 DROP TABLE IF EXISTS `cities`;
410 CREATE TABLE `cities` ( -- authorized values for cities/states/countries to choose when adding/editing a patron/borrower
411   `cityid` int(11) NOT NULL auto_increment, -- unique identifier added by Koha
412   `city_name` varchar(100) NOT NULL default '', -- name of the city
413   `city_state` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the state/province
414   `city_country` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the country
415   `city_zipcode` varchar(20) default NULL, -- zip or postal code
416   PRIMARY KEY  (`cityid`)
417 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
418
419 --
420 -- Table structure for table `class_sort_rules`
421 --
422
423 DROP TABLE IF EXISTS `class_sort_rules`;
424 CREATE TABLE `class_sort_rules` (
425   `class_sort_rule` varchar(10) NOT NULL default '',
426   `description` mediumtext,
427   `sort_routine` varchar(30) NOT NULL default '',
428   PRIMARY KEY (`class_sort_rule`),
429   UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
430 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
431
432 --
433 -- Table structure for table `class_sources`
434 --
435
436 DROP TABLE IF EXISTS `class_sources`;
437 CREATE TABLE `class_sources` (
438   `cn_source` varchar(10) NOT NULL default '',
439   `description` mediumtext,
440   `used` tinyint(4) NOT NULL default 0,
441   `class_sort_rule` varchar(10) NOT NULL default '',
442   PRIMARY KEY (`cn_source`),
443   UNIQUE KEY `cn_source_idx` (`cn_source`),
444   KEY `used_idx` (`used`),
445   CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`)
446 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
447
448 --
449 -- Table structure for table `currency`
450 --
451
452 DROP TABLE IF EXISTS `currency`;
453 CREATE TABLE `currency` (
454   `currency` varchar(10) NOT NULL default '',
455   `symbol` varchar(5) default NULL,
456   `isocode` varchar(5) default NULL,
457   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
458   `rate` float(15,5) default NULL,
459   `active` tinyint(1) default NULL,
460   PRIMARY KEY  (`currency`)
461 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
462
463 --
464 -- Table structure for table `deletedbiblio`
465 --
466
467 DROP TABLE IF EXISTS `deletedbiblio`;
468 CREATE TABLE `deletedbiblio` ( -- stores information about bibliographic records that have been deleted
469   `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
470   `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
471   `author` mediumtext, -- statement of responsibility from MARC record (100$a in MARC21)
472   `title` mediumtext, -- title (without the subtitle) from the MARC record (245$a in MARC21)
473   `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
474   `notes` mediumtext, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
475   `serial` tinyint(1) default NULL, -- Boolean indicating whether biblio is for a serial
476   `seriestitle` mediumtext,
477   `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
478   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
479   `datecreated` DATE NOT NULL, -- the date this record was added to Koha
480   `abstract` mediumtext, -- summary from the MARC record (520$a in MARC21)
481   PRIMARY KEY  (`biblionumber`),
482   KEY `blbnoidx` (`biblionumber`)
483 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
484
485 --
486 -- Table structure for table `deletedbiblioitems`
487 --
488
489 DROP TABLE IF EXISTS `deletedbiblioitems`;
490 CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records that have been deleted
491   `biblioitemnumber` int(11) NOT NULL default 0, -- primary key, unique identifier assigned by Koha
492   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking this table to the biblio table
493   `volume` mediumtext,
494   `number` mediumtext,
495   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
496   `isbn` mediumtext default NULL, -- ISBN (MARC21 020$a)
497   `issn` mediumtext default NULL, -- ISSN (MARC21 022$a)
498   `ean` varchar(13) default NULL,
499   `publicationyear` text,
500   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
501   `volumedate` date default NULL,
502   `volumedesc` text, -- volume information (MARC21 362$a)
503   `collectiontitle` mediumtext default NULL,
504   `collectionissn` text default NULL,
505   `collectionvolume` mediumtext default NULL,
506   `editionstatement` text default NULL,
507   `editionresponsibility` text default NULL,
508   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
509   `illus` varchar(255) default NULL, -- illustrations (MARC21 300$b)
510   `pages` varchar(255) default NULL, -- number of pages (MARC21 300$c)
511   `notes` mediumtext,
512   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
513   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
514   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
515   `marc` longblob, -- full bibliographic MARC record
516   `url` text default NULL, -- url (MARC21 856$u)
517   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
518   `cn_class` varchar(30) default NULL,
519   `cn_item` varchar(10) default NULL,
520   `cn_suffix` varchar(10) default NULL,
521   `cn_sort` varchar(255) default NULL, -- normalized version of the call number used for sorting
522   `agerestriction` varchar(255) default NULL, -- target audience/age restriction from the bib record (MARC21 521$a)
523   `totalissues` int(10),
524   `marcxml` longtext, -- full bibliographic MARC record in MARCXML
525   PRIMARY KEY  (`biblioitemnumber`),
526   KEY `bibinoidx` (`biblioitemnumber`),
527   KEY `bibnoidx` (`biblionumber`),
528   KEY `itemtype_idx` (`itemtype`),
529   KEY `isbn` (`isbn`(255)),
530   KEY `publishercode` (`publishercode`)
531 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
532
533 --
534 -- Table structure for table `deletedborrowers`
535 --
536
537 DROP TABLE IF EXISTS `deletedborrowers`;
538 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrowers you have deleted
539   `borrowernumber` int(11) NOT NULL default 0, -- primary key, Koha assigned ID number for patrons/borrowers
540   `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
541   `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
542   `firstname` text, -- patron/borrower's first name
543   `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
544   `othernames` mediumtext, -- any other names associated with the patron/borrower
545   `initials` text, -- initials for your patron/borrower
546   `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
547   `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
548   `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
549   `address2` text, -- the second address line for your patron/borrower's primary address
550   `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
551   `state` text default NULL, -- the state or province for your patron/borrower's primary address
552   `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
553   `country` text, -- the country for your patron/borrower's primary address
554   `email` mediumtext, -- the primary email address for your patron/borrower's primary address
555   `phone` text, -- the primary phone number for your patron/borrower's primary address
556   `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
557   `fax` mediumtext, -- the fax number for your patron/borrower's primary address
558   `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
559   `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
560   `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
561   `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
562   `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
563   `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
564   `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
565   `B_state` text default NULL, -- the state for your patron/borrower's alternate address
566   `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
567   `B_country` text, -- the country for your patron/borrower's alternate address
568   `B_email` text, -- the patron/borrower's alternate email address
569   `B_phone` mediumtext, -- the patron/borrower's alternate phone number
570   `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
571   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
572   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
573   `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
574   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
575   `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
576   `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
577   `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)
578   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
579   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
580   `contactfirstname` text, -- used for children to include first name of guarentor
581   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
582   `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
583   `borrowernotes` mediumtext, -- a note on the patron/borrower's account that is only visible in the staff client
584   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
585   `sex` varchar(1) default NULL, -- patron/borrower's gender
586   `password` varchar(60) default NULL, -- patron/borrower's encrypted password
587   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
588   `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
589   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
590   `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
591   `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
592   `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
593   `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
594   `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
595   `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
596   `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
597   `altcontactaddress3` varchar(255) default NULL, -- the city for the alternate contact for the patron/borrower
598   `altcontactstate` text default NULL, -- the state for the alternate contact for the patron/borrower
599   `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
600   `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
601   `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
602   `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
603   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
604   `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)
605   KEY borrowernumber (borrowernumber),
606   KEY `cardnumber` (`cardnumber`)
607 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
608
609 --
610 -- Table structure for table `deleteditems`
611 --
612
613 DROP TABLE IF EXISTS `deleteditems`;
614 CREATE TABLE `deleteditems` (
615   `itemnumber` int(11) NOT NULL default 0, -- primary key and unique identifier added by Koha
616   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
617   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
618   `barcode` varchar(20) default NULL, -- item barcode (MARC21 952$p)
619   `dateaccessioned` date default NULL, -- date the item was acquired or added to Koha (MARC21 952$d)
620   `booksellerid` mediumtext default NULL, -- where the item was purchased (MARC21 952$e)
621   `homebranch` varchar(10) default NULL, -- foreign key from the branches table for the library that owns this item (MARC21 952$a)
622   `price` decimal(8,2) default NULL, -- purchase price (MARC21 952$g)
623   `replacementprice` decimal(8,2) default NULL, -- cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
624   `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
625   `datelastborrowed` date default NULL, -- the date the item was last checked out
626   `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
627   `stack` tinyint(1) default NULL,
628   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
629   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
630   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
631   `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
632   `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
633   `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
634   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
635   `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
636   `issues` smallint(6) default NULL, -- number of times this item has been checked out
637   `renewals` smallint(6) default NULL, -- number of times this item has been renewed
638   `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved
639   `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5)
640   `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x)
641   `itemnotes_nonpublic` mediumtext default NULL,
642   `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
643   `paidfor` mediumtext,
644   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
645   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
646   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
647   `onloan` date default NULL, -- defines if item is checked out (NULL for not checked out, and checkout date for checked out)
648   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
649   `cn_sort` varchar(255) default NULL, -- normalized form of the call number (MARC21 952$o) used for sorting
650   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
651   `materials` text default NULL, -- materials specified (MARC21 952$3)
652   `uri` varchar(255) default NULL, -- URL for the item (MARC21 952$u)
653   `itype` varchar(10) default NULL, -- foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
654   `more_subfields_xml` longtext default NULL, -- additional 952 subfields in XML format
655   `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h)
656   `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t)
657   `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i)
658   PRIMARY KEY  (`itemnumber`),
659   KEY `delitembarcodeidx` (`barcode`),
660   KEY `delitemstocknumberidx` (`stocknumber`),
661   KEY `delitembinoidx` (`biblioitemnumber`),
662   KEY `delitembibnoidx` (`biblionumber`),
663   KEY `delhomebranch` (`homebranch`),
664   KEY `delholdingbranch` (`holdingbranch`),
665   KEY `itype_idx` (`itype`)
666 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
667
668 --
669 -- Table structure for table `export_format`
670 --
671
672 DROP TABLE IF EXISTS `export_format`;
673 CREATE TABLE `export_format` (
674   `export_format_id` int(11) NOT NULL auto_increment,
675   `profile` varchar(255) NOT NULL,
676   `description` mediumtext NOT NULL,
677   `content` mediumtext NOT NULL,
678   `csv_separator` varchar(2) NOT NULL,
679   `field_separator` varchar(2) NOT NULL,
680   `subfield_separator` varchar(2) NOT NULL,
681   `encoding` varchar(255) NOT NULL,
682   `type` varchar(255) DEFAULT 'marc',
683   PRIMARY KEY  (`export_format_id`)
684 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Used for CSV export';
685
686 --
687 -- Table structure for table `import_batches`
688 --
689
690 DROP TABLE IF EXISTS `import_batches`;
691 CREATE TABLE `import_batches` ( -- information about batches of marc records that have been imported
692   `import_batch_id` int(11) NOT NULL auto_increment, -- unique identifier and primary key
693   `matcher_id` int(11) default NULL, -- the id of the match rule used (matchpoints.matcher_id)
694   `template_id` int(11) default NULL,
695   `branchcode` varchar(10) default NULL,
696   `num_records` int(11) NOT NULL default 0, -- number of records in the file
697   `num_items` int(11) NOT NULL default 0, -- number of items in the file
698   `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- date and time the file was uploaded
699   `overlay_action` enum('replace', 'create_new', 'use_template', 'ignore') NOT NULL default 'create_new', -- how to handle duplicate records
700   `nomatch_action` enum('create_new', 'ignore') NOT NULL default 'create_new', -- how to handle records where no match is found
701   `item_action` enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore', 'replace') NOT NULL default 'always_add', -- what to do with item records
702   `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging', -- the status of the imported file
703   `batch_type` enum('batch', 'z3950', 'webservice') NOT NULL default 'batch', -- where this batch has come from
704   `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio', -- type of record in the batch
705   `file_name` varchar(100), -- the name of the file uploaded
706   `comments` mediumtext, -- any comments added when the file was uploaded
707   PRIMARY KEY (`import_batch_id`),
708   KEY `branchcode` (`branchcode`)
709 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
710
711 --
712 -- Table structure for table `import_records`
713 --
714
715 DROP TABLE IF EXISTS `import_records`;
716 CREATE TABLE `import_records` (
717   `import_record_id` int(11) NOT NULL auto_increment,
718   `import_batch_id` int(11) NOT NULL,
719   `branchcode` varchar(10) default NULL,
720   `record_sequence` int(11) NOT NULL default 0,
721   `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
722   `import_date` DATE default NULL,
723   `marc` longblob NOT NULL,
724   `marcxml` longtext NOT NULL,
725   `marcxml_old` longtext NOT NULL,
726   `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
727   `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
728   `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted', 'ignored') NOT NULL default 'staged',
729   `import_error` mediumtext,
730   `encoding` varchar(40) NOT NULL default '',
731   `z3950random` varchar(40) default NULL,
732   PRIMARY KEY (`import_record_id`),
733   CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
734              REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
735   KEY `branchcode` (`branchcode`),
736   KEY `batch_sequence` (`import_batch_id`, `record_sequence`),
737   KEY `batch_id_record_type` (`import_batch_id`,`record_type`)
738 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
739
740 --
741 -- Table structure for `import_record_matches`
742 --
743 DROP TABLE IF EXISTS `import_record_matches`;
744 CREATE TABLE `import_record_matches` ( -- matches found when importing a batch of records
745   `import_record_id` int(11) NOT NULL, -- the id given to the imported bib record (import_records.import_record_id)
746   `candidate_match_id` int(11) NOT NULL, -- the biblio the imported record matches (biblio.biblionumber)
747   `score` int(11) NOT NULL default 0, -- the match score
748   CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
749              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
750   KEY `record_score` (`import_record_id`, `score`)
751 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
752
753 --
754 -- Table structure for table `import_auths`
755 --
756
757 DROP TABLE IF EXISTS `import_auths`;
758 CREATE TABLE `import_auths` (
759   `import_record_id` int(11) NOT NULL,
760   `matched_authid` int(11) default NULL,
761   `control_number` varchar(25) default NULL,
762   `authorized_heading` varchar(128) default NULL,
763   `original_source` varchar(25) default NULL,
764   CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`)
765              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
766   KEY `matched_authid` (`matched_authid`)
767 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
768
769 --
770 -- Table structure for table `import_biblios`
771 --
772
773 DROP TABLE IF EXISTS `import_biblios`;
774 CREATE TABLE `import_biblios` (
775   `import_record_id` int(11) NOT NULL,
776   `matched_biblionumber` int(11) default NULL,
777   `control_number` varchar(25) default NULL,
778   `original_source` varchar(25) default NULL,
779   `title` varchar(128) default NULL,
780   `author` varchar(80) default NULL,
781   `isbn` varchar(30) default NULL,
782   `issn` varchar(9) default NULL,
783   `has_items` tinyint(1) NOT NULL default 0,
784   CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
785              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
786   KEY `matched_biblionumber` (`matched_biblionumber`),
787   KEY `title` (`title`),
788   KEY `isbn` (`isbn`)
789 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
790
791 --
792 -- Table structure for table `import_items`
793 --
794
795 DROP TABLE IF EXISTS `import_items`;
796 CREATE TABLE `import_items` (
797   `import_items_id` int(11) NOT NULL auto_increment,
798   `import_record_id` int(11) NOT NULL,
799   `itemnumber` int(11) default NULL,
800   `branchcode` varchar(10) default NULL,
801   `status` enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged',
802   `marcxml` longtext NOT NULL,
803   `import_error` mediumtext,
804   PRIMARY KEY (`import_items_id`),
805   CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
806              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
807   KEY `itemnumber` (`itemnumber`),
808   KEY `branchcode` (`branchcode`)
809 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
810
811 --
812 -- Table structure for table `issuingrules`
813 --
814
815 DROP TABLE IF EXISTS `issuingrules`;
816 CREATE TABLE `issuingrules` ( -- circulation and fine rules
817   `categorycode` varchar(10) NOT NULL default '', -- patron category this rule is for (categories.categorycode)
818   `itemtype` varchar(10) NOT NULL default '', -- item type this rule is for (itemtypes.itemtype)
819   `restrictedtype` tinyint(1) default NULL, -- not used? always NULL
820   `rentaldiscount` decimal(28,6) default NULL, -- percent discount on the rental charge for this item
821   `reservecharge` decimal(28,6) default NULL,
822   `fine` decimal(28,6) default NULL, -- fine amount
823   `finedays` int(11) default NULL, -- suspension in days
824   `maxsuspensiondays` int(11) default NULL, -- max suspension days
825   `firstremind` int(11) default NULL, -- fine grace period
826   `chargeperiod` int(11) default NULL, -- how often the fine amount is charged
827   `chargeperiod_charge_at` tinyint(1) NOT NULL DEFAULT '0', -- Should fine be given at the start ( 1 ) or the end ( 0 ) of the period
828   `accountsent` int(11) default NULL, -- not used? always NULL
829   `chargename` varchar(100) default NULL, -- not used? always NULL
830   `maxissueqty` int(4) default NULL, -- total number of checkouts allowed
831   `maxonsiteissueqty` int(4) default NULL, -- total number of on-site checkouts allowed
832   `issuelength` int(4) default NULL, -- length of checkout in the unit set in issuingrules.lengthunit
833   `lengthunit` varchar(10) default 'days', -- unit of checkout length (days, hours)
834   `hardduedate` date default NULL, -- hard due date
835   `hardduedatecompare` tinyint NOT NULL default "0", -- type of hard due date (1 = after, 0 = on, -1 = before)
836   `renewalsallowed` smallint(6) NOT NULL default "0", -- how many renewals are allowed
837   `renewalperiod` int(4) default NULL, -- renewal period in the unit set in issuingrules.lengthunit
838   `norenewalbefore` int(4) default NULL, -- no renewal allowed until X days or hours before due date. In the unit set in issuingrules.lengthunit
839   `auto_renew` BOOLEAN default FALSE, -- automatic renewal
840   `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
841   `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
842   overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
843   onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
844   opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
845   PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
846   KEY `categorycode` (`categorycode`),
847   KEY `itemtype` (`itemtype`)
848 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
849
850 --
851 -- Table structure for table `items`
852 --
853
854 DROP TABLE IF EXISTS `items`;
855 CREATE TABLE `items` ( -- holdings/item information 
856   `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha
857   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
858   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
859   `barcode` varchar(20) default NULL, -- item barcode (MARC21 952$p)
860   `dateaccessioned` date default NULL, -- date the item was acquired or added to Koha (MARC21 952$d)
861   `booksellerid` mediumtext default NULL, -- where the item was purchased (MARC21 952$e)
862   `homebranch` varchar(10) default NULL, -- foreign key from the branches table for the library that owns this item (MARC21 952$a)
863   `price` decimal(8,2) default NULL, -- purchase price (MARC21 952$g)
864   `replacementprice` decimal(8,2) default NULL, -- cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
865   `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
866   `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
867   `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
868   `stack` tinyint(1) default NULL,
869   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
870   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
871   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
872   `itemlost_on` datetime DEFAULT NULL, -- the date and time an item was last marked as lost, NULL if not lost
873   `withdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
874   `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn
875   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
876   `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f)
877   `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
878   `renewals` smallint(6) default NULL, -- number of times this item has been renewed
879   `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved
880   `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5)
881   `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x)
882   `itemnotes_nonpublic` mediumtext default NULL,
883   `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
884   `paidfor` mediumtext,
885   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
886   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
887   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
888   `onloan` date default NULL, -- defines if item is checked out (NULL for not checked out, and checkout date for checked out)
889   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
890   `cn_sort` varchar(255) default NULL,  -- normalized form of the call number (MARC21 952$o) used for sorting
891   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
892   `materials` text default NULL, -- materials specified (MARC21 952$3)
893   `uri` varchar(255) default NULL, -- URL for the item (MARC21 952$u)
894   `itype` varchar(10) default NULL, -- foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
895   `more_subfields_xml` longtext default NULL, -- additional 952 subfields in XML format
896   `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h)
897   `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t)
898   `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i)
899   PRIMARY KEY  (`itemnumber`),
900   UNIQUE KEY `itembarcodeidx` (`barcode`),
901   KEY `itemstocknumberidx` (`stocknumber`),
902   KEY `itembinoidx` (`biblioitemnumber`),
903   KEY `itembibnoidx` (`biblionumber`),
904   KEY `homebranch` (`homebranch`),
905   KEY `holdingbranch` (`holdingbranch`),
906   KEY `itemcallnumber` (`itemcallnumber`),
907   KEY `items_location` (`location`),
908   KEY `items_ccode` (`ccode`),
909   KEY `itype_idx` (`itype`),
910   CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
911   CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
912   CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
913   CONSTRAINT `items_ibfk_4` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
914 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
915
916 --
917 -- Table structure for table `itemtypes`
918 --
919
920 DROP TABLE IF EXISTS `itemtypes`;
921 CREATE TABLE `itemtypes` ( -- defines the item types
922   itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
923   description mediumtext, -- a plain text explanation of the item type
924   rentalcharge double(16,4) default NULL, -- the amount charged when this item is checked out/issued
925   notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
926   imageurl varchar(200) default NULL, -- URL for the item type icon
927   summary text, -- information from the summary field, may include HTML
928   checkinmsg VARCHAR(255), -- message that is displayed when an item with the given item type is checked in
929   checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message"
930   sip_media_type VARCHAR(3) DEFAULT NULL, -- SIP2 protocol media type for this itemtype
931   hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC
932   searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options
933   PRIMARY KEY  (`itemtype`),
934   UNIQUE KEY `itemtype` (`itemtype`)
935 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
936
937 --
938 -- Table structure for table `default_branch_item_rules`
939 --
940
941 DROP TABLE IF EXISTS `default_branch_item_rules`;
942 CREATE TABLE `default_branch_item_rules` (
943   `itemtype` varchar(10) NOT NULL,
944   `holdallowed` tinyint(1) default NULL,
945   `returnbranch` varchar(15) default NULL,
946   PRIMARY KEY  (`itemtype`),
947   CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
948     ON DELETE CASCADE ON UPDATE CASCADE
949 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
950
951 --
952 -- Table structure for table `branchtransfers`
953 --
954
955 DROP TABLE IF EXISTS `branchtransfers`;
956 CREATE TABLE `branchtransfers` ( -- information for items that are in transit between branches
957   `itemnumber` int(11) NOT NULL default 0, -- the itemnumber that it is in transit (items.itemnumber)
958   `datesent` datetime default NULL, -- the date the transfer was initialized
959   `frombranch` varchar(10) NOT NULL default '', -- the branch the transfer is coming from
960   `datearrived` datetime default NULL, -- the date the transfer arrived at its destination
961   `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to
962   `comments` mediumtext, -- any comments related to the transfer
963   KEY `frombranch` (`frombranch`),
964   KEY `tobranch` (`tobranch`),
965   KEY `itemnumber` (`itemnumber`),
966   CONSTRAINT `branchtransfers_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
967   CONSTRAINT `branchtransfers_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
968   CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
969 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
970
971 --
972 -- Table structure for table `branch_item_rules`
973 --
974
975 DROP TABLE IF EXISTS `branch_item_rules`;
976 CREATE TABLE `branch_item_rules` ( -- information entered in the circulation and fine rules under 'Holds policy by item type'
977   `branchcode` varchar(10) NOT NULL, -- the branch this rule is for (branches.branchcode)
978   `itemtype` varchar(10) NOT NULL, -- the item type this rule applies to (items.itype)
979   `holdallowed` tinyint(1) default NULL, -- the number of holds allowed
980   `returnbranch` varchar(15) default NULL, -- the branch the item returns to (homebranch, holdingbranch, noreturn)
981   PRIMARY KEY  (`itemtype`,`branchcode`),
982   KEY `branch_item_rules_ibfk_2` (`branchcode`),
983   CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
984     ON DELETE CASCADE ON UPDATE CASCADE,
985   CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
986     ON DELETE CASCADE ON UPDATE CASCADE
987 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
988
989 --
990 -- Table structure for table `creator_images`
991 --
992
993 DROP TABLE IF EXISTS `creator_images`;
994 SET @saved_cs_client     = @@character_set_client;
995 SET character_set_client = utf8;
996 CREATE TABLE `creator_images` (
997   `image_id` int(4) NOT NULL AUTO_INCREMENT,
998   `imagefile` mediumblob,
999   `image_name` char(20) NOT NULL DEFAULT 'DEFAULT',
1000   PRIMARY KEY (`image_id`),
1001   UNIQUE KEY `image_name_index` (`image_name`)
1002 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1003
1004 --
1005 -- Table structure for table `creator_layouts`
1006 --
1007
1008 DROP TABLE IF EXISTS `creator_layouts`;
1009 SET @saved_cs_client     = @@character_set_client;
1010 SET character_set_client = utf8;
1011 CREATE TABLE `creator_layouts` (
1012   `layout_id` int(4) NOT NULL AUTO_INCREMENT,
1013   `barcode_type` char(100) NOT NULL DEFAULT 'CODE39',
1014   `start_label` int(2) NOT NULL DEFAULT '1',
1015   `printing_type` char(32) NOT NULL DEFAULT 'BAR',
1016   `layout_name` char(25) NOT NULL DEFAULT 'DEFAULT',
1017   `guidebox` int(1) DEFAULT '0',
1018   `oblique_title` int(1) DEFAULT '1',
1019   `font` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TR',
1020   `font_size` int(4) NOT NULL DEFAULT '10',
1021   `units` char(20) NOT NULL DEFAULT 'POINT',
1022   `callnum_split` int(1) DEFAULT '0',
1023   `text_justify` char(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'L',
1024   `format_string` varchar(210) NOT NULL DEFAULT 'barcode',
1025   `layout_xml` text NOT NULL,
1026   `creator` char(15) NOT NULL DEFAULT 'Labels',
1027   PRIMARY KEY (`layout_id`)
1028 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1029
1030 --
1031 -- Table structure for table `creator_templates`
1032 --
1033
1034 DROP TABLE IF EXISTS `creator_templates`;
1035 SET @saved_cs_client     = @@character_set_client;
1036 SET character_set_client = utf8;
1037 CREATE TABLE `creator_templates` (
1038   `template_id` int(4) NOT NULL AUTO_INCREMENT,
1039   `profile_id` int(4) DEFAULT NULL,
1040   `template_code` char(100) NOT NULL DEFAULT 'DEFAULT TEMPLATE',
1041   `template_desc` char(100) NOT NULL DEFAULT 'Default description',
1042   `page_width` float NOT NULL DEFAULT '0',
1043   `page_height` float NOT NULL DEFAULT '0',
1044   `label_width` float NOT NULL DEFAULT '0',
1045   `label_height` float NOT NULL DEFAULT '0',
1046   `top_text_margin` float NOT NULL DEFAULT '0',
1047   `left_text_margin` float NOT NULL DEFAULT '0',
1048   `top_margin` float NOT NULL DEFAULT '0',
1049   `left_margin` float NOT NULL DEFAULT '0',
1050   `cols` int(2) NOT NULL DEFAULT '0',
1051   `rows` int(2) NOT NULL DEFAULT '0',
1052   `col_gap` float NOT NULL DEFAULT '0',
1053   `row_gap` float NOT NULL DEFAULT '0',
1054   `units` char(20) NOT NULL DEFAULT 'POINT',
1055   `creator` char(15) NOT NULL DEFAULT 'Labels',
1056   PRIMARY KEY (`template_id`),
1057   KEY `template_profile_fk_constraint` (`profile_id`)
1058 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1059
1060 --
1061 -- Table structure for table `marc_subfield_structure`
1062 --
1063
1064 DROP TABLE IF EXISTS `marc_subfield_structure`;
1065 CREATE TABLE `marc_subfield_structure` (
1066   `tagfield` varchar(3) NOT NULL default '',
1067   `tagsubfield` varchar(1) NOT NULL default '' COLLATE utf8_bin,
1068   `liblibrarian` varchar(255) NOT NULL default '',
1069   `libopac` varchar(255) NOT NULL default '',
1070   `repeatable` tinyint(4) NOT NULL default 0,
1071   `mandatory` tinyint(4) NOT NULL default 0,
1072   `kohafield` varchar(40) default NULL,
1073   `tab` tinyint(1) default NULL,
1074   `authorised_value` varchar(20) default NULL,
1075   `authtypecode` varchar(20) default NULL,
1076   `value_builder` varchar(80) default NULL,
1077   `isurl` tinyint(1) default NULL,
1078   `hidden` tinyint(1) default NULL,
1079   `frameworkcode` varchar(4) NOT NULL default '',
1080   `seealso` varchar(1100) default NULL,
1081   `link` varchar(80) default NULL,
1082   `defaultvalue` text default NULL,
1083   `maxlength` int(4) NOT NULL DEFAULT '9999',
1084   PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
1085   KEY `kohafield_2` (`kohafield`),
1086   KEY `tab` (`frameworkcode`,`tab`),
1087   KEY `kohafield` (`frameworkcode`,`kohafield`)
1088 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1089
1090 --
1091 -- Table structure for table `marc_tag_structure`
1092 --
1093
1094 DROP TABLE IF EXISTS `marc_tag_structure`;
1095 CREATE TABLE `marc_tag_structure` (
1096   `tagfield` varchar(3) NOT NULL default '',
1097   `liblibrarian` varchar(255) NOT NULL default '',
1098   `libopac` varchar(255) NOT NULL default '',
1099   `repeatable` tinyint(4) NOT NULL default 0,
1100   `mandatory` tinyint(4) NOT NULL default 0,
1101   `authorised_value` varchar(10) default NULL,
1102   `frameworkcode` varchar(4) NOT NULL default '',
1103   PRIMARY KEY  (`frameworkcode`,`tagfield`)
1104 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1105
1106 --
1107 -- Table structure for table `marc_matchers`
1108 --
1109
1110 DROP TABLE IF EXISTS `marc_matchers`;
1111 CREATE TABLE `marc_matchers` (
1112   `matcher_id` int(11) NOT NULL auto_increment,
1113   `code` varchar(10) NOT NULL default '',
1114   `description` varchar(255) NOT NULL default '',
1115   `record_type` varchar(10) NOT NULL default 'biblio',
1116   `threshold` int(11) NOT NULL default 0,
1117   PRIMARY KEY (`matcher_id`),
1118   KEY `code` (`code`),
1119   KEY `record_type` (`record_type`)
1120 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1121
1122 --
1123 -- Table structure for table `matchpoints`
1124 --
1125 DROP TABLE IF EXISTS `matchpoints`;
1126 CREATE TABLE `matchpoints` (
1127   `matcher_id` int(11) NOT NULL,
1128   `matchpoint_id` int(11) NOT NULL auto_increment,
1129   `search_index` varchar(30) NOT NULL default '',
1130   `score` int(11) NOT NULL default 0,
1131   PRIMARY KEY (`matchpoint_id`),
1132   CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
1133   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
1134 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1135
1136
1137 --
1138 -- Table structure for table `matchpoint_components`
1139 --
1140 DROP TABLE IF EXISTS `matchpoint_components`;
1141 CREATE TABLE `matchpoint_components` (
1142   `matchpoint_id` int(11) NOT NULL,
1143   `matchpoint_component_id` int(11) NOT NULL auto_increment,
1144   sequence int(11) NOT NULL default 0,
1145   tag varchar(3) NOT NULL default '',
1146   subfields varchar(40) NOT NULL default '',
1147   offset int(4) NOT NULL default 0,
1148   length int(4) NOT NULL default 0,
1149   PRIMARY KEY (`matchpoint_component_id`),
1150   KEY `by_sequence` (`matchpoint_id`, `sequence`),
1151   CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
1152   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1153 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1154
1155 --
1156 -- Table structure for table `matcher_component_norms`
1157 --
1158 DROP TABLE IF EXISTS `matchpoint_component_norms`;
1159 CREATE TABLE `matchpoint_component_norms` (
1160   `matchpoint_component_id` int(11) NOT NULL,
1161   `sequence`  int(11) NOT NULL default 0,
1162   `norm_routine` varchar(50) NOT NULL default '',
1163   KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
1164   CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
1165   REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
1166 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1167
1168 --
1169 -- Table structure for table `matcher_matchpoints`
1170 --
1171 DROP TABLE IF EXISTS `matcher_matchpoints`;
1172 CREATE TABLE `matcher_matchpoints` (
1173   `matcher_id` int(11) NOT NULL,
1174   `matchpoint_id` int(11) NOT NULL,
1175   CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
1176   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1177   CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
1178   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1179 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1180
1181 --
1182 -- Table structure for table `matchchecks`
1183 --
1184 DROP TABLE IF EXISTS `matchchecks`;
1185 CREATE TABLE `matchchecks` (
1186   `matcher_id` int(11) NOT NULL,
1187   `matchcheck_id` int(11) NOT NULL auto_increment,
1188   `source_matchpoint_id` int(11) NOT NULL,
1189   `target_matchpoint_id` int(11) NOT NULL,
1190   PRIMARY KEY (`matchcheck_id`),
1191   CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
1192   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1193   CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
1194   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1195   CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
1196   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1197 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1198
1199 --
1200 -- Table structure for table `need_merge_authorities`
1201 --
1202
1203 DROP TABLE IF EXISTS `need_merge_authorities`;
1204 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)
1205   `id` int NOT NULL auto_increment PRIMARY KEY, -- unique id
1206   `authid` bigint NOT NULL, -- reference to authority record
1207   `done` tinyint DEFAULT 0  -- indication whether merge has been executed (0=not done, 1= done, 2= in progress)
1208 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1209
1210 --
1211 -- Table structure for table `notifys`
1212 --
1213
1214 DROP TABLE IF EXISTS `notifys`;
1215 CREATE TABLE `notifys` (
1216   `notify_id` int(11) NOT NULL default 0,
1217   `borrowernumber` int(11) NOT NULL default 0,
1218   `itemnumber` int(11) NOT NULL default 0,
1219   `notify_date` date default NULL,
1220   `notify_send_date` date default NULL,
1221   `notify_level` int(1) NOT NULL default 0,
1222   `method` varchar(20) NOT NULL default ''
1223 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1224
1225 --
1226 -- Table structure for table `oai_sets`
1227 --
1228
1229 DROP TABLE IF EXISTS `oai_sets`;
1230 CREATE TABLE `oai_sets` (
1231   `id` int(11) NOT NULL auto_increment,
1232   `spec` varchar(80) NOT NULL UNIQUE,
1233   `name` varchar(80) NOT NULL,
1234   PRIMARY KEY (`id`)
1235 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1236
1237 --
1238 -- Table structure for table `oai_sets_descriptions`
1239 --
1240
1241 DROP TABLE IF EXISTS `oai_sets_descriptions`;
1242 CREATE TABLE `oai_sets_descriptions` (
1243   `set_id` int(11) NOT NULL,
1244   `description` varchar(255) NOT NULL,
1245   CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1246 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1247
1248 --
1249 -- Table structure for table `oai_sets_mappings`
1250 --
1251
1252 DROP TABLE IF EXISTS `oai_sets_mappings`;
1253 CREATE TABLE `oai_sets_mappings` (
1254   `set_id` int(11) NOT NULL,
1255   `marcfield` char(3) NOT NULL,
1256   `marcsubfield` char(1) NOT NULL,
1257   `operator` varchar(8) NOT NULL default 'equal',
1258   `marcvalue` varchar(80) NOT NULL,
1259   CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1260 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1261
1262 --
1263 -- Table structure for table `oai_sets_biblios`
1264 --
1265
1266 DROP TABLE IF EXISTS `oai_sets_biblios`;
1267 CREATE TABLE `oai_sets_biblios` (
1268   `biblionumber` int(11) NOT NULL,
1269   `set_id` int(11) NOT NULL,
1270   PRIMARY KEY (`biblionumber`, `set_id`),
1271   CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1272 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1273
1274 --
1275 -- Table structure for table `overduerules`
1276 --
1277
1278 DROP TABLE IF EXISTS `overduerules`;
1279 CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1280   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to define which branch this rule is for (if blank it's all libraries)
1281   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1282   `delay1` int(4) default NULL, -- number of days after the item is overdue that the first notice is sent
1283   `letter1` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the first notice
1284   `debarred1` varchar(1) default 0, -- is the patron restricted when the first notice is sent (1 for yes, 0 for no)
1285   `delay2` int(4) default NULL, -- number of days after the item is overdue that the second notice is sent
1286   `debarred2` varchar(1) default 0, -- is the patron restricted when the second notice is sent (1 for yes, 0 for no)
1287   `letter2` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the second notice
1288   `delay3` int(4) default NULL, -- number of days after the item is overdue that the third notice is sent
1289   `letter3` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the third notice
1290   `debarred3` int(1) default 0, -- is the patron restricted when the third notice is sent (1 for yes, 0 for no)
1291   PRIMARY KEY  (`branchcode`,`categorycode`)
1292 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1293
1294 -- Table structure for table `pending_offline_operations`
1295 --
1296 -- this table is MyISAM, InnoDB tables are growing only and this table is filled/emptied/filled/emptied...
1297 -- so MyISAM is better in this case
1298
1299 DROP TABLE IF EXISTS `pending_offline_operations`;
1300 CREATE TABLE pending_offline_operations (
1301   operationid int(11) NOT NULL AUTO_INCREMENT,
1302   userid varchar(30) NOT NULL,
1303   branchcode varchar(10) NOT NULL,
1304   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
1305   `action` varchar(10) NOT NULL,
1306   barcode varchar(20) DEFAULT NULL,
1307   cardnumber varchar(16) DEFAULT NULL,
1308   amount decimal(28,6) DEFAULT NULL,
1309   PRIMARY KEY (operationid)
1310 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1311
1312
1313 --
1314 -- Table structure for table `printers`
1315 --
1316
1317 DROP TABLE IF EXISTS `printers`;
1318 CREATE TABLE `printers` (
1319   `printername` varchar(40) NOT NULL default '',
1320   `printqueue` varchar(20) default NULL,
1321   `printtype` varchar(20) default NULL,
1322   PRIMARY KEY  (`printername`)
1323 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1324
1325 --
1326 -- Table structure for table `printers_profile`
1327 --
1328
1329 DROP TABLE IF EXISTS `printers_profile`;
1330 CREATE TABLE `printers_profile` (
1331   `profile_id` int(4) NOT NULL auto_increment,
1332   `printer_name` varchar(40) NOT NULL default 'Default Printer',
1333   `template_id` int(4) NOT NULL default '0',
1334   `paper_bin` varchar(20) NOT NULL default 'Bypass',
1335   `offset_horz` float NOT NULL default '0',
1336   `offset_vert` float NOT NULL default '0',
1337   `creep_horz` float NOT NULL default '0',
1338   `creep_vert` float NOT NULL default '0',
1339   `units` char(20) NOT NULL default 'POINT',
1340   `creator` char(15) NOT NULL DEFAULT 'Labels',
1341   PRIMARY KEY  (`profile_id`),
1342   UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`,`creator`)
1343 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1344
1345 --
1346 -- Table structure for table `repeatable_holidays`
1347 --
1348
1349 DROP TABLE IF EXISTS `repeatable_holidays`;
1350 CREATE TABLE `repeatable_holidays` ( -- information for the days the library is closed
1351   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1352   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
1353   `weekday` smallint(6) default NULL, -- day of the week (0=Sunday, 1=Monday, etc) this closing is repeated on
1354   `day` smallint(6) default NULL, -- day of the month this closing is on
1355   `month` smallint(6) default NULL, -- month this closing is in
1356   `title` varchar(50) NOT NULL default '', -- title of this closing
1357   `description` text NOT NULL, -- description for this closing
1358   PRIMARY KEY  (`id`)
1359 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1360
1361 --
1362 -- Table structure for table `reports_dictionary`
1363 --
1364
1365 DROP TABLE IF EXISTS `reports_dictionary`;
1366 CREATE TABLE reports_dictionary ( -- definitions (or snippets of SQL) stored for use in reports
1367    `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1368    `name` varchar(255) default NULL, -- name for this definition
1369    `description` text, -- description for this definition
1370    `date_created` datetime default NULL, -- date and time this definition was created
1371    `date_modified` datetime default NULL, -- date and time this definition was last modified
1372    `saved_sql` text, -- SQL snippet for us in reports
1373    report_area varchar(6) DEFAULT NULL, -- Koha module this definition is for Circulation, Catalog, Patrons, Acquistions, Accounts)
1374    PRIMARY KEY  (id),
1375    KEY dictionary_area_idx (report_area)
1376 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1377
1378 --
1379 -- Table structure for table `saved_sql`
1380 --
1381
1382 DROP TABLE IF EXISTS `saved_sql`;
1383 CREATE TABLE saved_sql ( -- saved sql reports
1384    `id` int(11) NOT NULL auto_increment, -- unique id and primary key assigned by Koha
1385    `borrowernumber` int(11) default NULL, -- the staff member who created this report (borrowers.borrowernumber)
1386    `date_created` datetime default NULL, -- the date this report was created
1387    `last_modified` datetime default NULL, -- the date this report was last edited
1388    `savedsql` text, -- the SQL for this report
1389    `last_run` datetime default NULL,
1390    `report_name` varchar(255) NOT NULL default '', -- the name of this report
1391    `type` varchar(255) default NULL, -- always 1 for tabular
1392    `notes` text, -- the notes or description given to this report
1393    `cache_expiry` int NOT NULL default 300,
1394    `public` boolean NOT NULL default FALSE,
1395     report_area varchar(6) default NULL,
1396     report_group varchar(80) default NULL,
1397     report_subgroup varchar(80) default NULL,
1398    PRIMARY KEY  (`id`),
1399    KEY sql_area_group_idx (report_group, report_subgroup),
1400    KEY boridx (`borrowernumber`)
1401 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1402
1403
1404 --
1405 -- Table structure for `saved_reports`
1406 --
1407
1408 DROP TABLE IF EXISTS `saved_reports`;
1409 CREATE TABLE saved_reports (
1410    `id` int(11) NOT NULL auto_increment,
1411    `report_id` int(11) default NULL,
1412    `report` longtext,
1413    `date_run` datetime default NULL,
1414    PRIMARY KEY  (`id`)
1415 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1416
1417 --
1418 -- Table structure for table `search_history`
1419 --
1420
1421 DROP TABLE IF EXISTS `search_history`;
1422 CREATE TABLE IF NOT EXISTS `search_history` ( -- patron's opac search history
1423   `id` int(11) NOT NULL auto_increment, -- search history id
1424   `userid` int(11) NOT NULL, -- the patron who performed the search (borrowers.borrowernumber)
1425   `sessionid` varchar(32) NOT NULL, -- a system generated session id
1426   `query_desc` varchar(255) NOT NULL, -- the search that was performed
1427   `query_cgi` text NOT NULL, -- the string to append to the search url to rerun the search
1428   `type` varchar(16) NOT NULL DEFAULT 'biblio', -- search type, must be 'biblio' or 'authority'
1429   `total` int(11) NOT NULL, -- the total of results found
1430   `time` timestamp NOT NULL default CURRENT_TIMESTAMP, -- the date and time the search was run
1431   KEY `userid` (`userid`),
1432   KEY `sessionid` (`sessionid`),
1433   PRIMARY KEY  (`id`)
1434 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Opac search history results';
1435
1436 --
1437 -- Table structure for table `serial`
1438 --
1439
1440 DROP TABLE IF EXISTS `serial`;
1441 CREATE TABLE `serial` ( -- issues related to subscriptions
1442   `serialid` int(11) NOT NULL auto_increment, -- unique key for the issue
1443   `biblionumber` varchar(100) NOT NULL default '', -- foreign key for the biblio.biblionumber that this issue is attached to
1444   `subscriptionid` varchar(100) NOT NULL default '', -- foreign key to the subscription.subscriptionid that this issue is part of
1445   `serialseq` varchar(100) NOT NULL default '', -- issue information (volume, number, etc)
1446   `status` tinyint(4) NOT NULL default 0, -- status code for this issue (see manual for full descriptions)
1447   `planneddate` date default NULL, -- date expected
1448   `notes` text, -- notes
1449   `publisheddate` date default NULL, -- date published
1450   publisheddatetext varchar(100) default NULL, -- date published (descriptive)
1451   `claimdate` date default NULL, -- date claimed
1452   claims_count int(11) default 0, -- number of claims made related to this issue
1453   `routingnotes` text, -- notes from the routing list
1454   PRIMARY KEY  (`serialid`)
1455 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1456
1457 --
1458 -- Table structure for table `sessions`
1459 --
1460
1461 DROP TABLE IF EXISTS sessions;
1462 CREATE TABLE sessions (
1463   `id` varchar(32) NOT NULL,
1464   `a_session` mediumtext NOT NULL,
1465   PRIMARY KEY (`id`)
1466 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1467
1468 --
1469 -- Table structure for table `borrowers`
1470 --
1471
1472 DROP TABLE IF EXISTS `borrowers`;
1473 CREATE TABLE `borrowers` ( -- this table includes information about your patrons/borrowers/members
1474   `borrowernumber` int(11) NOT NULL auto_increment, -- primary key, Koha assigned ID number for patrons/borrowers
1475   `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
1476   `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
1477   `firstname` text, -- patron/borrower's first name
1478   `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
1479   `othernames` mediumtext, -- any other names associated with the patron/borrower
1480   `initials` text, -- initials for your patron/borrower
1481   `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
1482   `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
1483   `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
1484   `address2` text, -- the second address line for your patron/borrower's primary address
1485   `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
1486   `state` text default NULL, -- the state or province for your patron/borrower's primary address
1487   `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
1488   `country` text, -- the country for your patron/borrower's primary address
1489   `email` mediumtext, -- the primary email address for your patron/borrower's primary address
1490   `phone` text, -- the primary phone number for your patron/borrower's primary address
1491   `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
1492   `fax` mediumtext, -- the fax number for your patron/borrower's primary address
1493   `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
1494   `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
1495   `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
1496   `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
1497   `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
1498   `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
1499   `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
1500   `B_state` text default NULL, -- the state for your patron/borrower's alternate address
1501   `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
1502   `B_country` text, -- the country for your patron/borrower's alternate address
1503   `B_email` text, -- the patron/borrower's alternate email address
1504   `B_phone` mediumtext, -- the patron/borrower's alternate phone number
1505   `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
1506   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
1507   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
1508   `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
1509   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
1510   `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
1511   `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
1512   `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)
1513   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
1514   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
1515   `contactfirstname` text, -- used for children to include first name of guarentor
1516   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
1517   `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
1518   `borrowernotes` mediumtext, -- a note on the patron/borrower's account that is only visible in the staff client
1519   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
1520   `sex` varchar(1) default NULL, -- patron/borrower's gender
1521   `password` varchar(60) default NULL, -- patron/borrower's encrypted password
1522   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
1523   `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
1524   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
1525   `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
1526   `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
1527   `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
1528   `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
1529   `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
1530   `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
1531   `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
1532   `altcontactaddress3` varchar(255) default NULL, -- the city for the alternate contact for the patron/borrower
1533   `altcontactstate` text default NULL, -- the state for the alternate contact for the patron/borrower
1534   `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
1535   `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
1536   `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
1537   `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
1538   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
1539   `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)
1540   UNIQUE KEY `cardnumber` (`cardnumber`),
1541   PRIMARY KEY `borrowernumber` (`borrowernumber`),
1542   KEY `categorycode` (`categorycode`),
1543   KEY `branchcode` (`branchcode`),
1544   UNIQUE KEY `userid` (`userid`),
1545   KEY `guarantorid` (`guarantorid`),
1546   KEY `surname_idx` (`surname`(255)),
1547   KEY `firstname_idx` (`firstname`(255)),
1548   KEY `othernames_idx` (`othernames`(255)),
1549   CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
1550   CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1551 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1552
1553 --
1554 -- Table structure for table `borrower_attributes`
1555 --
1556
1557 DROP TABLE IF EXISTS `borrower_attributes`;
1558 CREATE TABLE `borrower_attributes` ( -- values of custom patron fields known as extended patron attributes linked to patrons/borrowers
1559   `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines which patron/borrower has this attribute
1560   `code` varchar(10) NOT NULL, -- foreign key from the borrower_attribute_types table, defines which custom field this value was entered for
1561   `attribute` varchar(255) default NULL, -- custom patron field value
1562   `password` varchar(64) default NULL, -- password associated with this field
1563   KEY `borrowernumber` (`borrowernumber`),
1564   KEY `code_attribute` (`code`, `attribute`),
1565   CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1566     ON DELETE CASCADE ON UPDATE CASCADE,
1567   CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
1568     ON DELETE CASCADE ON UPDATE CASCADE
1569 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1570
1571 --
1572 -- Table structure for table `borrower_debarments`
1573 --
1574
1575 DROP TABLE IF EXISTS `borrower_debarments`;
1576 CREATE TABLE borrower_debarments ( -- tracks restrictions on the patron's record
1577   borrower_debarment_id int(11) NOT NULL AUTO_INCREMENT, -- unique key for the restriction
1578   borrowernumber int(11) NOT NULL, -- foreign key for borrowers.borrowernumber for patron who is restricted
1579   expiration date DEFAULT NULL, -- expiration date of the restriction
1580   `type` enum('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL', -- type of restriction
1581   `comment` text, -- comments about the restriction
1582   manager_id int(11) DEFAULT NULL, -- foreign key for borrowers.borrowernumber for the librarian managing the restriction
1583   created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date the restriction was added
1584   updated timestamp NULL DEFAULT NULL, -- date the restriction was updated
1585   PRIMARY KEY (borrower_debarment_id),
1586   KEY borrowernumber (borrowernumber),
1587   CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1588     ON DELETE CASCADE ON UPDATE CASCADE
1589 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1590
1591 --
1592 -- Table structure for table borrower_sync
1593 --
1594
1595 DROP TABLE IF EXISTS `borrower_sync`;
1596 CREATE TABLE borrower_sync (
1597   borrowersyncid int(11) NOT NULL AUTO_INCREMENT, -- Primary key, unique identifier
1598   borrowernumber int(11) NOT NULL, -- Connects data about synchronisations to a borrower
1599   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
1600   sync tinyint(1) NOT NULL DEFAULT '0', -- A boolean (1/0) for turning syncing off and on for individual borrowers
1601   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.
1602   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.
1603   hashed_pin varchar(64) DEFAULT NULL, -- Perhaps specific to The Norwegian national patron database, this column holds a hashed PIN code
1604   PRIMARY KEY (borrowersyncid),
1605   KEY borrowernumber (borrowernumber),
1606   CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
1607 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1608
1609 --
1610 -- Table structure for table `issues`
1611 --
1612
1613 DROP TABLE IF EXISTS `issues`;
1614 CREATE TABLE `issues` ( -- information related to check outs or issues
1615   `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1616   `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1617   `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1618   `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1619   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1620   `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
1621   `lastreneweddate` datetime default NULL, -- date the item was last renewed
1622   `return` varchar(4) default NULL,
1623   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
1624   `auto_renew` BOOLEAN default FALSE, -- automatic renewal
1625   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1626   `issuedate` datetime default NULL, -- date the item was checked out or issued
1627   `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1628   PRIMARY KEY (`issue_id`),
1629   UNIQUE KEY `itemnumber` (`itemnumber`),
1630   KEY `issuesborridx` (`borrowernumber`),
1631   KEY `itemnumber_idx` (`itemnumber`),
1632   KEY `branchcode_idx` (`branchcode`),
1633   KEY `bordate` (`borrowernumber`,`timestamp`),
1634   CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1635   CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE
1636 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1637
1638 --
1639 -- Table structure for table `old_issues`
1640 --
1641
1642 DROP TABLE IF EXISTS `old_issues`;
1643 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1644   `issue_id` int(11) NOT NULL, -- primary key for issues table
1645   `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1646   `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1647   `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
1648   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1649   `returndate` datetime default NULL, -- date the item was returned
1650   `lastreneweddate` datetime default NULL, -- date the item was last renewed
1651   `return` varchar(4) default NULL,
1652   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
1653   `auto_renew` BOOLEAN default FALSE, -- automatic renewal
1654   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1655   `issuedate` datetime default NULL, -- date the item was checked out or issued
1656   `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1657   PRIMARY KEY (`issue_id`),
1658   KEY `old_issuesborridx` (`borrowernumber`),
1659   KEY `old_issuesitemidx` (`itemnumber`),
1660   KEY `branchcode_idx` (`branchcode`),
1661   KEY `old_bordate` (`borrowernumber`,`timestamp`),
1662   CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1663     ON DELETE SET NULL ON UPDATE SET NULL,
1664   CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1665     ON DELETE SET NULL ON UPDATE SET NULL
1666 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1667
1668 --
1669 -- Table structure for table `creator_batches`
1670 --
1671
1672 DROP TABLE IF EXISTS `creator_batches`;
1673 SET @saved_cs_client     = @@character_set_client;
1674 SET character_set_client = utf8;
1675 CREATE TABLE `creator_batches` (
1676   `label_id` int(11) NOT NULL AUTO_INCREMENT,
1677   `batch_id` int(10) NOT NULL DEFAULT '1',
1678   `item_number` int(11) DEFAULT NULL,
1679   `borrower_number` int(11) DEFAULT NULL,
1680   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
1681   `branch_code` varchar(10) NOT NULL DEFAULT 'NB',
1682   `creator` char(15) NOT NULL DEFAULT 'Labels',
1683   PRIMARY KEY (`label_id`),
1684   KEY `branch_fk_constraint` (`branch_code`),
1685   KEY `item_fk_constraint` (`item_number`),
1686   KEY `borrower_fk_constraint` (`borrower_number`),
1687   CONSTRAINT `creator_batches_ibfk_1` FOREIGN KEY (`borrower_number`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1688   CONSTRAINT `creator_batches_ibfk_2` FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
1689   CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE
1690 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1691
1692 --
1693 -- Table structure for table `opac_news`
1694 --
1695
1696 DROP TABLE IF EXISTS `opac_news`;
1697 CREATE TABLE `opac_news` ( -- data from the news tool
1698   `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
1699   `branchcode` varchar(10) default NULL, -- branch code users to create branch specific news, NULL is every branch.
1700   `title` varchar(250) NOT NULL default '', -- title of the news article
1701   `new` text NOT NULL, -- the body of your news article
1702   `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)
1703   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time
1704   `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible
1705   `number` int(11) default NULL, -- the order in which this article appears in that specific location
1706   `borrowernumber` int(11) default NULL, -- The user who created the news article
1707   PRIMARY KEY  (`idnew`),
1708   CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
1709   CONSTRAINT opac_news_branchcode_ibfk FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
1710     ON DELETE CASCADE ON UPDATE CASCADE
1711 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1712
1713 --
1714 -- Table structure for table `patronimage`
1715 --
1716
1717 DROP TABLE IF EXISTS `patronimage`;
1718 CREATE TABLE `patronimage` ( -- information related to patron images
1719   `borrowernumber` int(11) NOT NULL, -- the borrowernumber of the patron this image is attached to (borrowers.borrowernumber)
1720   `mimetype` varchar(15) NOT NULL, -- the format of the image (png, jpg, etc)
1721   `imagefile` mediumblob NOT NULL, -- the image
1722   PRIMARY KEY  (`borrowernumber`),
1723   CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1724 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1725
1726 --
1727 -- Table structure for table `reserves`
1728 --
1729
1730 DROP TABLE IF EXISTS `reserves`;
1731 CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
1732   `reserve_id` int(11) NOT NULL auto_increment, -- primary key
1733   `borrowernumber` int(11) NOT NULL default 0, -- foreign key from the borrowers table defining which patron this hold is for
1734   `reservedate` date default NULL, -- the date the hold was places
1735   `biblionumber` int(11) NOT NULL default 0, -- foreign key from the biblio table defining which bib record this hold is on
1736   `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
1737   `notificationdate` date default NULL, -- currently unused
1738   `reminderdate` date default NULL, -- currently unused
1739   `cancellationdate` date default NULL, -- the date this hold was cancelled
1740   `reservenotes` mediumtext, -- notes related to this hold
1741   `priority` smallint(6) default NULL, -- where in the queue the patron sits
1742   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
1743   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
1744   `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
1745   `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1746   `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)
1747   `lowestPriority` tinyint(1) NOT NULL,
1748   `suspend` BOOLEAN NOT NULL DEFAULT 0,
1749   `suspend_until` DATETIME NULL DEFAULT NULL,
1750   PRIMARY KEY (`reserve_id`),
1751   KEY priorityfoundidx (priority,found),
1752   KEY `borrowernumber` (`borrowernumber`),
1753   KEY `biblionumber` (`biblionumber`),
1754   KEY `itemnumber` (`itemnumber`),
1755   KEY `branchcode` (`branchcode`),
1756   CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1757   CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1758   CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1759   CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1760 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1761
1762 --
1763 -- Table structure for table `old_reserves`
1764 --
1765
1766 DROP TABLE IF EXISTS `old_reserves`;
1767 CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have been completed (either filled or cancelled)
1768   `reserve_id` int(11) NOT NULL, -- primary key
1769   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron this hold is for
1770   `reservedate` date default NULL, -- the date the hold was places
1771   `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bib record this hold is on
1772   `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
1773   `notificationdate` date default NULL, -- currently unused
1774   `reminderdate` date default NULL, -- currently unused
1775   `cancellationdate` date default NULL, -- the date this hold was cancelled
1776   `reservenotes` mediumtext, -- notes related to this hold
1777   `priority` smallint(6) default NULL, -- where in the queue the patron sits
1778   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
1779   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
1780   `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
1781   `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1782   `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)
1783   `lowestPriority` tinyint(1) NOT NULL, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no)
1784   `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no)
1785   `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely)
1786   PRIMARY KEY (`reserve_id`),
1787   KEY `old_reserves_borrowernumber` (`borrowernumber`),
1788   KEY `old_reserves_biblionumber` (`biblionumber`),
1789   KEY `old_reserves_itemnumber` (`itemnumber`),
1790   KEY `old_reserves_branchcode` (`branchcode`),
1791   CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1792     ON DELETE SET NULL ON UPDATE SET NULL,
1793   CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1794     ON DELETE SET NULL ON UPDATE SET NULL,
1795   CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1796     ON DELETE SET NULL ON UPDATE SET NULL
1797 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1798
1799 --
1800 -- Table structure for table `reviews`
1801 --
1802
1803 DROP TABLE IF EXISTS `reviews`;
1804 CREATE TABLE `reviews` ( -- patron opac comments
1805   `reviewid` int(11) NOT NULL auto_increment, -- unique identifier for this comment
1806   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron left this comment
1807   `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bibliographic record this comment is for
1808   `review` text, -- the body of the comment
1809   `approved` tinyint(4) default NULL, -- whether this comment has been approved by a librarian (1 for yes, 0 for no)
1810   `datereviewed` datetime default NULL, -- the date the comment was left
1811   PRIMARY KEY  (`reviewid`),
1812   CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
1813   CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1814 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1815
1816 --
1817 -- Table structure for table `special_holidays`
1818 --
1819
1820 DROP TABLE IF EXISTS `special_holidays`;
1821 CREATE TABLE `special_holidays` ( -- non repeatable holidays/library closings
1822   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1823   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
1824   `day` smallint(6) NOT NULL default 0, -- day of the month this closing is on
1825   `month` smallint(6) NOT NULL default 0, -- month this closing is in
1826   `year` smallint(6) NOT NULL default 0, -- year this closing is in
1827   `isexception` smallint(1) NOT NULL default 1, -- is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)
1828   `title` varchar(50) NOT NULL default '', -- title for this closing
1829   `description` text NOT NULL, -- description of this closing
1830   PRIMARY KEY  (`id`)
1831 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1832
1833 --
1834 -- Table structure for table `statistics`
1835 --
1836
1837 DROP TABLE IF EXISTS `statistics`;
1838 CREATE TABLE `statistics` ( -- information related to transactions (circulation and fines) in Koha
1839   `datetime` datetime default NULL, -- date and time of the transaction
1840   `branch` varchar(10) default NULL, -- foreign key, branch where the transaction occurred
1841   `proccode` varchar(4) default NULL, -- type of procedure used when making payments (does not appear in the code)
1842   `value` double(16,4) default NULL, -- monetary value associated with the transaction
1843   `type` varchar(16) default NULL, -- transaction type (locause, issue, return, renew, writeoff, payment, Credit*)
1844   `other` mediumtext, -- used by SIP
1845   `usercode` varchar(10) default NULL, -- unused in Koha
1846   `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
1847   `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
1848   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
1849   `associatedborrower` int(11) default NULL, -- unused in Koha
1850   `ccode` varchar(10) default NULL, -- foreign key from the items table, links transaction to a specific collection code
1851   KEY `timeidx` (`datetime`),
1852   KEY `branch_idx` (`branch`),
1853   KEY `proccode_idx` (`proccode`),
1854   KEY `type_idx` (`type`),
1855   KEY `usercode_idx` (`usercode`),
1856   KEY `itemnumber_idx` (`itemnumber`),
1857   KEY `itemtype_idx` (`itemtype`),
1858   KEY `borrowernumber_idx` (`borrowernumber`),
1859   KEY `associatedborrower_idx` (`associatedborrower`),
1860   KEY `ccode_idx` (`ccode`)
1861 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1862
1863 --
1864 -- Table structure for table `stopwords`
1865 --
1866
1867 DROP TABLE IF EXISTS `stopwords`;
1868   CREATE TABLE `stopwords` (
1869   `word` varchar(255) default NULL
1870 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1871
1872 --
1873 -- Table structure for table subscription_frequencies
1874 --
1875
1876 DROP TABLE IF EXISTS subscription_frequencies;
1877 CREATE TABLE subscription_frequencies (
1878     id INTEGER NOT NULL AUTO_INCREMENT,
1879     description TEXT NOT NULL,
1880     displayorder INT DEFAULT NULL,
1881     unit ENUM('day','week','month','year') DEFAULT NULL,
1882     unitsperissue INTEGER NOT NULL DEFAULT '1',
1883     issuesperunit INTEGER NOT NULL DEFAULT '1',
1884     PRIMARY KEY (id)
1885 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1886
1887 --
1888 -- Table structure for table subscription_numberpatterns
1889 --
1890
1891 DROP TABLE IF EXISTS subscription_numberpatterns;
1892 CREATE TABLE subscription_numberpatterns (
1893     id INTEGER NOT NULL AUTO_INCREMENT,
1894     label VARCHAR(255) NOT NULL,
1895     displayorder INTEGER DEFAULT NULL,
1896     description TEXT NOT NULL,
1897     numberingmethod VARCHAR(255) NOT NULL,
1898     label1 VARCHAR(255) DEFAULT NULL,
1899     add1 INTEGER DEFAULT NULL,
1900     every1 INTEGER DEFAULT NULL,
1901     whenmorethan1 INTEGER DEFAULT NULL,
1902     setto1 INTEGER DEFAULT NULL,
1903     numbering1 VARCHAR(255) DEFAULT NULL,
1904     label2 VARCHAR(255) DEFAULT NULL,
1905     add2 INTEGER DEFAULT NULL,
1906     every2 INTEGER DEFAULT NULL,
1907     whenmorethan2 INTEGER DEFAULT NULL,
1908     setto2 INTEGER DEFAULT NULL,
1909     numbering2 VARCHAR(255) DEFAULT NULL,
1910     label3 VARCHAR(255) DEFAULT NULL,
1911     add3 INTEGER DEFAULT NULL,
1912     every3 INTEGER DEFAULT NULL,
1913     whenmorethan3 INTEGER DEFAULT NULL,
1914     setto3 INTEGER DEFAULT NULL,
1915     numbering3 VARCHAR(255) DEFAULT NULL,
1916     PRIMARY KEY (id)
1917 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1918
1919 --
1920 -- Table structure for table `subscription`
1921 --
1922
1923 DROP TABLE IF EXISTS `subscription`;
1924 CREATE TABLE `subscription` ( -- information related to the subscription
1925   `biblionumber` int(11) NOT NULL default 0, -- foreign key for biblio.biblionumber that this subscription is attached to
1926   `subscriptionid` int(11) NOT NULL auto_increment, -- unique key for this subscription
1927   `librarian` varchar(100) default '', -- the librarian's username from borrowers.userid
1928   `startdate` date default NULL, -- start date for this subscription
1929   `aqbooksellerid` int(11) default 0, -- foreign key for aqbooksellers.id to link to the vendor
1930   `cost` int(11) default 0,
1931   `aqbudgetid` int(11) default 0,
1932   `weeklength` int(11) default 0, -- subscription length in weeks (will not be filled in if monthlength or numberlength is set)
1933   `monthlength` int(11) default 0, -- subscription length in weeks (will not be filled in if weeklength or numberlength is set)
1934   `numberlength` int(11) default 0, -- subscription length in weeks (will not be filled in if monthlength or weeklength is set)
1935   `periodicity` integer default null, -- frequency type links to subscription_frequencies.id
1936   countissuesperunit INTEGER NOT NULL DEFAULT 1,
1937   `notes` mediumtext, -- notes
1938   `status` varchar(100) NOT NULL default '',  -- status of this subscription
1939   `lastvalue1` int(11) default NULL,
1940   `innerloop1` int(11) default 0,
1941   `lastvalue2` int(11) default NULL,
1942   `innerloop2` int(11) default 0,
1943   `lastvalue3` int(11) default NULL,
1944   `innerloop3` int(11) default 0,
1945   `firstacquidate` date default NULL, -- first issue received date
1946   `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually
1947   `irregularity` text, -- any irregularities in the subscription
1948   skip_serialseq BOOLEAN NOT NULL DEFAULT 0,
1949   `letter` varchar(20) default NULL,
1950   `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id
1951   locale VARCHAR(80) DEFAULT NULL, -- for foreign language subscriptions to display months, seasons, etc correctly
1952   `distributedto` text,
1953   `internalnotes` longtext,
1954   `callnumber` text, -- default call number
1955   `location` varchar(80) NULL default '', -- default shelving location (items.location)
1956   `branchcode` varchar(10) NOT NULL default '', -- default branches (items.homebranch)
1957   `lastbranch` varchar(10),
1958   `serialsadditems` tinyint(1) NOT NULL default '0', -- does receiving this serial create an item record
1959   `staffdisplaycount` VARCHAR(10) NULL, -- how many issues to show to the staff
1960   `opacdisplaycount` VARCHAR(10) NULL, -- how many issues to show to the public
1961   `graceperiod` int(11) NOT NULL default '0', -- grace period in days
1962   `enddate` date default NULL, -- subscription end date
1963   `closed` INT(1) NOT NULL DEFAULT 0, -- yes / no if the subscription is closed
1964   `reneweddate` date default NULL, -- date of last renewal for the subscription
1965   PRIMARY KEY  (`subscriptionid`),
1966   CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
1967   CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
1968 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1969
1970 --
1971 -- Table structure for table `subscriptionhistory`
1972 --
1973
1974 DROP TABLE IF EXISTS `subscriptionhistory`;
1975 CREATE TABLE `subscriptionhistory` (
1976   `biblionumber` int(11) NOT NULL default 0,
1977   `subscriptionid` int(11) NOT NULL default 0,
1978   `histstartdate` date default NULL,
1979   `histenddate` date default NULL,
1980   `missinglist` longtext NOT NULL,
1981   `recievedlist` longtext NOT NULL,
1982   `opacnote` varchar(150) NOT NULL default '',
1983   `librariannote` varchar(150) NOT NULL default '',
1984   PRIMARY KEY  (`subscriptionid`),
1985   KEY `biblionumber` (`biblionumber`)
1986 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1987
1988 --
1989 -- Table structure for table `subscriptionroutinglist`
1990 --
1991
1992 DROP TABLE IF EXISTS `subscriptionroutinglist`;
1993 CREATE TABLE `subscriptionroutinglist` ( -- information related to the routing lists attached to subscriptions
1994   `routingid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1995   `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines with patron is on the routing list
1996   `ranking` int(11) default NULL, -- where the patron stands in line to receive the serial
1997   `subscriptionid` int(11) NOT NULL, -- foreign key from the subscription table, defines which subscription this routing list is for
1998   PRIMARY KEY  (`routingid`),
1999   UNIQUE (`subscriptionid`, `borrowernumber`),
2000   CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
2001     ON DELETE CASCADE ON UPDATE CASCADE,
2002   CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`)
2003     ON DELETE CASCADE ON UPDATE CASCADE
2004 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2005
2006 --
2007 -- Table structure for table `systempreferences`
2008 --
2009
2010 DROP TABLE IF EXISTS `systempreferences`;
2011 CREATE TABLE `systempreferences` ( -- global system preferences
2012   `variable` varchar(50) NOT NULL default '', -- system preference name
2013   `value` text, -- system preference values
2014   `options` mediumtext, -- options for multiple choice system preferences
2015   `explanation` text, -- descriptive text for the system preference
2016   `type` varchar(20) default NULL, -- type of question this preference asks (multiple choice, plain text, yes or no, etc)
2017   PRIMARY KEY  (`variable`)
2018 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2019
2020 --
2021 -- Table structure for table `tags`
2022 --
2023
2024 DROP TABLE IF EXISTS `tags`;
2025 CREATE TABLE `tags` (
2026   `entry` varchar(255) NOT NULL default '',
2027   `weight` bigint(20) NOT NULL default 0,
2028   PRIMARY KEY  (`entry`)
2029 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2030
2031 --
2032 -- Table structure for table `tags_all`
2033 --
2034
2035 DROP TABLE IF EXISTS `tags_all`;
2036 CREATE TABLE `tags_all` ( -- all of the tags
2037   `tag_id`         int(11) NOT NULL auto_increment, -- unique id and primary key
2038   `borrowernumber` int(11) DEFAULT NULL, -- the patron who added the tag (borrowers.borrowernumber)
2039   `biblionumber`   int(11) NOT NULL, -- the bib record this tag was left on (biblio.biblionumber)
2040   `term`      varchar(255) NOT NULL, -- the tag
2041   `language`       int(4) default NULL, -- the language the tag was left in
2042   `date_created` datetime  NOT NULL, -- the date the tag was added
2043   PRIMARY KEY  (`tag_id`),
2044   KEY `tags_borrowers_fk_1` (`borrowernumber`),
2045   KEY `tags_biblionumber_fk_1` (`biblionumber`),
2046   CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
2047         REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2048   CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
2049         REFERENCES `biblio`     (`biblionumber`)  ON DELETE CASCADE ON UPDATE CASCADE
2050 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2051
2052 --
2053 -- Table structure for table `tags_approval`
2054 --
2055
2056 DROP TABLE IF EXISTS `tags_approval`;
2057 CREATE TABLE `tags_approval` ( -- approved tags
2058   `term`   varchar(255) NOT NULL, -- the tag
2059   `approved`     int(1) NOT NULL default '0', -- whether the tag is approved or not (1=yes, 0=pending, -1=rejected)
2060   `date_approved` datetime       default NULL, -- the date this tag was approved
2061   `approved_by` int(11)          default NULL, -- the librarian who approved the tag (borrowers.borrowernumber)
2062   `weight_total` int(9) NOT NULL default '1', -- the total number of times this tag was used
2063   PRIMARY KEY  (`term`),
2064   KEY `tags_approval_borrowers_fk_1` (`approved_by`),
2065   CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
2066         REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
2067 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2068
2069 --
2070 -- Table structure for table `tags_index`
2071 --
2072
2073 DROP TABLE IF EXISTS `tags_index`;
2074 CREATE TABLE `tags_index` ( -- a weighted list of all tags and where they are used
2075   `term`    varchar(255) NOT NULL, -- the tag
2076   `biblionumber` int(11) NOT NULL, -- the bib record this tag was used on (biblio.biblionumber)
2077   `weight`        int(9) NOT NULL default '1', -- the number of times this term was used on this bib record
2078   PRIMARY KEY  (`term`,`biblionumber`),
2079   KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
2080   CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
2081         REFERENCES `tags_approval` (`term`)  ON DELETE CASCADE ON UPDATE CASCADE,
2082   CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
2083         REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2084 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2085
2086 --
2087 -- Table structure for table `userflags`
2088 --
2089
2090 DROP TABLE IF EXISTS `userflags`;
2091 CREATE TABLE `userflags` (
2092   `bit` int(11) NOT NULL default 0,
2093   `flag` varchar(30) default NULL,
2094   `flagdesc` varchar(255) default NULL,
2095   `defaulton` int(11) default NULL,
2096   PRIMARY KEY  (`bit`)
2097 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2098
2099 --
2100 -- Table structure for table `virtualshelves`
2101 --
2102
2103 DROP TABLE IF EXISTS `virtualshelves`;
2104 CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) 
2105   `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2106   `shelfname` varchar(255) default NULL, -- name of the list
2107   `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)
2108   `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2109   `sortfield` varchar(16) default 'title', -- the field this list is sorted on
2110   `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2111   `created_on` datetime NOT NULL, -- creation time
2112   `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2113   `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2114   `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2115   PRIMARY KEY  (`shelfnumber`),
2116   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
2117 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2118
2119 --
2120 -- Table structure for table `virtualshelfcontents`
2121 --
2122
2123 DROP TABLE IF EXISTS `virtualshelfcontents`;
2124 CREATE TABLE `virtualshelfcontents` ( -- information about the titles in a list (or virtual shelf)
2125   `shelfnumber` int(11) NOT NULL default 0, -- foreign key linking to the virtualshelves table, defines the list that this record has been added to
2126   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking to the biblio table, defines the bib record that has been added to the list
2127   `flags` int(11) default NULL,
2128   `dateadded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date and time this bib record was added to the list
2129   `borrowernumber` int, -- borrower number that created this list entry (only the first one is saved: no need for use in/as key)
2130   KEY `shelfnumber` (`shelfnumber`),
2131   KEY `biblionumber` (`biblionumber`),
2132   CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2133   CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2134   CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
2135 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2136
2137 --
2138 -- Table structure for table `virtualshelfshares`
2139 --
2140
2141 DROP TABLE IF EXISTS `virtualshelfshares`;
2142 CREATE TABLE `virtualshelfshares` ( -- shared private lists
2143   `id` int AUTO_INCREMENT PRIMARY KEY,  -- unique key
2144   `shelfnumber` int NOT NULL,  -- foreign key for virtualshelves
2145   `borrowernumber` int,  -- borrower that accepted access to this list
2146   `invitekey` varchar(10), -- temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet
2147   `sharedate` datetime,  -- date of invitation or acceptance of invitation
2148   CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2149   CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm
2150 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2151
2152 --
2153 -- Table structure for table `z3950servers`
2154 --
2155
2156 DROP TABLE IF EXISTS `z3950servers`;
2157 CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets used in cataloging
2158   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2159   `host` varchar(255) default NULL, -- target's host name
2160   `port` int(11) default NULL, -- port number used to connect to target
2161   `db` varchar(255) default NULL, -- target's database name
2162   `userid` varchar(255) default NULL, -- username needed to log in to target
2163   `password` varchar(255) default NULL, -- password needed to log in to target
2164   `servername` mediumtext NOT NULL, -- name given to the target by the library
2165   `checked` smallint(6) default NULL, -- whether this target is checked by default  (1 for yes, 0 for no)
2166   `rank` int(11) default NULL, -- where this target appears in the list of targets
2167   `syntax` varchar(80) default NULL, -- marc format provided by this target
2168   `timeout` int(11) NOT NULL DEFAULT '0', -- number of seconds before Koha stops trying to access this server
2169   `servertype` enum('zed','sru') NOT NULL default 'zed', -- zed means z39.50 server
2170   `encoding` text default NULL, -- characters encoding provided by this target
2171   `recordtype` enum('authority','biblio') NOT NULL default 'biblio', -- server contains bibliographic or authority records
2172   `sru_options` varchar(255) default NULL, -- options like sru=get, sru_version=1.1; will be passed to the server via ZOOM
2173   `sru_fields` mediumtext default NULL, -- contains the mapping between the Z3950 search fields and the specific SRU server indexes
2174   `add_xslt` mediumtext default NULL, -- zero or more paths to XSLT files to be processed on the search results
2175   PRIMARY KEY  (`id`)
2176 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2177
2178 --
2179 -- Table structure for table `zebraqueue`
2180 --
2181
2182 DROP TABLE IF EXISTS `zebraqueue`;
2183 CREATE TABLE `zebraqueue` (
2184   `id` int(11) NOT NULL auto_increment,
2185   `biblio_auth_number` bigint(20) unsigned NOT NULL default '0',
2186   `operation` char(20) NOT NULL default '',
2187   `server` char(20) NOT NULL default '',
2188   `done` int(11) NOT NULL default '0',
2189   `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2190   PRIMARY KEY  (`id`),
2191   KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)
2192 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2193
2194 --
2195 -- Table structure for table `services_throttle`
2196 --
2197
2198 DROP TABLE IF EXISTS `services_throttle`;
2199 CREATE TABLE `services_throttle` (
2200   `service_type` varchar(10) NOT NULL default '',
2201   `service_count` varchar(45) default NULL,
2202   PRIMARY KEY  (`service_type`)
2203 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2204
2205 --
2206 -- Table structure for table `language_subtag_registry`
2207 -- http://www.w3.org/International/articles/language-tags/
2208 -- RFC4646
2209 --
2210
2211 DROP TABLE IF EXISTS language_subtag_registry;
2212 CREATE TABLE language_subtag_registry (
2213         subtag varchar(25),
2214         type varchar(25), -- language-script-region-variant-extension-privateuse
2215         description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
2216         added date,
2217         id int(11) NOT NULL auto_increment,
2218         PRIMARY KEY  (`id`),
2219         KEY `subtag` (`subtag`)
2220 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2221
2222 --
2223 -- Table structure for table `language_rfc4646_to_iso639`
2224 -- TODO: add suppress_scripts
2225 -- this maps three letter codes defined in iso639.2 back to their
2226 -- two letter equivilents in rfc4646 (LOC maintains iso639+)
2227 --
2228
2229 DROP TABLE IF EXISTS language_rfc4646_to_iso639;
2230 CREATE TABLE language_rfc4646_to_iso639 (
2231         rfc4646_subtag varchar(25),
2232         iso639_2_code varchar(25),
2233         id int(11) NOT NULL auto_increment,
2234         PRIMARY KEY  (`id`),
2235         KEY `rfc4646_subtag` (`rfc4646_subtag`)
2236 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2237
2238 --
2239 -- Table structure for table `language_descriptions`
2240 --
2241
2242 DROP TABLE IF EXISTS language_descriptions;
2243 CREATE TABLE language_descriptions (
2244         subtag varchar(25),
2245         type varchar(25),
2246         lang varchar(25),
2247         description varchar(255),
2248         id int(11) NOT NULL auto_increment,
2249         PRIMARY KEY  (`id`),
2250         KEY `lang` (`lang`),
2251         KEY `subtag_type_lang` (`subtag`, `type`, `lang`)
2252 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2253
2254 --
2255 -- Table structure for table `language_script_bidi`
2256 -- bi-directional support, keyed by script subcode
2257 --
2258
2259 DROP TABLE IF EXISTS language_script_bidi;
2260 CREATE TABLE language_script_bidi (
2261         rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
2262         bidi varchar(3), -- rtl ltr
2263         KEY `rfc4646_subtag` (`rfc4646_subtag`)
2264 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2265
2266 --
2267 -- Table structure for table `language_script_mapping`
2268 -- TODO: need to map language subtags to script subtags for detection
2269 -- of bidi when script is not specified (like ar, he)
2270 --
2271
2272 DROP TABLE IF EXISTS language_script_mapping;
2273 CREATE TABLE language_script_mapping (
2274         language_subtag varchar(25),
2275         script_subtag varchar(25),
2276         KEY `language_subtag` (`language_subtag`)
2277 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2278
2279 --
2280 -- Table structure for table `permissions`
2281 --
2282
2283 DROP TABLE IF EXISTS `permissions`;
2284 CREATE TABLE `permissions` (
2285   `module_bit` int(11) NOT NULL DEFAULT 0,
2286   `code` varchar(64) NOT NULL DEFAULT '',
2287   `description` varchar(255) DEFAULT NULL,
2288   PRIMARY KEY  (`module_bit`, `code`),
2289   CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
2290     ON DELETE CASCADE ON UPDATE CASCADE
2291 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2292
2293 --
2294 -- Table structure for table `serialitems`
2295 --
2296
2297 DROP TABLE IF EXISTS `serialitems`;
2298 CREATE TABLE `serialitems` (
2299         `itemnumber` int(11) NOT NULL,
2300         `serialid` int(11) NOT NULL,
2301         UNIQUE KEY `serialitemsidx` (`itemnumber`),
2302         KEY `serialitems_sfk_1` (`serialid`),
2303         CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
2304         CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
2305 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2306
2307 --
2308 -- Table structure for table `user_permissions`
2309 --
2310
2311 DROP TABLE IF EXISTS `user_permissions`;
2312 CREATE TABLE `user_permissions` (
2313   `borrowernumber` int(11) NOT NULL DEFAULT 0,
2314   `module_bit` int(11) NOT NULL DEFAULT 0,
2315   `code` varchar(64) DEFAULT NULL,
2316   CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
2317     ON DELETE CASCADE ON UPDATE CASCADE,
2318   CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`) REFERENCES `permissions` (`module_bit`, `code`)
2319     ON DELETE CASCADE ON UPDATE CASCADE
2320 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2321
2322 --
2323 -- Table structure for table `tmp_holdsqueue`
2324 --
2325
2326 DROP TABLE IF EXISTS `tmp_holdsqueue`;
2327 CREATE TABLE `tmp_holdsqueue` (
2328   `biblionumber` int(11) default NULL,
2329   `itemnumber` int(11) default NULL,
2330   `barcode` varchar(20) default NULL,
2331   `surname` mediumtext NOT NULL,
2332   `firstname` text,
2333   `phone` text,
2334   `borrowernumber` int(11) NOT NULL,
2335   `cardnumber` varchar(16) default NULL,
2336   `reservedate` date default NULL,
2337   `title` mediumtext,
2338   `itemcallnumber` varchar(255) default NULL,
2339   `holdingbranch` varchar(10) default NULL,
2340   `pickbranch` varchar(10) default NULL,
2341   `notes` text,
2342   `item_level_request` tinyint(4) NOT NULL default 0
2343 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2344
2345 --
2346 -- Table structure for table `message_transport_types`
2347 --
2348
2349 DROP TABLE IF EXISTS `message_transport_types`;
2350 CREATE TABLE `message_transport_types` (
2351   `message_transport_type` varchar(20) NOT NULL,
2352   PRIMARY KEY  (`message_transport_type`)
2353 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2354
2355 --
2356 -- Table structure for table `message_queue`
2357 --
2358
2359 DROP TABLE IF EXISTS `message_queue`;
2360 CREATE TABLE `message_queue` (
2361   `message_id` int(11) NOT NULL auto_increment,
2362   `borrowernumber` int(11) default NULL,
2363   `subject` text,
2364   `content` text,
2365   `metadata` text DEFAULT NULL,
2366   `letter_code` varchar(64) DEFAULT NULL,
2367   `message_transport_type` varchar(20) NOT NULL,
2368   `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
2369   `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2370   `to_address` mediumtext,
2371   `from_address` mediumtext,
2372   `content_type` text,
2373   PRIMARY KEY `message_id` (`message_id`),
2374   KEY `borrowernumber` (`borrowernumber`),
2375   KEY `message_transport_type` (`message_transport_type`),
2376   CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2377   CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
2378 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2379
2380 --
2381 -- Table structure for table `letter`
2382 --
2383
2384 DROP TABLE IF EXISTS `letter`;
2385 CREATE TABLE `letter` ( -- table for all notice templates in Koha
2386   `module` varchar(20) NOT NULL default '', -- Koha module that triggers this notice or slip
2387   `code` varchar(20) NOT NULL default '', -- unique identifier for this notice or slip
2388   `branchcode` varchar(10) NOT NULL default '', -- the branch this notice or slip is used at (branches.branchcode)
2389   `name` varchar(100) NOT NULL default '', -- plain text name for this notice or slip
2390   `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
2391   `title` varchar(200) NOT NULL default '', -- subject line of the notice
2392   `content` text, -- body text for the notice or slip
2393   `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
2394   PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
2395   CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
2396   REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
2397 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2398
2399 --
2400 -- Table structure for table `overduerules_transport_types`
2401 --
2402
2403 DROP TABLE IF EXISTS `overduerules_transport_types`;
2404 CREATE TABLE overduerules_transport_types(
2405     `id` INT(11) NOT NULL AUTO_INCREMENT,
2406     `branchcode` varchar(10) NOT NULL DEFAULT '',
2407     `categorycode` VARCHAR(10) NOT NULL DEFAULT '',
2408     `letternumber` INT(1) NOT NULL DEFAULT 1,
2409     `message_transport_type` VARCHAR(20) NOT NULL DEFAULT 'email',
2410     PRIMARY KEY (id),
2411     CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
2412     CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
2413 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2414
2415 --
2416 -- Table structure for table `message_attributes`
2417 --
2418
2419 DROP TABLE IF EXISTS `message_attributes`;
2420 CREATE TABLE `message_attributes` (
2421   `message_attribute_id` int(11) NOT NULL auto_increment,
2422   `message_name` varchar(40) NOT NULL default '',
2423   `takes_days` tinyint(1) NOT NULL default '0',
2424   PRIMARY KEY  (`message_attribute_id`),
2425   UNIQUE KEY `message_name` (`message_name`)
2426 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2427
2428 --
2429 -- Table structure for table `message_transports`
2430 --
2431
2432 DROP TABLE IF EXISTS `message_transports`;
2433 CREATE TABLE `message_transports` (
2434   `message_attribute_id` int(11) NOT NULL,
2435   `message_transport_type` varchar(20) NOT NULL,
2436   `is_digest` tinyint(1) NOT NULL default '0',
2437   `letter_module` varchar(20) NOT NULL default '',
2438   `letter_code` varchar(20) NOT NULL default '',
2439   `branchcode` varchar(10) NOT NULL default '',
2440   PRIMARY KEY  (`message_attribute_id`,`message_transport_type`,`is_digest`),
2441   KEY `message_transport_type` (`message_transport_type`),
2442   KEY `letter_module` (`letter_module`,`letter_code`),
2443   CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2444   CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
2445   CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`, `branchcode`) REFERENCES `letter` (`module`, `code`, `branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2446 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2447
2448 --
2449 -- Table structure for table `borrower_files`
2450 --
2451
2452 DROP TABLE IF EXISTS `borrower_files`;
2453 CREATE TABLE IF NOT EXISTS `borrower_files` ( -- files attached to the patron/borrower record
2454   `file_id` int(11) NOT NULL AUTO_INCREMENT, -- unique key
2455   `borrowernumber` int(11) NOT NULL, -- foreign key linking to the patron via the borrowernumber
2456   `file_name` varchar(255) NOT NULL, -- file name
2457   `file_type` varchar(255) NOT NULL, -- type of file
2458   `file_description` varchar(255) DEFAULT NULL, -- description given to the file
2459   `file_content` longblob NOT NULL, -- the file
2460   `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date and time the file was added
2461   PRIMARY KEY (`file_id`),
2462   KEY `borrowernumber` (`borrowernumber`),
2463   CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
2464 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2465
2466 --
2467 -- Table structure for table `borrower_message_preferences`
2468 --
2469
2470 DROP TABLE IF EXISTS `borrower_message_preferences`;
2471 CREATE TABLE `borrower_message_preferences` (
2472   `borrower_message_preference_id` int(11) NOT NULL auto_increment,
2473   `borrowernumber` int(11) default NULL,
2474   `categorycode` varchar(10) default NULL,
2475   `message_attribute_id` int(11) default '0',
2476   `days_in_advance` int(11) default '0',
2477   `wants_digest` tinyint(1) NOT NULL default '0',
2478   PRIMARY KEY  (`borrower_message_preference_id`),
2479   KEY `borrowernumber` (`borrowernumber`),
2480   KEY `categorycode` (`categorycode`),
2481   KEY `message_attribute_id` (`message_attribute_id`),
2482   CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2483   CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2484   CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
2485 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2486
2487 --
2488 -- Table structure for table `borrower_message_transport_preferences`
2489 --
2490
2491 DROP TABLE IF EXISTS `borrower_message_transport_preferences`;
2492 CREATE TABLE `borrower_message_transport_preferences` (
2493   `borrower_message_preference_id` int(11) NOT NULL default '0',
2494   `message_transport_type` varchar(20) NOT NULL default '0',
2495   PRIMARY KEY  (`borrower_message_preference_id`,`message_transport_type`),
2496   KEY `message_transport_type` (`message_transport_type`),
2497   CONSTRAINT `borrower_message_transport_preferences_ibfk_1` FOREIGN KEY (`borrower_message_preference_id`) REFERENCES `borrower_message_preferences` (`borrower_message_preference_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2498   CONSTRAINT `borrower_message_transport_preferences_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
2499 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2500
2501 --
2502 -- Table structure for the table branch_transfer_limits
2503 --
2504
2505 DROP TABLE IF EXISTS `branch_transfer_limits`;
2506 CREATE TABLE branch_transfer_limits (
2507     limitId int(8) NOT NULL auto_increment,
2508     toBranch varchar(10) NOT NULL,
2509     fromBranch varchar(10) NOT NULL,
2510     itemtype varchar(10) NULL,
2511     ccode varchar(10) NULL,
2512     PRIMARY KEY  (limitId)
2513 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2514
2515 --
2516 -- Table structure for table `item_circulation_alert_preferences`
2517 --
2518
2519 DROP TABLE IF EXISTS `item_circulation_alert_preferences`;
2520 CREATE TABLE `item_circulation_alert_preferences` (
2521   `id` int(11) NOT NULL auto_increment,
2522   `branchcode` varchar(10) NOT NULL,
2523   `categorycode` varchar(10) NOT NULL,
2524   `item_type` varchar(10) NOT NULL,
2525   `notification` varchar(16) NOT NULL,
2526   PRIMARY KEY  (`id`),
2527   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`, `notification`)
2528 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2529
2530 --
2531 -- Table structure for table `messages`
2532 --
2533 DROP TABLE IF EXISTS `messages`;
2534 CREATE TABLE `messages` ( -- circulation messages left via the patron's check out screen
2535   `message_id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2536   `borrowernumber` int(11) NOT NULL, -- foreign key linking this message to the borrowers table
2537   `branchcode` varchar(10) default NULL, -- foreign key linking the message to the branches table
2538   `message_type` varchar(1) NOT NULL, -- whether the message is for the librarians (L) or the patron (B)
2539   `message` text NOT NULL, -- the text of the message
2540   `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- the date and time the message was written
2541   PRIMARY KEY (`message_id`)
2542 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2543
2544 --
2545 -- Table structure for table `accountlines`
2546 --
2547
2548 DROP TABLE IF EXISTS `accountlines`;
2549 CREATE TABLE `accountlines` (
2550   `accountlines_id` int(11) NOT NULL AUTO_INCREMENT,
2551   `borrowernumber` int(11) NOT NULL default 0,
2552   `accountno` smallint(6) NOT NULL default 0,
2553   `itemnumber` int(11) default NULL,
2554   `date` date default NULL,
2555   `amount` decimal(28,6) default NULL,
2556   `description` mediumtext,
2557   `dispute` mediumtext,
2558   `accounttype` varchar(5) default NULL,
2559   `amountoutstanding` decimal(28,6) default NULL,
2560   `lastincrement` decimal(28,6) default NULL,
2561   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2562   `notify_id` int(11) NOT NULL default 0,
2563   `notify_level` int(2) NOT NULL default 0,
2564   `note` text NULL default NULL,
2565   `manager_id` int(11) NULL,
2566   PRIMARY KEY (`accountlines_id`),
2567   KEY `acctsborridx` (`borrowernumber`),
2568   KEY `timeidx` (`timestamp`),
2569   KEY `itemnumber` (`itemnumber`),
2570   CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2571   CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
2572 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2573
2574 --
2575 -- Table structure for table `accountoffsets`
2576 --
2577
2578 DROP TABLE IF EXISTS `accountoffsets`;
2579 CREATE TABLE `accountoffsets` (
2580   `borrowernumber` int(11) NOT NULL default 0,
2581   `accountno` smallint(6) NOT NULL default 0,
2582   `offsetaccount` smallint(6) NOT NULL default 0,
2583   `offsetamount` decimal(28,6) default NULL,
2584   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2585   CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2586 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2587
2588 --
2589 -- Table structure for table `action_logs`
2590 --
2591
2592 DROP TABLE IF EXISTS `action_logs`;
2593 CREATE TABLE `action_logs` ( -- logs of actions taken in Koha (requires that the logs be turned on)
2594   `action_id` int(11) NOT NULL auto_increment, -- unique identifier for each action
2595   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time the action took place
2596   `user` int(11) NOT NULL default 0, -- the staff member who performed the action (borrowers.borrowernumber)
2597   `module` text, -- the module this action was taken against
2598   `action` text, -- the action (includes things like DELETED, ADDED, MODIFY, etc)
2599   `object` int(11) default NULL, -- the object that the action was taken against (could be a borrowernumber, itemnumber, etc)
2600   `info` text, -- information about the action (usually includes SQL statement)
2601   PRIMARY KEY (`action_id`),
2602   KEY `timestamp_idx` (`timestamp`),
2603   KEY `user_idx` (`user`),
2604   KEY `module_idx` (`module`(255)),
2605   KEY `action_idx` (`action`(255)),
2606   KEY `object_idx` (`object`),
2607   KEY `info_idx` (`info`(255))
2608 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2609
2610 --
2611 -- Table structure for table `alert`
2612 --
2613
2614 DROP TABLE IF EXISTS `alert`;
2615 CREATE TABLE `alert` (
2616   `alertid` int(11) NOT NULL auto_increment,
2617   `borrowernumber` int(11) NOT NULL default 0,
2618   `type` varchar(10) NOT NULL default '',
2619   `externalid` varchar(20) NOT NULL default '',
2620   PRIMARY KEY  (`alertid`),
2621   KEY `borrowernumber` (`borrowernumber`),
2622   KEY `type` (`type`,`externalid`)
2623 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2624
2625 --
2626 -- Table structure for table `aqbooksellers`
2627 --
2628
2629 DROP TABLE IF EXISTS `aqbooksellers`;
2630 CREATE TABLE `aqbooksellers` ( -- information about the vendors listed in acquisitions
2631   `id` int(11) NOT NULL auto_increment, -- primary key and unique identifier assigned by Koha
2632   `name` mediumtext NOT NULL, -- vendor name
2633   `address1` mediumtext, -- first line of vendor physical address
2634   `address2` mediumtext, -- second line of vendor physical address
2635   `address3` mediumtext, -- third line of vendor physical address
2636   `address4` mediumtext, -- fourth line of vendor physical address
2637   `phone` varchar(30) default NULL, -- vendor phone number
2638   `accountnumber` mediumtext, -- unused in Koha
2639   `othersupplier` mediumtext,  -- unused in Koha
2640   `currency` varchar(3) NOT NULL default '', -- unused in Koha
2641   `booksellerfax` mediumtext, -- vendor fax number
2642   `notes` mediumtext, -- order notes
2643   `bookselleremail` mediumtext, -- vendor email
2644   `booksellerurl` mediumtext, -- unused in Koha
2645   `postal` mediumtext, -- vendor postal address (all lines)
2646   `url` varchar(255) default NULL, -- vendor web address
2647   `active` tinyint(4) default NULL, -- is this vendor active (1 for yes, 0 for no)
2648   `listprice` varchar(10) default NULL, -- currency code for list prices
2649   `invoiceprice` varchar(10) default NULL, -- currency code for invoice prices
2650   `gstreg` tinyint(4) default NULL, -- is your library charged tax (1 for yes, 0 for no)
2651   `listincgst` tinyint(4) default NULL, -- is tax included in list prices (1 for yes, 0 for no)
2652   `invoiceincgst` tinyint(4) default NULL, -- is tax included in invoice prices (1 for yes, 0 for no)
2653   `gstrate` decimal(6,4) default NULL, -- the tax rate the library is charged
2654   `discount` float(6,4) default NULL, -- discount offered on all items ordered from this vendor
2655   `fax` varchar(50) default NULL, -- vendor fax number
2656   deliverytime int(11) default NULL, -- vendor delivery time
2657   PRIMARY KEY  (`id`),
2658   KEY `listprice` (`listprice`),
2659   KEY `invoiceprice` (`invoiceprice`),
2660   KEY `name` (`name`(255)),
2661   CONSTRAINT `aqbooksellers_ibfk_1` FOREIGN KEY (`listprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE,
2662   CONSTRAINT `aqbooksellers_ibfk_2` FOREIGN KEY (`invoiceprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE
2663 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2664
2665 --
2666 -- Table structure for table `aqbasketgroups`
2667 --
2668
2669 DROP TABLE IF EXISTS `aqbasketgroups`;
2670 CREATE TABLE `aqbasketgroups` (
2671   `id` int(11) NOT NULL auto_increment,
2672   `name` varchar(50) default NULL,
2673   `closed` tinyint(1) default NULL,
2674   `booksellerid` int(11) NOT NULL,
2675   `deliveryplace` varchar(10) default NULL,
2676   `freedeliveryplace` text default NULL,
2677   `deliverycomment` varchar(255) default NULL,
2678   `billingplace` varchar(10) default NULL,
2679   PRIMARY KEY  (`id`),
2680   KEY `booksellerid` (`booksellerid`),
2681   CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2682 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2683
2684 --
2685 -- Table structure for table `aqbudgets`
2686 --
2687
2688 DROP TABLE IF EXISTS `aqbudgets`;
2689 CREATE TABLE `aqbudgets` ( -- information related to Funds
2690   `budget_id` int(11) NOT NULL auto_increment, -- primary key and unique number assigned to each fund by Koha
2691   `budget_parent_id` int(11) default NULL, -- if this fund is a child of another this will include the parent id (aqbudgets.budget_id)
2692   `budget_code` varchar(30) default NULL, -- code assigned to the fund by the user
2693   `budget_name` varchar(80) default NULL, -- name assigned to the fund by the user
2694   `budget_branchcode` varchar(10) default NULL, -- branch that this fund belongs to (branches.branchcode)
2695   `budget_amount` decimal(28,6) NULL default '0.00', -- total amount for this fund
2696   `budget_encumb` decimal(28,6) NULL default '0.00', -- not used in the code
2697   `budget_expend` decimal(28,6) NULL default '0.00', -- not used in the code
2698   `budget_notes` mediumtext, -- notes related to this fund
2699   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this fund was last touched (created or modified)
2700   `budget_period_id` int(11) default NULL, -- id of the budget that this fund belongs to (aqbudgetperiods.budget_period_id)
2701   `sort1_authcat` varchar(80) default NULL, -- statistical category for this fund
2702   `sort2_authcat` varchar(80) default NULL, -- second statistical category for this fund
2703   `budget_owner_id` int(11) default NULL, -- borrowernumber of the person who owns this fund (borrowers.borrowernumber)
2704   `budget_permission` int(1) default '0', -- level of permission for this fund (used only by the owner, only by the library, or anyone)
2705   PRIMARY KEY  (`budget_id`),
2706   KEY `budget_parent_id` (`budget_parent_id`),
2707   KEY `budget_code` (`budget_code`),
2708   KEY `budget_branchcode` (`budget_branchcode`),
2709   KEY `budget_period_id` (`budget_period_id`),
2710   KEY `budget_owner_id` (`budget_owner_id`)
2711 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2712
2713 --
2714 -- Table structure for table aqbudgetborrowers
2715 --
2716
2717 DROP TABLE IF EXISTS aqbudgetborrowers;
2718 CREATE TABLE aqbudgetborrowers (
2719   budget_id int(11) NOT NULL,
2720   borrowernumber int(11) NOT NULL,
2721   PRIMARY KEY (budget_id, borrowernumber),
2722   CONSTRAINT aqbudgetborrowers_ibfk_1 FOREIGN KEY (budget_id)
2723     REFERENCES aqbudgets (budget_id)
2724     ON DELETE CASCADE ON UPDATE CASCADE,
2725   CONSTRAINT aqbudgetborrowers_ibfk_2 FOREIGN KEY (borrowernumber)
2726     REFERENCES borrowers (borrowernumber)
2727     ON DELETE CASCADE ON UPDATE CASCADE
2728 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2729
2730 --
2731 -- Table structure for table `aqbudgetperiods`
2732 --
2733
2734
2735 DROP TABLE IF EXISTS `aqbudgetperiods`;
2736 CREATE TABLE `aqbudgetperiods` ( -- information related to Budgets
2737   `budget_period_id` int(11) NOT NULL auto_increment, -- primary key and unique number assigned by Koha
2738   `budget_period_startdate` date NOT NULL, -- date when the budget starts
2739   `budget_period_enddate` date NOT NULL, -- date when the budget ends
2740   `budget_period_active` tinyint(1) default '0', -- whether this budget is active or not (1 for yes, 0 for no)
2741   `budget_period_description` mediumtext, -- description assigned to this budget
2742   `budget_period_total` decimal(28,6), -- total amount available in this budget
2743   `budget_period_locked` tinyint(1) default NULL, -- whether this budget is locked or not (1 for yes, 0 for no)
2744   `sort1_authcat` varchar(10) default NULL, -- statistical category for this budget
2745   `sort2_authcat` varchar(10) default NULL, -- second statistical category for this budget
2746   PRIMARY KEY  (`budget_period_id`)
2747 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2748
2749 --
2750 -- Table structure for table `aqbudgets_planning`
2751 --
2752
2753 DROP TABLE IF EXISTS `aqbudgets_planning`;
2754 CREATE TABLE `aqbudgets_planning` (
2755   `plan_id` int(11) NOT NULL auto_increment,
2756   `budget_id` int(11) NOT NULL,
2757   `budget_period_id` int(11) NOT NULL,
2758   `estimated_amount` decimal(28,6) default NULL,
2759   `authcat` varchar(30) NOT NULL,
2760   `authvalue` varchar(30) NOT NULL,
2761   `display` tinyint(1) DEFAULT 1,
2762   PRIMARY KEY  (`plan_id`),
2763   KEY `budget_period_id` (`budget_period_id`),
2764   CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
2765 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2766
2767 --
2768 -- Table structure for table 'aqcontacts'
2769 --
2770
2771 DROP TABLE IF EXISTS aqcontacts;
2772 CREATE TABLE aqcontacts (
2773   id int(11) NOT NULL auto_increment, -- primary key and unique number assigned by Koha
2774   name varchar(100) default NULL, -- name of contact at vendor
2775   position varchar(100) default NULL, -- contact person's position
2776   phone varchar(100) default NULL, -- contact's phone number
2777   altphone varchar(100) default NULL, -- contact's alternate phone number
2778   fax varchar(100) default NULL,  -- contact's fax number
2779   email varchar(100) default NULL, -- contact's email address
2780   notes mediumtext, -- notes related to the contact
2781   claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims
2782   claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims
2783   acqprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for acquisitions messages
2784   serialsprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for serials messages
2785   booksellerid int(11) not NULL,
2786   PRIMARY KEY  (id),
2787   CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
2788        REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
2789 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
2790
2791 --
2792 -- Table structure for table 'aqcontract'
2793 --
2794
2795 DROP TABLE IF EXISTS `aqcontract`;
2796 CREATE TABLE `aqcontract` (
2797   `contractnumber` int(11) NOT NULL auto_increment,
2798   `contractstartdate` date default NULL,
2799   `contractenddate` date default NULL,
2800   `contractname` varchar(50) default NULL,
2801   `contractdescription` mediumtext,
2802   `booksellerid` int(11) not NULL,
2803   PRIMARY KEY  (`contractnumber`),
2804   CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2805        REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2806 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
2807
2808 --
2809 -- Table structure for table `aqbasket`
2810 --
2811
2812 DROP TABLE IF EXISTS `aqbasket`;
2813 CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions
2814   `basketno` int(11) NOT NULL auto_increment, -- primary key, Koha defined number
2815   `basketname` varchar(50) default NULL, -- name given to the basket at creation
2816   `note` mediumtext, -- the internal note added at basket creation
2817   `booksellernote` mediumtext, -- the vendor note added at basket creation
2818   `contractnumber` int(11), -- links this basket to the aqcontract table (aqcontract.contractnumber)
2819   `creationdate` date default NULL, -- the date the basket was created
2820   `closedate` date default NULL, -- the date the basket was closed
2821   `booksellerid` int(11) NOT NULL default 1, -- the Koha assigned ID for the vendor (aqbooksellers.id)
2822   `authorisedby` varchar(10) default NULL, -- the borrowernumber of the person who created the basket
2823   `booksellerinvoicenumber` mediumtext, -- appears to always be NULL
2824   `basketgroupid` int(11), -- links this basket to its group (aqbasketgroups.id)
2825   `deliveryplace` varchar(10) default NULL, -- basket delivery place
2826   `billingplace` varchar(10) default NULL, -- basket billing place
2827   branch varchar(10) default NULL, -- basket branch
2828   PRIMARY KEY  (`basketno`),
2829   KEY `booksellerid` (`booksellerid`),
2830   KEY `basketgroupid` (`basketgroupid`),
2831   KEY `contractnumber` (`contractnumber`),
2832   KEY `authorisedby` (`authorisedby`),
2833   CONSTRAINT `aqbasket_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE,
2834   CONSTRAINT `aqbasket_ibfk_2` FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`),
2835   CONSTRAINT `aqbasket_ibfk_3` FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE,
2836   CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL
2837 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2838
2839 --
2840 -- Table structure for table aqbasketusers
2841 --
2842
2843 DROP TABLE IF EXISTS aqbasketusers;
2844 CREATE TABLE aqbasketusers (
2845   basketno int(11) NOT NULL,
2846   borrowernumber int(11) NOT NULL,
2847   PRIMARY KEY (basketno,borrowernumber),
2848   CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON UPDATE CASCADE ON DELETE CASCADE,
2849   CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
2850 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2851
2852 --
2853 -- Table structure for table `suggestions`
2854 --
2855
2856 DROP TABLE IF EXISTS `suggestions`;
2857 CREATE TABLE `suggestions` ( -- purchase suggestions
2858   `suggestionid` int(8) NOT NULL auto_increment, -- unique identifier assigned automatically by Koha
2859   `suggestedby` int(11) NOT NULL default 0, -- borrowernumber for the person making the suggestion, foreign key linking to the borrowers table
2860   `suggesteddate` date NOT NULL, -- date the suggestion was submitted
2861   `managedby` int(11) default NULL, -- borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table
2862   `manageddate` date default NULL, -- date the suggestion was updated
2863    acceptedby INT(11) default NULL, -- borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table
2864    accepteddate date default NULL, -- date the suggestion was marked as accepted
2865    rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table
2866    rejecteddate date default NULL, -- date the suggestion was marked as rejected
2867   `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)
2868   `note` mediumtext, -- note entered on the suggestion
2869   `author` varchar(80) default NULL, -- author of the suggested item
2870   `title` varchar(255) default NULL, -- title of the suggested item
2871   `copyrightdate` smallint(6) default NULL, -- copyright date of the suggested item
2872   `publishercode` varchar(255) default NULL, -- publisher of the suggested item
2873   `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  -- date and time the suggestion was updated
2874   `volumedesc` varchar(255) default NULL,
2875   `publicationyear` smallint(6) default 0,
2876   `place` varchar(255) default NULL, -- publication place of the suggested item
2877   `isbn` varchar(30) default NULL, -- isbn of the suggested item
2878   `biblionumber` int(11) default NULL, -- foreign key linking the suggestion to the biblio table after the suggestion has been ordered
2879   `reason` text, -- reason for accepting or rejecting the suggestion
2880   `patronreason` text, -- reason for making the suggestion
2881    budgetid INT(11), -- foreign key linking the suggested budget to the aqbudgets table
2882    branchcode VARCHAR(10) default NULL, -- foreign key linking the suggested branch to the branches table
2883    collectiontitle text default NULL, -- collection name for the suggested item
2884    itemtype VARCHAR(30) default NULL, -- suggested item type 
2885    quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased
2886    currency VARCHAR(3) default NULL, -- suggested currency for the suggested price
2887    price DECIMAL(28,6) default NULL, -- suggested price
2888    total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2889   PRIMARY KEY  (`suggestionid`),
2890   KEY `suggestedby` (`suggestedby`),
2891   KEY `managedby` (`managedby`),
2892   KEY `status` (`STATUS`),
2893   KEY `biblionumber` (`biblionumber`),
2894   KEY `branchcode` (`branchcode`),
2895   CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE
2896 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2897
2898 --
2899 -- Table structure for table aqinvoices
2900 --
2901
2902 DROP TABLE IF EXISTS aqinvoices;
2903 CREATE TABLE aqinvoices (
2904   invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
2905   invoicenumber mediumtext NOT NULL,    -- Name of invoice
2906   booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
2907   shipmentdate date default NULL,   -- date of shipment
2908   billingdate date default NULL,    -- date of billing
2909   closedate date default NULL,  -- invoice close date, NULL means the invoice is open
2910   shipmentcost decimal(28,6) default NULL,  -- shipment cost
2911   shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
2912   PRIMARY KEY (invoiceid),
2913   CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
2914   CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
2915 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2916
2917 --
2918 -- Table structure for table `aqorders`
2919 --
2920
2921 DROP TABLE IF EXISTS `aqorders`;
2922 CREATE TABLE `aqorders` ( -- information related to the basket line items
2923   `ordernumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier assigned by Koha to each line
2924   `biblionumber` int(11) default NULL, -- links the order to the biblio being ordered (biblio.biblionumber)
2925   `entrydate` date default NULL, -- the date the bib was added to the basket
2926   `quantity` smallint(6) default NULL, -- the quantity ordered
2927   `currency` varchar(3) default NULL, -- the currency used for the purchase
2928   `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
2929   `datereceived` date default NULL, -- the date this order was received
2930   invoiceid int(11) default NULL, -- id of invoice
2931   `freight` decimal(28,6) default NULL, -- shipping costs (not used)
2932   `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
2933   `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
2934   `datecancellationprinted` date default NULL, -- the date the line item was deleted
2935   `cancellationreason` text default NULL, -- reason of cancellation
2936   `order_internalnote` mediumtext, -- notes related to this order line, made for staff
2937   `order_vendornote` mediumtext, -- notes related to this order line, made for vendor
2938   `purchaseordernumber` mediumtext, -- not used? always NULL
2939   `basketno` int(11) default NULL, -- links this order line to a specific basket (aqbasket.basketno)
2940   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order line was last modified
2941   `rrp` decimal(13,2) default NULL, -- the replacement cost for this line item
2942   `ecost` decimal(13,2) default NULL, -- the estimated cost for this line item
2943   `gstrate` decimal(6,4) default NULL, -- the tax rate for this line item
2944   `discount` float(6,4) default NULL, -- the discount for this line item
2945   `budget_id` int(11) NOT NULL, -- the fund this order goes against (aqbudgets.budget_id)
2946   `budgetgroup_id` int(11) NOT NULL, -- not used? always zero
2947   `budgetdate` date default NULL, -- not used? always NULL
2948   `sort1` varchar(80) default NULL, -- statistical field
2949   `sort2` varchar(80) default NULL, -- second statistical field
2950   `sort1_authcat` varchar(10) default NULL,
2951   `sort2_authcat` varchar(10) default NULL,
2952   `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
2953   `claims_count` int(11) default 0, -- count of claim letters generated
2954   `claimed_date` date default NULL, -- last date a claim was generated
2955   `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
2956   parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2957   `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
2958   PRIMARY KEY  (`ordernumber`),
2959   KEY `basketno` (`basketno`),
2960   KEY `biblionumber` (`biblionumber`),
2961   KEY `budget_id` (`budget_id`),
2962   KEY `parent_ordernumber` (`parent_ordernumber`),
2963   KEY `orderstatus` (`orderstatus`),
2964   CONSTRAINT `aqorders_budget_id_fk` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2965   CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2966   CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2967   CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE,
2968   CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
2969 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2970
2971 --
2972 -- Table structure for table `aqorder_users`
2973 --
2974
2975 DROP TABLE IF EXISTS `aqorder_users`;
2976 CREATE TABLE aqorder_users ( -- Mapping orders to patrons for notification sending
2977     ordernumber int(11) NOT NULL, -- the order this patrons receive notifications from (aqorders.ordernumber)
2978     borrowernumber int(11) NOT NULL, -- the borrowernumber for the patron receiving notifications for this order (borrowers.borrowernumber)
2979     PRIMARY KEY (ordernumber, borrowernumber),
2980     CONSTRAINT aqorder_users_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE,
2981     CONSTRAINT aqorder_users_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
2982 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2983
2984 --
2985 -- Table structure for table `aqorders_items`
2986 --
2987
2988 DROP TABLE IF EXISTS `aqorders_items`;
2989 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisitions process
2990   `ordernumber` int(11) NOT NULL, -- the order this item is attached to (aqorders.ordernumber)
2991   `itemnumber` int(11) NOT NULL, -- the item number for this item (items.itemnumber)
2992   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this order item was last touched
2993   PRIMARY KEY  (`itemnumber`),
2994   KEY `ordernumber` (`ordernumber`),
2995   CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
2996 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2997
2998 --
2999 -- Table structure for table aqorders_transfers
3000 --
3001
3002 DROP TABLE IF EXISTS aqorders_transfers;
3003 CREATE TABLE aqorders_transfers (
3004   ordernumber_from int(11) NULL,
3005   ordernumber_to int(11) NULL,
3006   timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
3007   UNIQUE KEY ordernumber_from (ordernumber_from),
3008   UNIQUE KEY ordernumber_to (ordernumber_to),
3009   CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
3010   CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3011 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3012
3013 --
3014 -- Table structure for table `fieldmapping`
3015 --
3016
3017 DROP TABLE IF EXISTS `fieldmapping`;
3018 CREATE TABLE `fieldmapping` ( -- koha to keyword mapping
3019   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
3020   `field` varchar(255) NOT NULL, -- keyword to be mapped to (ex. subtitle)
3021   `frameworkcode` char(4) NOT NULL default '', -- foreign key from the biblio_framework table to link this mapping to a specific framework
3022   `fieldcode` char(3) NOT NULL, -- marc field number to map to this keyword
3023   `subfieldcode` char(1) NOT NULL, -- marc subfield associated with the fieldcode to map to this keyword
3024   PRIMARY KEY  (`id`)
3025 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3026
3027 --
3028 -- Table structure for table `transport_cost`
3029 --
3030
3031 DROP TABLE IF EXISTS transport_cost;
3032 CREATE TABLE transport_cost (
3033       frombranch varchar(10) NOT NULL,
3034       tobranch varchar(10) NOT NULL,
3035       cost decimal(6,2) NOT NULL,
3036       disable_transfer tinyint(1) NOT NULL DEFAULT 0,
3037       CHECK ( frombranch <> tobranch ), -- a dud check, mysql does not support that
3038       PRIMARY KEY (frombranch, tobranch),
3039       CONSTRAINT transport_cost_ibfk_1 FOREIGN KEY (frombranch) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE,
3040       CONSTRAINT transport_cost_ibfk_2 FOREIGN KEY (tobranch) REFERENCES branches (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3041 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3042
3043 --
3044 -- Table structure for table `biblioimages`
3045 --
3046
3047 DROP TABLE IF EXISTS `biblioimages`;
3048
3049 CREATE TABLE `biblioimages` ( -- local cover images
3050  `imagenumber` int(11) NOT NULL AUTO_INCREMENT, -- unique identifier for the image
3051  `biblionumber` int(11) NOT NULL, -- foreign key from biblio table to link to biblionumber
3052  `mimetype` varchar(15) NOT NULL, -- image type
3053  `imagefile` mediumblob NOT NULL, -- image file contents
3054  `thumbnail` mediumblob NOT NULL, -- thumbnail file contents
3055  PRIMARY KEY (`imagenumber`),
3056  CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
3057 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3058
3059 --
3060 -- Table structure for table `social_data`
3061 --
3062
3063 DROP TABLE IF EXISTS `social_data`;
3064 CREATE TABLE IF NOT EXISTS `social_data` (
3065   `isbn` VARCHAR(30),
3066   `num_critics` INT,
3067   `num_critics_pro` INT,
3068   `num_quotations` INT,
3069   `num_videos` INT,
3070   `score_avg` DECIMAL(5,2),
3071   `num_scores` INT,
3072   PRIMARY KEY  (`isbn`)
3073 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3074
3075 --
3076 -- 'Ratings' table. This tracks the star ratings set by borrowers.
3077 --
3078
3079 DROP TABLE IF EXISTS ratings;
3080 CREATE TABLE ratings ( -- information related to the star ratings in the OPAC
3081     borrowernumber int(11) NOT NULL, -- the borrowernumber of the patron who left this rating (borrowers.borrowernumber)
3082     biblionumber int(11) NOT NULL, -- the biblio this rating is for (biblio.biblionumber)
3083     rating_value tinyint(1) NOT NULL, -- the rating, from 1 to 5
3084     timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
3085     PRIMARY KEY  (borrowernumber,biblionumber),
3086     CONSTRAINT ratings_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
3087     CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
3088 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3089
3090 --
3091 -- Table structure for table `quotes`
3092 --
3093
3094 DROP TABLE IF EXISTS quotes;
3095 CREATE TABLE `quotes` ( -- data for the quote of the day feature
3096   `id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the quote
3097   `source` text DEFAULT NULL, -- source/credit for the quote
3098   `text` mediumtext NOT NULL, -- text of the quote
3099   `timestamp` datetime NOT NULL, -- date and time that the quote last appeared in the opac
3100   PRIMARY KEY (`id`)
3101 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3102
3103 --
3104 -- Table structure for table categories_branches
3105 --
3106
3107 DROP TABLE IF EXISTS categories_branches;
3108 CREATE TABLE categories_branches( -- association table between categories and branches
3109     categorycode VARCHAR(10),
3110     branchcode VARCHAR(10),
3111     FOREIGN KEY (categorycode) REFERENCES categories(categorycode) ON DELETE CASCADE,
3112     FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
3113 ) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3114
3115 --
3116 -- Table structure for table authorised_values_branches
3117 --
3118
3119 DROP TABLE IF EXISTS authorised_values_branches;
3120 CREATE TABLE authorised_values_branches( -- association table between authorised_values and branches
3121     av_id INT(11) NOT NULL,
3122     branchcode VARCHAR(10) NOT NULL,
3123     FOREIGN KEY (av_id) REFERENCES authorised_values(id) ON DELETE CASCADE,
3124     FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
3125 ) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3126
3127
3128 --
3129 -- Table structure for table borrower_attribute_types_branches
3130 --
3131
3132 DROP TABLE IF EXISTS borrower_attribute_types_branches;
3133 CREATE TABLE borrower_attribute_types_branches( -- association table between borrower_attribute_types and branches
3134     bat_code VARCHAR(10),
3135     b_branchcode VARCHAR(10),
3136     FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE,
3137     FOREIGN KEY (b_branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
3138 ) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3139
3140 --
3141 -- Table structure for table `borrower_modifications`
3142 --
3143
3144 CREATE TABLE IF NOT EXISTS `borrower_modifications` (
3145   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3146   `verification_token` varchar(255) NOT NULL DEFAULT '',
3147   `borrowernumber` int(11) NOT NULL DEFAULT '0',
3148   `cardnumber` varchar(16) DEFAULT NULL,
3149   `surname` mediumtext,
3150   `firstname` text,
3151   `title` mediumtext,
3152   `othernames` mediumtext,
3153   `initials` text,
3154   `streetnumber` varchar(10) DEFAULT NULL,
3155   `streettype` varchar(50) DEFAULT NULL,
3156   `address` mediumtext,
3157   `address2` text,
3158   `city` mediumtext,
3159   `state` text,
3160   `zipcode` varchar(25) DEFAULT NULL,
3161   `country` text,
3162   `email` mediumtext,
3163   `phone` text,
3164   `mobile` varchar(50) DEFAULT NULL,
3165   `fax` mediumtext,
3166   `emailpro` text,
3167   `phonepro` text,
3168   `B_streetnumber` varchar(10) DEFAULT NULL,
3169   `B_streettype` varchar(50) DEFAULT NULL,
3170   `B_address` varchar(100) DEFAULT NULL,
3171   `B_address2` text,
3172   `B_city` mediumtext,
3173   `B_state` text,
3174   `B_zipcode` varchar(25) DEFAULT NULL,
3175   `B_country` text,
3176   `B_email` text,
3177   `B_phone` mediumtext,
3178   `dateofbirth` date DEFAULT NULL,
3179   `branchcode` varchar(10) DEFAULT NULL,
3180   `categorycode` varchar(10) DEFAULT NULL,
3181   `dateenrolled` date DEFAULT NULL,
3182   `dateexpiry` date DEFAULT NULL,
3183   `gonenoaddress` tinyint(1) DEFAULT NULL,
3184   `lost` tinyint(1) DEFAULT NULL,
3185   `debarred` date DEFAULT NULL,
3186   `debarredcomment` varchar(255) DEFAULT NULL,
3187   `contactname` mediumtext,
3188   `contactfirstname` text,
3189   `contacttitle` text,
3190   `guarantorid` int(11) DEFAULT NULL,
3191   `borrowernotes` mediumtext,
3192   `relationship` varchar(100) DEFAULT NULL,
3193   `sex` varchar(1) DEFAULT NULL,
3194   `password` varchar(30) DEFAULT NULL,
3195   `flags` int(11) DEFAULT NULL,
3196   `userid` varchar(75) DEFAULT NULL,
3197   `opacnote` mediumtext,
3198   `contactnote` varchar(255) DEFAULT NULL,
3199   `sort1` varchar(80) DEFAULT NULL,
3200   `sort2` varchar(80) DEFAULT NULL,
3201   `altcontactfirstname` varchar(255) DEFAULT NULL,
3202   `altcontactsurname` varchar(255) DEFAULT NULL,
3203   `altcontactaddress1` varchar(255) DEFAULT NULL,
3204   `altcontactaddress2` varchar(255) DEFAULT NULL,
3205   `altcontactaddress3` varchar(255) DEFAULT NULL,
3206   `altcontactstate` text,
3207   `altcontactzipcode` varchar(50) DEFAULT NULL,
3208   `altcontactcountry` text,
3209   `altcontactphone` varchar(50) DEFAULT NULL,
3210   `smsalertnumber` varchar(50) DEFAULT NULL,
3211   `privacy` int(11) DEFAULT NULL,
3212   PRIMARY KEY (`verification_token`,`borrowernumber`),
3213   KEY `verification_token` (`verification_token`),
3214   KEY `borrowernumber` (`borrowernumber`)
3215 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3216
3217 --
3218 -- Table structure for table uploaded_files
3219 --
3220
3221 DROP TABLE IF EXISTS uploaded_files;
3222 CREATE TABLE uploaded_files (
3223     id int(11) NOT NULL AUTO_INCREMENT,
3224     hashvalue CHAR(40) NOT NULL,
3225     filename TEXT NOT NULL,
3226     dir TEXT NOT NULL,
3227     filesize int(11),
3228     dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3229     uploadcategorycode tinytext,
3230     owner int(11),
3231     public tinyint,
3232     permanent tinyint,
3233     PRIMARY KEY (id)
3234 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3235
3236 --
3237 -- Table structure for table linktracker
3238 -- This stores clicks to external links
3239 --
3240
3241 DROP TABLE IF EXISTS linktracker;
3242 CREATE TABLE linktracker (
3243    id int(11) NOT NULL AUTO_INCREMENT, -- primary key identifier
3244    biblionumber int(11) DEFAULT NULL, -- biblionumber of the record the link is from
3245    itemnumber int(11) DEFAULT NULL, -- itemnumber if applicable that the link was from
3246    borrowernumber int(11) DEFAULT NULL, -- borrowernumber who clicked the link
3247    url text, -- the link itself
3248    timeclicked datetime DEFAULT NULL, -- the date and time the link was clicked
3249    PRIMARY KEY (id),
3250    KEY bibidx (biblionumber),
3251    KEY itemidx (itemnumber),
3252    KEY borridx (borrowernumber),
3253    KEY dateidx (timeclicked)
3254 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3255
3256 --
3257 -- Table structure for table 'plugin_data'
3258 --
3259
3260 CREATE TABLE IF NOT EXISTS plugin_data (
3261   plugin_class varchar(255) NOT NULL,
3262   plugin_key varchar(255) NOT NULL,
3263   plugin_value text,
3264   PRIMARY KEY (plugin_class,plugin_key)
3265 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3266
3267 --
3268 -- Table structure for table `patron_lists`
3269 --
3270
3271 DROP TABLE IF EXISTS patron_lists;
3272 CREATE TABLE patron_lists (
3273   patron_list_id int(11) NOT NULL AUTO_INCREMENT, -- unique identifier
3274   name varchar(255) CHARACTER SET utf8 NOT NULL,  -- the list's name
3275   owner int(11) NOT NULL,                         -- borrowernumber of the list creator
3276   PRIMARY KEY (patron_list_id),
3277   KEY owner (owner)
3278 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3279
3280 --
3281 -- Constraints for table `patron_lists`
3282 --
3283 ALTER TABLE `patron_lists`
3284   ADD CONSTRAINT patron_lists_ibfk_1 FOREIGN KEY (`owner`) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3285
3286 --
3287 -- Table structure for table 'patron_list_patrons'
3288 --
3289
3290 DROP TABLE IF EXISTS patron_list_patrons;
3291 CREATE TABLE patron_list_patrons (
3292   patron_list_patron_id int(11) NOT NULL AUTO_INCREMENT, -- unique identifier
3293   patron_list_id int(11) NOT NULL,                       -- the list this entry is part of
3294   borrowernumber int(11) NOT NULL,                       -- the borrower that is part of this list
3295   PRIMARY KEY (patron_list_patron_id),
3296   KEY patron_list_id (patron_list_id),
3297   KEY borrowernumber (borrowernumber)
3298 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3299
3300 --
3301 -- Constraints for table `patron_list_patrons`
3302 --
3303 ALTER TABLE `patron_list_patrons`
3304   ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
3305   ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
3306
3307 --
3308 -- Table structure for table 'marc_modification_templates'
3309 --
3310
3311 CREATE TABLE IF NOT EXISTS marc_modification_templates (
3312     template_id int(11) NOT NULL AUTO_INCREMENT,
3313     name text NOT NULL,
3314     PRIMARY KEY (template_id)
3315 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3316
3317 --
3318 -- Table structure for table 'marc_modification_template_actions'
3319 --
3320
3321 CREATE TABLE IF NOT EXISTS marc_modification_template_actions (
3322   mmta_id int(11) NOT NULL AUTO_INCREMENT,
3323   template_id int(11) NOT NULL,
3324   ordering int(3) NOT NULL,
3325   action ENUM('delete_field','update_field','move_field','copy_field','copy_and_replace_field') NOT NULL,
3326   field_number smallint(6) NOT NULL DEFAULT '0',
3327   from_field varchar(3) NOT NULL,
3328   from_subfield varchar(1) DEFAULT NULL,
3329   field_value varchar(100) DEFAULT NULL,
3330   to_field varchar(3) DEFAULT NULL,
3331   to_subfield varchar(1) DEFAULT NULL,
3332   to_regex_search text,
3333   to_regex_replace text,
3334   to_regex_modifiers varchar(8) DEFAULT '',
3335   conditional enum('if','unless') DEFAULT NULL,
3336   conditional_field varchar(3) DEFAULT NULL,
3337   conditional_subfield varchar(1) DEFAULT NULL,
3338   conditional_comparison enum('exists','not_exists','equals','not_equals') DEFAULT NULL,
3339   conditional_value text,
3340   conditional_regex tinyint(1) NOT NULL DEFAULT '0',
3341   description text,
3342   PRIMARY KEY (mmta_id),
3343   CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
3344 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3345
3346 --
3347 -- Table structure for table `misc_files`
3348 --
3349
3350 CREATE TABLE IF NOT EXISTS `misc_files` ( -- miscellaneous files attached to records from various tables
3351   `file_id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the file record
3352   `table_tag` varchar(255) NOT NULL, -- usually table name, or arbitrary unique tag
3353   `record_id` int(11) NOT NULL, -- record id from the table this file is associated to
3354   `file_name` varchar(255) NOT NULL, -- file name
3355   `file_type` varchar(255) NOT NULL, -- MIME type of the file
3356   `file_description` varchar(255) DEFAULT NULL, -- description given to the file
3357   `file_content` longblob NOT NULL, -- file content
3358   `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date and time the file was added
3359   PRIMARY KEY (`file_id`),
3360   KEY `table_tag` (`table_tag`),
3361   KEY `record_id` (`record_id`)
3362 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3363
3364 --
3365 -- Table structure for table `columns_settings`
3366 --
3367
3368 CREATE TABLE IF NOT EXISTS columns_settings (
3369     module varchar(255) NOT NULL,
3370     page varchar(255) NOT NULL,
3371     tablename varchar(255) NOT NULL,
3372     columnname varchar(255) NOT NULL,
3373     cannot_be_toggled int(1) NOT NULL DEFAULT 0,
3374     is_hidden int(1) NOT NULL DEFAULT 0,
3375     PRIMARY KEY(module, page, tablename, columnname)
3376 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3377
3378 --
3379 -- Table structure for table 'items_search_fields'
3380 --
3381
3382 DROP TABLE IF EXISTS items_search_fields;
3383 CREATE TABLE items_search_fields (
3384   name VARCHAR(255) NOT NULL,
3385   label VARCHAR(255) NOT NULL,
3386   tagfield CHAR(3) NOT NULL,
3387   tagsubfield CHAR(1) NULL DEFAULT NULL,
3388   authorised_values_category VARCHAR(32) NULL DEFAULT NULL,
3389   PRIMARY KEY(name),
3390   CONSTRAINT items_search_fields_authorised_values_category
3391     FOREIGN KEY (authorised_values_category) REFERENCES authorised_values (category)
3392     ON DELETE SET NULL ON UPDATE CASCADE
3393 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3394
3395 --
3396 -- Table structure for table 'discharges'
3397 --
3398
3399 DROP TABLE IF EXISTS discharges;
3400 CREATE TABLE discharges (
3401   discharge_id int(11) NOT NULL AUTO_INCREMENT,
3402   borrower int(11) DEFAULT NULL,
3403   needed timestamp NULL DEFAULT NULL,
3404   validated timestamp NULL DEFAULT NULL,
3405   PRIMARY KEY (discharge_id),
3406   KEY borrower_discharges_ibfk1 (borrower),
3407   CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
3408 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3409
3410 --
3411 -- Table structure for table additional_fields
3412 -- This table add the ability to add new fields for a record
3413 --
3414
3415 DROP TABLE IF EXISTS additional_fields;
3416 CREATE TABLE `additional_fields` (
3417   `id` int(11) NOT NULL AUTO_INCREMENT, -- primary key identifier
3418   `tablename` varchar(255) NOT NULL DEFAULT '', -- tablename of the new field
3419   `name` varchar(255) NOT NULL DEFAULT '', -- name of the field
3420   `authorised_value_category` varchar(16) NOT NULL DEFAULT '', -- is an authorised value category
3421   `marcfield` varchar(16) NOT NULL DEFAULT '', -- contains the marc field to copied into the record
3422   `searchable` tinyint(1) NOT NULL DEFAULT '0', -- is the field searchable?
3423   PRIMARY KEY (`id`),
3424   UNIQUE KEY `fields_uniq` (`tablename`,`name`)
3425 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3426
3427 --
3428 -- Table structure for table additional_field_values
3429 -- This table store values for additional fields
3430 --
3431
3432 DROP TABLE IF EXISTS additional_field_values;
3433 CREATE TABLE `additional_field_values` (
3434   `id` int(11) NOT NULL AUTO_INCREMENT, -- primary key identifier
3435   `field_id` int(11) NOT NULL, -- foreign key references additional_fields(id)
3436   `record_id` int(11) NOT NULL, -- record_id
3437   `value` varchar(255) NOT NULL DEFAULT '', -- value for this field
3438   PRIMARY KEY (`id`),
3439   UNIQUE KEY `field_record` (`field_id`,`record_id`),
3440   CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3442
3443 --
3444 -- Table structure for table 'localization'
3445 --
3446
3447 DROP TABLE IF EXISTS localization;
3448 CREATE TABLE `localization` (
3449       localization_id int(11) NOT NULL AUTO_INCREMENT,
3450       entity varchar(16) COLLATE utf8_unicode_ci NOT NULL,
3451       code varchar(64) COLLATE utf8_unicode_ci NOT NULL,
3452       lang varchar(25) COLLATE utf8_unicode_ci NOT NULL, -- could be a foreign key
3453       translation text COLLATE utf8_unicode_ci,
3454       PRIMARY KEY (localization_id),
3455       UNIQUE KEY `entity_code_lang` (`entity`,`code`,`lang`)
3456 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3457
3458 --
3459 -- Table structure for table 'audio_alerts'
3460 --
3461
3462 DROP TABLE IF EXISTS audio_alerts;
3463 CREATE TABLE audio_alerts (
3464   id int(11) NOT NULL AUTO_INCREMENT,
3465   precedence smallint(5) unsigned NOT NULL,
3466   selector varchar(255) NOT NULL,
3467   sound varchar(255) NOT NULL,
3468   PRIMARY KEY (id),
3469   KEY precedence (precedence)
3470 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3471
3472 --
3473 -- Table structure for table `courses`
3474 --
3475
3476 -- The courses table stores the courses created for the
3477 -- course reserves feature.
3478
3479 DROP TABLE IF EXISTS courses;
3480 CREATE TABLE `courses` (
3481   `course_id` int(11) NOT NULL AUTO_INCREMENT, -- unique id for the course
3482   `department` varchar(80) DEFAULT NULL, -- the authorised value for the DEPARTMENT
3483   `course_number` varchar(255) DEFAULT NULL, -- the "course number" assigned to a course
3484   `section` varchar(255) DEFAULT NULL, -- the 'section' of a course
3485   `course_name` varchar(255) DEFAULT NULL, -- the name of the course
3486   `term` varchar(80) DEFAULT NULL, -- the authorised value for the TERM
3487   `staff_note` mediumtext, -- the text of the staff only note
3488   `public_note` mediumtext, -- the text of the public / opac note
3489   `students_count` varchar(20) DEFAULT NULL, -- how many students will be taking this course/section
3490   `enabled` enum('yes','no') NOT NULL DEFAULT 'yes', -- determines whether the course is active
3491   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3492    PRIMARY KEY (`course_id`)
3493 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3494
3495 --
3496 -- Table structure for table `course_instructors`
3497 --
3498
3499 -- The course instructors table links Koha borrowers to the
3500 -- courses they are teaching. Many instructors can teach many
3501 -- courses. course_instructors is just a many-to-many join table.
3502
3503 DROP TABLE IF EXISTS course_instructors;
3504 CREATE TABLE `course_instructors` (
3505   `course_id` int(11) NOT NULL, -- foreign key to link to courses.course_id
3506   `borrowernumber` int(11) NOT NULL, -- foreign key to link to borrowers.borrowernumber for instructor information
3507   PRIMARY KEY (`course_id`,`borrowernumber`),
3508   KEY `borrowernumber` (`borrowernumber`)
3509 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3510
3511 --
3512 -- Constraints for table `course_instructors`
3513 --
3514 ALTER TABLE `course_instructors`
3515   ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
3516   ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3517
3518 --
3519 -- Table structure for table `course_items`
3520 --
3521
3522 -- If an item is placed on course reserve for one or more courses
3523 -- it will have an entry in this table. No matter how many courses an item
3524 -- is part of, it will only have one row in this table.
3525
3526 DROP TABLE IF EXISTS course_items;
3527 CREATE TABLE `course_items` (
3528   `ci_id` int(11) NOT NULL AUTO_INCREMENT, -- course item id
3529   `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
3530   `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
3531   `ccode` varchar(10) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
3532   `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
3533   `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
3534   `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'
3535   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3536    PRIMARY KEY (`ci_id`),
3537    UNIQUE KEY `itemnumber` (`itemnumber`),
3538    KEY `holdingbranch` (`holdingbranch`)
3539 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3540
3541 --
3542 -- Constraints for table `course_items`
3543 --
3544 ALTER TABLE `course_items`
3545   ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3546   ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3547
3548 --
3549 -- Table structure for table `course_reserves`
3550 --
3551
3552 -- This table connects an item placed on course reserve to a course it is on reserve for.
3553 -- There will be a row in this table for each course an item is on reserve for.
3554
3555 DROP TABLE IF EXISTS course_reserves;
3556 CREATE TABLE `course_reserves` (
3557   `cr_id` int(11) NOT NULL AUTO_INCREMENT,
3558   `course_id` int(11) NOT NULL, -- foreign key to link to courses.course_id
3559   `ci_id` int(11) NOT NULL, -- foreign key to link to courses_items.ci_id
3560   `staff_note` mediumtext, -- staff only note
3561   `public_note` mediumtext, -- public, OPAC visible note
3562   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3563    PRIMARY KEY (`cr_id`),
3564    UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
3565    KEY `course_id` (`course_id`)
3566 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3567
3568 --
3569 -- Constraints for table `course_reserves`
3570 --
3571 ALTER TABLE `course_reserves`
3572   ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
3573   ADD CONSTRAINT `course_reserves_ibfk_2` FOREIGN KEY (`ci_id`) REFERENCES `course_items` (`ci_id`) ON DELETE CASCADE ON UPDATE CASCADE;
3574
3575 --
3576 -- Table structure for table `hold_fill_targets`
3577 --
3578
3579 DROP TABLE IF EXISTS `hold_fill_targets`;
3580 CREATE TABLE `hold_fill_targets` (
3581   `borrowernumber` int(11) NOT NULL,
3582   `biblionumber` int(11) NOT NULL,
3583   `itemnumber` int(11) NOT NULL,
3584   `source_branchcode`  varchar(10) default NULL,
3585   `item_level_request` tinyint(4) NOT NULL default 0,
3586   PRIMARY KEY `itemnumber` (`itemnumber`),
3587   KEY `bib_branch` (`biblionumber`, `source_branchcode`),
3588   CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
3589     REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3590   CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
3591     REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3592   CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
3593     REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3594   CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
3595     REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3596 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3597
3598 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3599 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3600 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3601 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
3602 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
3603 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
3604 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
3605 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;