Bug 6140 - Set a timeout to z3950 servers that could have network problems occasionally
[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   `datemodified` date default NULL,
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;
36
37 --
38 -- Table structure for table `auth_subfield_structure`
39 --
40
41 DROP TABLE IF EXISTS `auth_subfield_structure`;
42 CREATE TABLE `auth_subfield_structure` (
43   `authtypecode` varchar(10) NOT NULL default '',
44   `tagfield` varchar(3) NOT NULL default '',
45   `tagsubfield` varchar(1) NOT NULL default '',
46   `liblibrarian` varchar(255) NOT NULL default '',
47   `libopac` varchar(255) NOT NULL default '',
48   `repeatable` tinyint(4) NOT NULL default 0,
49   `mandatory` tinyint(4) NOT NULL default 0,
50   `tab` tinyint(1) default NULL,
51   `authorised_value` varchar(10) default NULL,
52   `value_builder` varchar(80) default NULL,
53   `seealso` varchar(255) default NULL,
54   `isurl` tinyint(1) default NULL,
55   `hidden` tinyint(3) NOT NULL default 0,
56   `linkid` tinyint(1) NOT NULL default 0,
57   `kohafield` varchar(45) NULL default '',
58   `frameworkcode` varchar(10) NOT NULL default '',
59   PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
60   KEY `tab` (`authtypecode`,`tab`)
61 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
63 --
64 -- Table structure for table `auth_tag_structure`
65 --
66
67 DROP TABLE IF EXISTS `auth_tag_structure`;
68 CREATE TABLE `auth_tag_structure` (
69   `authtypecode` varchar(10) NOT NULL default '',
70   `tagfield` varchar(3) NOT NULL default '',
71   `liblibrarian` varchar(255) NOT NULL default '',
72   `libopac` varchar(255) NOT NULL default '',
73   `repeatable` tinyint(4) NOT NULL default 0,
74   `mandatory` tinyint(4) NOT NULL default 0,
75   `authorised_value` varchar(10) default NULL,
76   PRIMARY KEY  (`authtypecode`,`tagfield`),
77   CONSTRAINT `auth_tag_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
78 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
79
80 --
81 -- Table structure for table `auth_types`
82 --
83
84 DROP TABLE IF EXISTS `auth_types`;
85 CREATE TABLE `auth_types` (
86   `authtypecode` varchar(10) NOT NULL default '',
87   `authtypetext` varchar(255) NOT NULL default '',
88   `auth_tag_to_report` varchar(3) NOT NULL default '',
89   `summary` mediumtext NOT NULL,
90   PRIMARY KEY  (`authtypecode`)
91 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
92
93 --
94 -- Table structure for table `authorised_values`
95 --
96
97 DROP TABLE IF EXISTS `authorised_values`;
98 CREATE TABLE `authorised_values` ( -- stores values for authorized values categories and values
99   `id` int(11) NOT NULL auto_increment, -- unique key, used to identify the authorized value
100   `category` varchar(10) NOT NULL default '', -- key used to identify the authorized value category
101   `authorised_value` varchar(80) NOT NULL default '', -- code use to identify the authorized value
102   `lib` varchar(80) default NULL, -- authorized value description as printed in the staff client
103   `lib_opac` VARCHAR(80) default NULL, -- authorized value description as printed in the OPAC
104   `imageurl` varchar(200) default NULL, -- authorized value URL
105   PRIMARY KEY  (`id`),
106   KEY `name` (`category`),
107   KEY `lib` (`lib`),
108   KEY `auth_value_idx` (`authorised_value`)
109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
110
111 --
112 -- Table structure for table `biblio`
113 --
114
115 DROP TABLE IF EXISTS `biblio`;
116 CREATE TABLE `biblio` ( -- table that stores bibliographic information
117   `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
118   `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
119   `author` mediumtext, -- statement of responsibility from MARC record (100$a in MARC21)
120   `title` mediumtext, -- title (without the subtitle) from the MARC record (245$a in MARC21)
121   `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
122   `notes` mediumtext, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
123   `serial` tinyint(1) default NULL, -- foreign key, linking to the subscriptionid in the serial table
124   `seriestitle` mediumtext,
125   `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
126   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
127   `datecreated` DATE NOT NULL, -- the date this record was added to Koha
128   `abstract` mediumtext, -- summary from the MARC record (520$a in MARC21)
129   PRIMARY KEY  (`biblionumber`),
130   KEY `blbnoidx` (`biblionumber`)
131 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
132
133 --
134 -- Table structure for table `biblio_framework`
135 --
136
137 DROP TABLE IF EXISTS `biblio_framework`;
138 CREATE TABLE `biblio_framework` (
139   `frameworkcode` varchar(4) NOT NULL default '',
140   `frameworktext` varchar(255) NOT NULL default '',
141   PRIMARY KEY  (`frameworkcode`)
142 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
143
144 --
145 -- Table structure for table `biblioitems`
146 --
147
148 DROP TABLE IF EXISTS `biblioitems`;
149 CREATE TABLE `biblioitems` ( -- information related to bibliographic records in Koha
150   `biblioitemnumber` int(11) NOT NULL auto_increment, -- primary key, unique identifier assigned by Koha
151   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking this table to the biblio table
152   `volume` mediumtext,
153   `number` mediumtext,
154   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
155   `isbn` varchar(30) default NULL, -- ISBN (MARC21 020$a)
156   `issn` varchar(9) default NULL, -- ISSN (MARC21 022$a)
157   `publicationyear` text,
158   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
159   `volumedate` date default NULL,
160   `volumedesc` text, -- volume information (MARC21 362$a)
161   `collectiontitle` mediumtext default NULL,
162   `collectionissn` text default NULL,
163   `collectionvolume` mediumtext default NULL,
164   `editionstatement` text default NULL,
165   `editionresponsibility` text default NULL,
166   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
167   `illus` varchar(255) default NULL, -- illustrations (MARC21 300$b)
168   `pages` varchar(255) default NULL, -- number of pages (MARC21 300$c)
169   `notes` mediumtext,
170   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
171   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
172   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
173   `marc` longblob, -- full bibliographic MARC record
174   `url` varchar(255) default NULL, -- url (MARC21 856$u)
175   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
176   `cn_class` varchar(30) default NULL,
177   `cn_item` varchar(10) default NULL,
178   `cn_suffix` varchar(10) default NULL,
179   `cn_sort` varchar(30) default NULL,
180   `totalissues` int(10),
181   `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
182   PRIMARY KEY  (`biblioitemnumber`),
183   KEY `bibinoidx` (`biblioitemnumber`),
184   KEY `bibnoidx` (`biblionumber`),
185   KEY `isbn` (`isbn`),
186   KEY `issn` (`issn`),
187   KEY `publishercode` (`publishercode`),
188   CONSTRAINT `biblioitems_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
189 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
190
191 --
192 -- Table structure for table `borrowers`
193 --
194
195 DROP TABLE IF EXISTS `borrowers`;
196 CREATE TABLE `borrowers` ( -- this table includes information about your patrons/borrowers/members
197   `borrowernumber` int(11) NOT NULL auto_increment, -- primary key, Koha assigned ID number for patrons/borrowers
198   `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
199   `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
200   `firstname` text, -- patron/borrower's first name
201   `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
202   `othernames` mediumtext, -- any other names associated with the patron/borrower
203   `initials` text, -- initials for your patron/borrower
204   `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
205   `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
206   `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
207   `address2` text, -- the second address line for your patron/borrower's primary address
208   `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
209   `state` text default NULL, -- the state or province for your patron/borrower's primary address
210   `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
211   `country` text, -- the country for your patron/borrower's primary address
212   `email` mediumtext, -- the primary email address for your patron/borrower's primary address
213   `phone` text, -- the primary phone number for your patron/borrower's primary address
214   `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
215   `fax` mediumtext, -- the fax number for your patron/borrower's primary address
216   `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
217   `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
218   `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
219   `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
220   `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
221   `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
222   `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
223   `B_state` text default NULL, -- the state for your patron/borrower's alternate address
224   `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
225   `B_country` text, -- the country for your patron/borrower's alternate address
226   `B_email` text, -- the patron/borrower's alternate email address
227   `B_phone` mediumtext, -- the patron/borrower's alternate phone number
228   `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
229   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
230   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
231   `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
232   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
233   `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
234   `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
235   `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)
236   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
237   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
238   `contactfirstname` text, -- used for children to include first name of guarentor
239   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
240   `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
241   `borrowernotes` mediumtext, -- a note on the patron/borroewr's account that is only visible in the staff client
242   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
243   `ethnicity` varchar(50) default NULL, -- unused in Koha
244   `ethnotes` varchar(255) default NULL, -- unused in Koha
245   `sex` varchar(1) default NULL, -- patron/borrower's gender
246   `password` varchar(30) default NULL, -- patron/borrower's encrypted password
247   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
248   `userid` varchar(75) default NULL, -- patron/borrower's opac and/or staff client log in
249   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
250   `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
251   `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
252   `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
253   `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
254   `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
255   `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
256   `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
257   `altcontactaddress3` varchar(255) default NULL, -- the third address line for the alternate contact for the patron/borrower
258   `altcontactstate` text default NULL, -- the city and state for the alternate contact for the patron/borrower
259   `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
260   `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
261   `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
262   `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
263   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history
264   UNIQUE KEY `cardnumber` (`cardnumber`),
265   PRIMARY KEY `borrowernumber` (`borrowernumber`),
266   KEY `categorycode` (`categorycode`),
267   KEY `branchcode` (`branchcode`),
268   KEY `userid` (`userid`),
269   KEY `guarantorid` (`guarantorid`),
270   CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
271   CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
272 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
273
274 --
275 -- Table structure for table `borrower_attribute_types`
276 --
277
278 DROP TABLE IF EXISTS `borrower_attribute_types`;
279 CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron fields known as extended patron attributes
280   `code` varchar(10) NOT NULL, -- unique key used to identify each custom field
281   `description` varchar(255) NOT NULL, -- description for each custom field
282   `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)
283   `unique_id` tinyint(1) NOT NULL default 0, -- defines if this value needs to be unique (1 for yes, 0 for no)
284   `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)
285   `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)
286   `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)
287   `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
288   `display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
289   `category_code` VARCHAR(1) NOT NULL DEFAULT '',-- defines a category for an attribute_type
290   `class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type
291   PRIMARY KEY  (`code`),
292   KEY `auth_val_cat_idx` (`authorised_value_category`)
293 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
294
295 --
296 -- Table structure for table `borrower_attributes`
297 --
298
299 DROP TABLE IF EXISTS `borrower_attributes`;
300 CREATE TABLE `borrower_attributes` ( -- values of custom patron fields known as extended patron attributes linked to patrons/borrowers
301   `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines which patron/borrower has this attribute
302   `code` varchar(10) NOT NULL, -- foreign key from the borrower_attribute_types table, defines which custom field this value was entered for
303   `attribute` varchar(64) default NULL, -- custom patron field value
304   `password` varchar(64) default NULL, -- password associated with this field
305   KEY `borrowernumber` (`borrowernumber`),
306   KEY `code_attribute` (`code`, `attribute`),
307   CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
308     ON DELETE CASCADE ON UPDATE CASCADE,
309   CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
310     ON DELETE CASCADE ON UPDATE CASCADE
311 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
312
313 --
314 -- Table structure for table `branch_item_rules`
315 --
316
317 DROP TABLE IF EXISTS `branch_item_rules`;
318 CREATE TABLE `branch_item_rules` (
319   `branchcode` varchar(10) NOT NULL,
320   `itemtype` varchar(10) NOT NULL,
321   `holdallowed` tinyint(1) default NULL,
322   `returnbranch` varchar(15) default NULL,
323   PRIMARY KEY  (`itemtype`,`branchcode`),
324   KEY `branch_item_rules_ibfk_2` (`branchcode`),
325   CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
326     ON DELETE CASCADE ON UPDATE CASCADE,
327   CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
328     ON DELETE CASCADE ON UPDATE CASCADE
329 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
330
331 --
332 -- Table structure for table `branchcategories`
333 --
334
335 DROP TABLE IF EXISTS `branchcategories`;
336 CREATE TABLE `branchcategories` ( -- information related to library/branch groups
337   `categorycode` varchar(10) NOT NULL default '', -- unique identifier for the library/branch group
338   `categoryname` varchar(32), -- name of the library/branch group
339   `codedescription` mediumtext, -- longer description of the library/branch group
340   `categorytype` varchar(16), -- says whether this is a search group or a properties group
341   PRIMARY KEY  (`categorycode`)
342 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
343
344 --
345 -- Table structure for table `branches`
346 --
347
348 DROP TABLE IF EXISTS `branches`;
349 CREATE TABLE `branches` ( -- information about your libraries or branches are stored here
350   `branchcode` varchar(10) NOT NULL default '', -- a unique key assigned to each branch
351   `branchname` mediumtext NOT NULL, -- the name of your library or branch
352   `branchaddress1` mediumtext, -- the first address line of for your library or branch
353   `branchaddress2` mediumtext, -- the second address line of for your library or branch
354   `branchaddress3` mediumtext, -- the third address line of for your library or branch
355   `branchzip` varchar(25) default NULL, -- the zip or postal code for your library or branch
356   `branchcity` mediumtext, -- the city or province for your library or branch
357   `branchstate` mediumtext, -- the state for your library or branch
358   `branchcountry` text, -- the county for your library or branch
359   `branchphone` mediumtext, -- the primary phone for your library or branch
360   `branchfax` mediumtext, -- the fax number for your library or branch
361   `branchemail` mediumtext, -- the primary email address for your library or branch
362   `branchurl` mediumtext, -- the URL for your library or branch's website
363   `issuing` tinyint(4) default NULL, -- unused in Koha
364   `branchip` varchar(15) default NULL, -- the IP address for your library or branch
365   `branchprinter` varchar(100) default NULL, -- unused in Koha
366   `branchnotes` mediumtext, -- notes related to your library or branch
367   opac_info text, -- HTML that displays in OPAC
368   UNIQUE KEY `branchcode` (`branchcode`)
369 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
370
371 --
372 -- Table structure for table `branchrelations`
373 --
374
375 DROP TABLE IF EXISTS `branchrelations`;
376 CREATE TABLE `branchrelations` ( -- this table links libraries/branches to groups
377   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table to identify the branch
378   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the branchcategories table to identify the group
379   PRIMARY KEY  (`branchcode`,`categorycode`),
380   KEY `branchcode` (`branchcode`),
381   KEY `categorycode` (`categorycode`),
382   CONSTRAINT `branchrelations_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
383   CONSTRAINT `branchrelations_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `branchcategories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
384 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
385
386 --
387 -- Table structure for table `branchtransfers`
388 --
389
390 DROP TABLE IF EXISTS `branchtransfers`;
391 CREATE TABLE `branchtransfers` (
392   `itemnumber` int(11) NOT NULL default 0,
393   `datesent` datetime default NULL,
394   `frombranch` varchar(10) NOT NULL default '',
395   `datearrived` datetime default NULL,
396   `tobranch` varchar(10) NOT NULL default '',
397   `comments` mediumtext,
398   KEY `frombranch` (`frombranch`),
399   KEY `tobranch` (`tobranch`),
400   KEY `itemnumber` (`itemnumber`),
401   CONSTRAINT `branchtransfers_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
402   CONSTRAINT `branchtransfers_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
403   CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
404 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
405
406
407 --
408 -- Table structure for table `browser`
409 --
410 DROP TABLE IF EXISTS `browser`;
411 CREATE TABLE `browser` (
412   `level` int(11) NOT NULL,
413   `classification` varchar(20) NOT NULL,
414   `description` varchar(255) NOT NULL,
415   `number` bigint(20) NOT NULL,
416   `endnode` tinyint(4) NOT NULL
417 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
418
419 --
420 -- Table structure for table `categories`
421 --
422
423 DROP TABLE IF EXISTS `categories`;
424 CREATE TABLE `categories` ( -- this table shows information related to Koha patron categories
425   `categorycode` varchar(10) NOT NULL default '', -- unique primary key used to idenfity the patron category
426   `description` mediumtext, -- description of the patron category
427   `enrolmentperiod` smallint(6) default NULL, -- number of months the patron is enrolled for (will be NULL if enrolmentperioddate is set)
428   `enrolmentperioddate` DATE NULL DEFAULT NULL, -- date the patron is enrolled until (will be NULL if enrolmentperiod is set)
429   `upperagelimit` smallint(6) default NULL, -- age limit for the patron
430   `dateofbirthrequired` tinyint(1) default NULL,
431   `finetype` varchar(30) default NULL, -- unused in Koha
432   `bulk` tinyint(1) default NULL,
433   `enrolmentfee` decimal(28,6) default NULL, -- enrollment fee for the patron
434   `overduenoticerequired` tinyint(1) default NULL, -- are overdue notices sent to this patron category (1 for yes, 0 for no)
435   `issuelimit` smallint(6) default NULL, -- unused in Koha
436   `reservefee` decimal(28,6) default NULL, -- cost to place holds
437   `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
438   `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
439   PRIMARY KEY  (`categorycode`),
440   UNIQUE KEY `categorycode` (`categorycode`)
441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
442
443 --
444 -- Table: collections
445 --
446 DROP TABLE IF EXISTS collections;
447 CREATE TABLE collections (
448   colId integer(11) NOT NULL auto_increment,
449   colTitle varchar(100) NOT NULL DEFAULT '',
450   colDesc text NOT NULL,
451   colBranchcode varchar(4) DEFAULT NULL comment 'branchcode for branch where item should be held.',
452   PRIMARY KEY (colId)
453 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
454
455 --
456 -- Table: collections_tracking
457 --
458 DROP TABLE IF EXISTS collections_tracking;
459 CREATE TABLE collections_tracking (
460   ctId integer(11) NOT NULL auto_increment,
461   colId integer(11) NOT NULL DEFAULT 0 comment 'collections.colId',
462   itemnumber integer(11) NOT NULL DEFAULT 0 comment 'items.itemnumber',
463   PRIMARY KEY (ctId)
464 ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
465
466 --
467 -- Table structure for table `borrower_branch_circ_rules`
468 --
469
470 DROP TABLE IF EXISTS `branch_borrower_circ_rules`;
471 CREATE TABLE `branch_borrower_circ_rules` (
472   `branchcode` VARCHAR(10) NOT NULL,
473   `categorycode` VARCHAR(10) NOT NULL,
474   `maxissueqty` int(4) default NULL,
475   PRIMARY KEY (`categorycode`, `branchcode`),
476   CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
477     ON DELETE CASCADE ON UPDATE CASCADE,
478   CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
479     ON DELETE CASCADE ON UPDATE CASCADE
480 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
481
482 --
483 -- Table structure for table `default_borrower_circ_rules`
484 --
485
486 DROP TABLE IF EXISTS `default_borrower_circ_rules`;
487 CREATE TABLE `default_borrower_circ_rules` (
488   `categorycode` VARCHAR(10) NOT NULL,
489   `maxissueqty` int(4) default NULL,
490   PRIMARY KEY (`categorycode`),
491   CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
492     ON DELETE CASCADE ON UPDATE CASCADE
493 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
494
495 --
496 -- Table structure for table `default_branch_circ_rules`
497 --
498
499 DROP TABLE IF EXISTS `default_branch_circ_rules`;
500 CREATE TABLE `default_branch_circ_rules` (
501   `branchcode` VARCHAR(10) NOT NULL,
502   `maxissueqty` int(4) default NULL,
503   `holdallowed` tinyint(1) default NULL,
504   `returnbranch` varchar(15) default NULL,
505   PRIMARY KEY (`branchcode`),
506   CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
507     ON DELETE CASCADE ON UPDATE CASCADE
508 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
509
510 --
511 -- Table structure for table `default_branch_item_rules`
512 --
513 DROP TABLE IF EXISTS `default_branch_item_rules`;
514 CREATE TABLE `default_branch_item_rules` (
515   `itemtype` varchar(10) NOT NULL,
516   `holdallowed` tinyint(1) default NULL,
517   `returnbranch` varchar(15) default NULL,
518   PRIMARY KEY  (`itemtype`),
519   CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`)
520     ON DELETE CASCADE ON UPDATE CASCADE
521 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
522
523 --
524 -- Table structure for table `default_circ_rules`
525 --
526
527 DROP TABLE IF EXISTS `default_circ_rules`;
528 CREATE TABLE `default_circ_rules` (
529     `singleton` enum('singleton') NOT NULL default 'singleton',
530     `maxissueqty` int(4) default NULL,
531     `holdallowed` int(1) default NULL,
532     `returnbranch` varchar(15) default NULL,
533     PRIMARY KEY (`singleton`)
534 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
535
536 --
537 -- Table structure for table `cities`
538 --
539
540 DROP TABLE IF EXISTS `cities`;
541 CREATE TABLE `cities` ( -- authorized values for cities/states/countries to choose when adding/editing a patron/borrower
542   `cityid` int(11) NOT NULL auto_increment, -- unique identifier added by Koha
543   `city_name` varchar(100) NOT NULL default '', -- name of the city
544   `city_state` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the state/province
545   `city_country` VARCHAR( 100 ) NULL DEFAULT NULL, -- name of the country
546   `city_zipcode` varchar(20) default NULL, -- zip or postal code
547   PRIMARY KEY  (`cityid`)
548 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
549
550 --
551 -- Table structure for table `class_sort_rules`
552 --
553
554 DROP TABLE IF EXISTS `class_sort_rules`;
555 CREATE TABLE `class_sort_rules` (
556   `class_sort_rule` varchar(10) NOT NULL default '',
557   `description` mediumtext,
558   `sort_routine` varchar(30) NOT NULL default '',
559   PRIMARY KEY (`class_sort_rule`),
560   UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
561 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
562
563 --
564 -- Table structure for table `class_sources`
565 --
566
567 DROP TABLE IF EXISTS `class_sources`;
568 CREATE TABLE `class_sources` (
569   `cn_source` varchar(10) NOT NULL default '',
570   `description` mediumtext,
571   `used` tinyint(4) NOT NULL default 0,
572   `class_sort_rule` varchar(10) NOT NULL default '',
573   PRIMARY KEY (`cn_source`),
574   UNIQUE KEY `cn_source_idx` (`cn_source`),
575   KEY `used_idx` (`used`),
576   CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`)
577 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
578
579 --
580 -- Table structure for table `currency`
581 --
582
583 DROP TABLE IF EXISTS `currency`;
584 CREATE TABLE `currency` (
585   `currency` varchar(10) NOT NULL default '',
586   `symbol` varchar(5) default NULL,
587   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
588   `rate` float(15,5) default NULL,
589   `active` tinyint(1) default NULL,
590   PRIMARY KEY  (`currency`)
591 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
592
593 --
594 -- Table structure for table `deletedbiblio`
595 --
596
597 DROP TABLE IF EXISTS `deletedbiblio`;
598 CREATE TABLE `deletedbiblio` ( -- stores information about bibliographic records that have been deleted
599   `biblionumber` int(11) NOT NULL auto_increment, -- unique identifier assigned to each bibliographic record
600   `frameworkcode` varchar(4) NOT NULL default '', -- foriegn key from the biblio_framework table to identify which framework was used in cataloging this record
601   `author` mediumtext, -- statement of responsibility from MARC record (100$a in MARC21)
602   `title` mediumtext, -- title (without the subtitle) from the MARC record (245$a in MARC21)
603   `unititle` mediumtext, -- uniform title (without the subtitle) from the MARC record (240$a in MARC21)
604   `notes` mediumtext, -- values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)
605   `serial` tinyint(1) default NULL, -- foreign key, linking to the subscriptionid in the serial table
606   `seriestitle` mediumtext,
607   `copyrightdate` smallint(6) default NULL, -- publication or copyright date from the MARC record
608   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched
609   `datecreated` DATE NOT NULL, -- the date this record was added to Koha
610   `abstract` mediumtext, -- summary from the MARC record (520$a in MARC21)
611   PRIMARY KEY  (`biblionumber`),
612   KEY `blbnoidx` (`biblionumber`)
613 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
614
615 --
616 -- Table structure for table `deletedbiblioitems`
617 --
618
619 DROP TABLE IF EXISTS `deletedbiblioitems`;
620 CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records that have been deleted
621   `biblioitemnumber` int(11) NOT NULL default 0, -- primary key, unique identifier assigned by Koha
622   `biblionumber` int(11) NOT NULL default 0, -- foreign key linking this table to the biblio table
623   `volume` mediumtext,
624   `number` mediumtext,
625   `itemtype` varchar(10) default NULL, -- biblio level item type (MARC21 942$c)
626   `isbn` varchar(30) default NULL, -- ISBN (MARC21 020$a)
627   `issn` varchar(9) default NULL, -- ISSN (MARC21 022$a)
628   `publicationyear` text,
629   `publishercode` varchar(255) default NULL, -- publisher (MARC21 260$b)
630   `volumedate` date default NULL,
631   `volumedesc` text, -- volume information (MARC21 362$a)
632   `collectiontitle` mediumtext default NULL,
633   `collectionissn` text default NULL,
634   `collectionvolume` mediumtext default NULL,
635   `editionstatement` text default NULL,
636   `editionresponsibility` text default NULL,
637   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
638   `illus` varchar(255) default NULL, -- illustrations (MARC21 300$b)
639   `pages` varchar(255) default NULL, -- number of pages (MARC21 300$c)
640   `notes` mediumtext,
641   `size` varchar(255) default NULL, -- material size (MARC21 300$c)
642   `place` varchar(255) default NULL, -- publication place (MARC21 260$a)
643   `lccn` varchar(25) default NULL, -- library of congress control number (MARC21 010$a)
644   `marc` longblob, -- full bibliographic MARC record
645   `url` varchar(255) default NULL, -- url (MARC21 856$u)
646   `cn_source` varchar(10) default NULL, -- classification source (MARC21 942$2)
647   `cn_class` varchar(30) default NULL,
648   `cn_item` varchar(10) default NULL,
649   `cn_suffix` varchar(10) default NULL,
650   `cn_sort` varchar(30) default NULL,
651   `totalissues` int(10),
652   `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
653   PRIMARY KEY  (`biblioitemnumber`),
654   KEY `bibinoidx` (`biblioitemnumber`),
655   KEY `bibnoidx` (`biblionumber`),
656   KEY `isbn` (`isbn`),
657   KEY `publishercode` (`publishercode`)
658 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
659
660 --
661 -- Table structure for table `deletedborrowers`
662 --
663
664 DROP TABLE IF EXISTS `deletedborrowers`;
665 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrowers you have deleted
666   `borrowernumber` int(11) NOT NULL default 0, -- primary key, Koha assigned ID number for patrons/borrowers
667   `cardnumber` varchar(16) default NULL, -- unique key, library assigned ID number for patrons/borrowers
668   `surname` mediumtext NOT NULL, -- patron/borrower's last name (surname)
669   `firstname` text, -- patron/borrower's first name
670   `title` mediumtext, -- patron/borrower's title, for example: Mr. or Mrs.
671   `othernames` mediumtext, -- any other names associated with the patron/borrower
672   `initials` text, -- initials for your patron/borrower
673   `streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's primary address
674   `streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's primary address
675   `address` mediumtext NOT NULL, -- the first address line for your patron/borrower's primary address
676   `address2` text, -- the second address line for your patron/borrower's primary address
677   `city` mediumtext NOT NULL, -- the city or town for your patron/borrower's primary address
678   `state` text default NULL, -- the state or province for your patron/borrower's primary address
679   `zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's primary address
680   `country` text, -- the country for your patron/borrower's primary address
681   `email` mediumtext, -- the primary email address for your patron/borrower's primary address
682   `phone` text, -- the primary phone number for your patron/borrower's primary address
683   `mobile` varchar(50) default NULL, -- the other phone number for your patron/borrower's primary address
684   `fax` mediumtext, -- the fax number for your patron/borrower's primary address
685   `emailpro` text, -- the secondary email addres for your patron/borrower's primary address
686   `phonepro` text, -- the secondary phone number for your patron/borrower's primary address
687   `B_streetnumber` varchar(10) default NULL, -- the house number for your patron/borrower's alternate address
688   `B_streettype` varchar(50) default NULL, -- the street type (Rd., Blvd, etc) for your patron/borrower's alternate address
689   `B_address` varchar(100) default NULL, -- the first address line for your patron/borrower's alternate address
690   `B_address2` text default NULL, -- the second address line for your patron/borrower's alternate address
691   `B_city` mediumtext, -- the city or town for your patron/borrower's alternate address
692   `B_state` text default NULL, -- the state for your patron/borrower's alternate address
693   `B_zipcode` varchar(25) default NULL, -- the zip or postal code for your patron/borrower's alternate address
694   `B_country` text, -- the country for your patron/borrower's alternate address
695   `B_email` text, -- the patron/borrower's alternate email address
696   `B_phone` mediumtext, -- the patron/borrower's alternate phone number
697   `dateofbirth` date default NULL, -- the patron/borrower's date of birth (YYYY-MM-DD)
698   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, includes the code of the patron/borrower's home branch
699   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table, includes the code of the patron category
700   `dateenrolled` date default NULL, -- date the patron was added to Koha (YYYY-MM-DD)
701   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
702   `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
703   `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
704   `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)
705   `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
706   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
707   `contactfirstname` text, -- used for children to include first name of guarentor
708   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
709   `guarantorid` int(11) default NULL, -- borrowernumber used for children or professionals to link them to guarentors or organizations
710   `borrowernotes` mediumtext, -- a note on the patron/borroewr's account that is only visible in the staff client
711   `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarentor
712   `ethnicity` varchar(50) default NULL, -- unused in Koha
713   `ethnotes` varchar(255) default NULL, -- unused in Koha
714   `sex` varchar(1) default NULL, -- patron/borrower's gender
715   `password` varchar(30) default NULL, -- patron/borrower's encrypted password
716   `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions
717   `userid` varchar(30) default NULL, -- patron/borrower's opac and/or staff client log in
718   `opacnote` mediumtext, -- a note on the patron/borrower's account that is visible in the OPAC and staff client
719   `contactnote` varchar(255) default NULL, -- a note related to the patron/borrower's alternate address
720   `sort1` varchar(80) default NULL, -- a field that can be used for any information unique to the library
721   `sort2` varchar(80) default NULL, -- a field that can be used for any information unique to the library
722   `altcontactfirstname` varchar(255) default NULL, -- first name of alternate contact for the patron/borrower
723   `altcontactsurname` varchar(255) default NULL, -- surname or last name of the alternate contact for the patron/borrower
724   `altcontactaddress1` varchar(255) default NULL, -- the first address line for the alternate contact for the patron/borrower
725   `altcontactaddress2` varchar(255) default NULL, -- the second address line for the alternate contact for the patron/borrower
726   `altcontactaddress3` varchar(255) default NULL, -- the third address line for the alternate contact for the patron/borrower
727   `altcontactstate` text default NULL, -- the city and state for the alternate contact for the patron/borrower
728   `altcontactzipcode` varchar(50) default NULL, -- the zipcode for the alternate contact for the patron/borrower
729   `altcontactcountry` text default NULL, -- the country for the alternate contact for the patron/borrower
730   `altcontactphone` varchar(50) default NULL, -- the phone number for the alternate contact for the patron/borrower
731   `smsalertnumber` varchar(50) default NULL, -- the mobile phone number where the patron/borrower would like to receive notices (if SNS turned on)
732   `privacy` integer(11) DEFAULT '1' NOT NULL, -- patron/borrower's privacy settings related to their reading history  KEY `borrowernumber` (`borrowernumber`),
733   KEY borrowernumber (borrowernumber),
734   KEY `cardnumber` (`cardnumber`)
735 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
736
737 --
738 -- Table structure for table `deleteditems`
739 --
740
741 DROP TABLE IF EXISTS `deleteditems`;
742 CREATE TABLE `deleteditems` (
743   `itemnumber` int(11) NOT NULL default 0, -- primary key and unique identifier added by Koha
744   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
745   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
746   `barcode` varchar(20) default NULL, -- item barcode (MARC21 952$p)
747   `dateaccessioned` date default NULL, -- date the item was acquired or added to Koha (MARC21 952$d)
748   `booksellerid` mediumtext default NULL, -- where the item was purchased (MARC21 952$e)
749   `homebranch` varchar(10) default NULL, -- foreign key from the branches table for the library that owns this item (MARC21 952$a)
750   `price` decimal(8,2) default NULL, -- purchase price (MARC21 952$g)
751   `replacementprice` decimal(8,2) default NULL, -- cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
752   `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
753   `datelastborrowed` date default NULL, -- the date the item was last checked out
754   `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
755   `stack` tinyint(1) default NULL,
756   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
757   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
758   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
759   `wthdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
760   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
761   `issues` smallint(6) default NULL, -- number of times this item has been checked out
762   `renewals` smallint(6) default NULL, -- number of times this item has been renewed
763   `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved
764   `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5)
765   `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x)
766   `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
767   `paidfor` mediumtext,
768   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
769   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
770   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
771   `onloan` date default NULL, -- defines if this item is currently checked out (1 for yes, 0 for no)
772   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
773   `cn_sort` varchar(30) default NULL, -- normalized form of the call number (MARC21 952$o) used for sorting
774   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
775   `materials` varchar(10) default NULL, -- materials specified (MARC21 952$3)
776   `uri` varchar(255) default NULL, -- URL for the item (MARC21 952$u)
777   `itype` varchar(10) default NULL, -- foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
778   `more_subfields_xml` longtext default NULL, -- additional 952 subfields in XML format
779   `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h)
780   `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t)
781   `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i)
782   `marc` longblob, -- unused in Koha
783   PRIMARY KEY  (`itemnumber`),
784   KEY `delitembarcodeidx` (`barcode`),
785   KEY `delitemstocknumberidx` (`stocknumber`),
786   KEY `delitembinoidx` (`biblioitemnumber`),
787   KEY `delitembibnoidx` (`biblionumber`),
788   KEY `delhomebranch` (`homebranch`),
789   KEY `delholdingbranch` (`holdingbranch`)
790 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
791
792 --
793 -- Table structure for table `ethnicity`
794 --
795
796 DROP TABLE IF EXISTS `ethnicity`;
797 CREATE TABLE `ethnicity` (
798   `code` varchar(10) NOT NULL default '',
799   `name` varchar(255) default NULL,
800   PRIMARY KEY  (`code`)
801 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
802
803 --
804 -- Table structure for table `export_format`
805 --
806
807 DROP TABLE IF EXISTS `export_format`;
808 CREATE TABLE `export_format` (
809   `export_format_id` int(11) NOT NULL auto_increment,
810   `profile` varchar(255) NOT NULL,
811   `description` mediumtext NOT NULL,
812   `marcfields` mediumtext NOT NULL,
813   `csv_separator` varchar(2) NOT NULL,
814   `field_separator` varchar(2) NOT NULL,
815   `subfield_separator` varchar(2) NOT NULL,
816   `encoding` varchar(255) NOT NULL,
817   PRIMARY KEY  (`export_format_id`)
818 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
819
820
821 --
822 -- Table structure for table `hold_fill_targets`
823 --
824
825 DROP TABLE IF EXISTS `hold_fill_targets`;
826 CREATE TABLE hold_fill_targets (
827   `borrowernumber` int(11) NOT NULL,
828   `biblionumber` int(11) NOT NULL,
829   `itemnumber` int(11) NOT NULL,
830   `source_branchcode`  varchar(10) default NULL,
831   `item_level_request` tinyint(4) NOT NULL default 0,
832   PRIMARY KEY `itemnumber` (`itemnumber`),
833   KEY `bib_branch` (`biblionumber`, `source_branchcode`),
834   CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
835     REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
836   CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
837     REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
838   CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
839     REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
840   CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
841     REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
842 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
843
844 --
845 -- Table structure for table `import_batches`
846 --
847
848 DROP TABLE IF EXISTS `import_batches`;
849 CREATE TABLE `import_batches` (
850   `import_batch_id` int(11) NOT NULL auto_increment,
851   `matcher_id` int(11) default NULL,
852   `template_id` int(11) default NULL,
853   `branchcode` varchar(10) default NULL,
854   `num_biblios` int(11) NOT NULL default 0,
855   `num_items` int(11) NOT NULL default 0,
856   `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
857   `overlay_action` enum('replace', 'create_new', 'use_template', 'ignore') NOT NULL default 'create_new',
858   `nomatch_action` enum('create_new', 'ignore') NOT NULL default 'create_new',
859   `item_action` enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore') NOT NULL default 'always_add',
860   `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
861   `batch_type` enum('batch', 'z3950') NOT NULL default 'batch',
862   `file_name` varchar(100),
863   `comments` mediumtext,
864   PRIMARY KEY (`import_batch_id`),
865   KEY `branchcode` (`branchcode`)
866 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
867
868 --
869 -- Table structure for table `import_records`
870 --
871
872 DROP TABLE IF EXISTS `import_records`;
873 CREATE TABLE `import_records` (
874   `import_record_id` int(11) NOT NULL auto_increment,
875   `import_batch_id` int(11) NOT NULL,
876   `branchcode` varchar(10) default NULL,
877   `record_sequence` int(11) NOT NULL default 0,
878   `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
879   `import_date` DATE default NULL,
880   `marc` longblob NOT NULL,
881   `marcxml` longtext NOT NULL,
882   `marcxml_old` longtext NOT NULL,
883   `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
884   `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
885   `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted', 'ignored') NOT NULL default 'staged',
886   `import_error` mediumtext,
887   `encoding` varchar(40) NOT NULL default '',
888   `z3950random` varchar(40) default NULL,
889   PRIMARY KEY (`import_record_id`),
890   CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
891              REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
892   KEY `branchcode` (`branchcode`),
893   KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
894 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
895
896 --
897 -- Table structure for `import_record_matches`
898 --
899 DROP TABLE IF EXISTS `import_record_matches`;
900 CREATE TABLE `import_record_matches` (
901   `import_record_id` int(11) NOT NULL,
902   `candidate_match_id` int(11) NOT NULL,
903   `score` int(11) NOT NULL default 0,
904   CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
905              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
906   KEY `record_score` (`import_record_id`, `score`)
907 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
908
909 --
910 -- Table structure for table `import_biblios`
911 --
912
913 DROP TABLE IF EXISTS `import_biblios`;
914 CREATE TABLE `import_biblios` (
915   `import_record_id` int(11) NOT NULL,
916   `matched_biblionumber` int(11) default NULL,
917   `control_number` varchar(25) default NULL,
918   `original_source` varchar(25) default NULL,
919   `title` varchar(128) default NULL,
920   `author` varchar(80) default NULL,
921   `isbn` varchar(30) default NULL,
922   `issn` varchar(9) default NULL,
923   `has_items` tinyint(1) NOT NULL default 0,
924   CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
925              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
926   KEY `matched_biblionumber` (`matched_biblionumber`),
927   KEY `title` (`title`),
928   KEY `isbn` (`isbn`)
929 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
930
931 --
932 -- Table structure for table `import_items`
933 --
934
935 DROP TABLE IF EXISTS `import_items`;
936 CREATE TABLE `import_items` (
937   `import_items_id` int(11) NOT NULL auto_increment,
938   `import_record_id` int(11) NOT NULL,
939   `itemnumber` int(11) default NULL,
940   `branchcode` varchar(10) default NULL,
941   `status` enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged',
942   `marcxml` longtext NOT NULL,
943   `import_error` mediumtext,
944   PRIMARY KEY (`import_items_id`),
945   CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
946              REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
947   KEY `itemnumber` (`itemnumber`),
948   KEY `branchcode` (`branchcode`)
949 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
950
951 --
952 -- Table structure for table `issues`
953 --
954
955 DROP TABLE IF EXISTS `issues`;
956 CREATE TABLE `issues` ( -- information related to check outs or issues
957   `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
958   `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
959   `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
960   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
961   `issuingbranch` varchar(18) default NULL,
962   `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
963   `lastreneweddate` datetime default NULL, -- date the item was last renewed
964   `return` varchar(4) default NULL,
965   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
966   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
967   `issuedate` datetime default NULL, -- date the item was checked out or issued
968   KEY `issuesborridx` (`borrowernumber`),
969   KEY `bordate` (`borrowernumber`,`timestamp`),
970   CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
971   CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE
972 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
973
974 --
975 -- Table structure for table `issuingrules`
976 --
977
978 DROP TABLE IF EXISTS `issuingrules`;
979 CREATE TABLE `issuingrules` (
980   `categorycode` varchar(10) NOT NULL default '',
981   `itemtype` varchar(10) NOT NULL default '',
982   `restrictedtype` tinyint(1) default NULL,
983   `rentaldiscount` decimal(28,6) default NULL,
984   `reservecharge` decimal(28,6) default NULL,
985   `fine` decimal(28,6) default NULL,
986   `finedays` int(11) default NULL,
987   `firstremind` int(11) default NULL,
988   `chargeperiod` int(11) default NULL,
989   `accountsent` int(11) default NULL,
990   `chargename` varchar(100) default NULL,
991   `maxissueqty` int(4) default NULL,
992   `issuelength` int(4) default NULL,
993   `hardduedate` date default NULL,
994   `hardduedatecompare` tinyint NOT NULL default "0",
995   `renewalsallowed` smallint(6) NOT NULL default "0",
996   `reservesallowed` smallint(6) NOT NULL default "0",
997   `branchcode` varchar(10) NOT NULL default '',
998   PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
999   KEY `categorycode` (`categorycode`),
1000   KEY `itemtype` (`itemtype`)
1001 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1002
1003 --
1004 -- Table structure for table `items`
1005 --
1006
1007 DROP TABLE IF EXISTS `items`;
1008 CREATE TABLE `items` ( -- holdings/item information 
1009   `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha
1010   `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
1011   `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
1012   `barcode` varchar(20) default NULL, -- item barcode (MARC21 952$p)
1013   `dateaccessioned` date default NULL, -- date the item was acquired or added to Koha (MARC21 952$d)
1014   `booksellerid` mediumtext default NULL, -- where the item was purchased (MARC21 952$e)
1015   `homebranch` varchar(10) default NULL, -- foreign key from the branches table for the library that owns this item (MARC21 952$a)
1016   `price` decimal(8,2) default NULL, -- purchase price (MARC21 952$g)
1017   `replacementprice` decimal(8,2) default NULL, -- cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
1018   `replacementpricedate` date default NULL, -- the date the price is effective from (MARC21 952$w)
1019   `datelastborrowed` date default NULL, -- the date the item was last checked out/issued
1020   `datelastseen` date default NULL, -- the date the item was last see (usually the last time the barcode was scanned or inventory was done)
1021   `stack` tinyint(1) default NULL,
1022   `notforloan` tinyint(1) NOT NULL default 0, -- authorized value defining why this item is not for loan (MARC21 952$7)
1023   `damaged` tinyint(1) NOT NULL default 0, -- authorized value defining this item as damaged (MARC21 952$4)
1024   `itemlost` tinyint(1) NOT NULL default 0, -- authorized value defining this item as lost (MARC21 952$1)
1025   `wthdrawn` tinyint(1) NOT NULL default 0, -- authorized value defining this item as withdrawn (MARC21 952$0)
1026   `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o)
1027   `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued
1028   `renewals` smallint(6) default NULL, -- number of times this item has been renewed
1029   `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved
1030   `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5)
1031   `itemnotes` mediumtext, -- public notes on this item (MARC21 952$x)
1032   `holdingbranch` varchar(10) default NULL, -- foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
1033   `paidfor` mediumtext,
1034   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this item was last altered
1035   `location` varchar(80) default NULL, -- authorized value for the shelving location for this item (MARC21 952$c)
1036   `permanent_location` varchar(80) default NULL, -- linked to the CART and PROC temporary locations feature, stores the permanent shelving location
1037   `onloan` date default NULL, -- defines if this item is currently checked out (1 for yes, 0 for no)
1038   `cn_source` varchar(10) default NULL, -- classification source used on this item (MARC21 952$2)
1039   `cn_sort` varchar(30) default NULL,  -- normalized form of the call number (MARC21 952$o) used for sorting
1040   `ccode` varchar(10) default NULL, -- authorized value for the collection code associated with this item (MARC21 952$8)
1041   `materials` text default NULL, -- materials specified (MARC21 952$3)
1042   `uri` varchar(255) default NULL, -- URL for the item (MARC21 952$u)
1043   `itype` varchar(10) default NULL, -- foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
1044   `more_subfields_xml` longtext default NULL, -- additional 952 subfields in XML format
1045   `enumchron` text default NULL, -- serial enumeration/chronology for the item (MARC21 952$h)
1046   `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t)
1047   `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i)
1048   PRIMARY KEY  (`itemnumber`),
1049   UNIQUE KEY `itembarcodeidx` (`barcode`),
1050   KEY `itemstocknumberidx` (`stocknumber`),
1051   KEY `itembinoidx` (`biblioitemnumber`),
1052   KEY `itembibnoidx` (`biblionumber`),
1053   KEY `homebranch` (`homebranch`),
1054   KEY `holdingbranch` (`holdingbranch`),
1055   KEY `itemcallnumber` (`itemcallnumber`),
1056   CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1057   CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
1058   CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE
1059 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1060
1061 --
1062 -- Table structure for table `itemtypes`
1063 --
1064
1065 DROP TABLE IF EXISTS `itemtypes`;
1066 CREATE TABLE `itemtypes` ( -- defines the item types
1067   `itemtype` varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
1068   `description` mediumtext, -- a plain text explanation of the item type
1069   `rentalcharge` double(16,4) default NULL, -- the amount charged when this item is checked out/issued
1070   `notforloan` smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
1071   `imageurl` varchar(200) default NULL, -- URL for the item type icon
1072   `summary` text, -- information from the summary field, may include HTML
1073   PRIMARY KEY  (`itemtype`),
1074   UNIQUE KEY `itemtype` (`itemtype`)
1075 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1076
1077 --
1078 -- Table structure for table `creator_batches`
1079 --
1080
1081 DROP TABLE IF EXISTS `creator_batches`;
1082 SET @saved_cs_client     = @@character_set_client;
1083 SET character_set_client = utf8;
1084 CREATE TABLE `creator_batches` (
1085   `label_id` int(11) NOT NULL AUTO_INCREMENT,
1086   `batch_id` int(10) NOT NULL DEFAULT '1',
1087   `item_number` int(11) DEFAULT NULL,
1088   `borrower_number` int(11) DEFAULT NULL,
1089   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
1090   `branch_code` varchar(10) NOT NULL DEFAULT 'NB',
1091   `creator` char(15) NOT NULL DEFAULT 'Labels',
1092   PRIMARY KEY (`label_id`),
1093   KEY `branch_fk_constraint` (`branch_code`),
1094   KEY `item_fk_constraint` (`item_number`),
1095   KEY `borrower_fk_constraint` (`borrower_number`),
1096   CONSTRAINT `creator_batches_ibfk_1` FOREIGN KEY (`borrower_number`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1097   CONSTRAINT `creator_batches_ibfk_2` FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
1098   CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE
1099 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1100
1101 --
1102 -- Table structure for table `creator_images`
1103 --
1104
1105 DROP TABLE IF EXISTS `creator_images`;
1106 SET @saved_cs_client     = @@character_set_client;
1107 SET character_set_client = utf8;
1108 CREATE TABLE `creator_images` (
1109   `image_id` int(4) NOT NULL AUTO_INCREMENT,
1110   `imagefile` mediumblob,
1111   `image_name` char(20) NOT NULL DEFAULT 'DEFAULT',
1112   PRIMARY KEY (`image_id`),
1113   UNIQUE KEY `image_name_index` (`image_name`)
1114 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1115
1116 --
1117 -- Table structure for table `creator_layouts`
1118 --
1119
1120 DROP TABLE IF EXISTS `creator_layouts`;
1121 SET @saved_cs_client     = @@character_set_client;
1122 SET character_set_client = utf8;
1123 CREATE TABLE `creator_layouts` (
1124   `layout_id` int(4) NOT NULL AUTO_INCREMENT,
1125   `barcode_type` char(100) NOT NULL DEFAULT 'CODE39',
1126   `start_label` int(2) NOT NULL DEFAULT '1',
1127   `printing_type` char(32) NOT NULL DEFAULT 'BAR',
1128   `layout_name` char(20) NOT NULL DEFAULT 'DEFAULT',
1129   `guidebox` int(1) DEFAULT '0',
1130   `font` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TR',
1131   `font_size` int(4) NOT NULL DEFAULT '10',
1132   `units` char(20) NOT NULL DEFAULT 'POINT',
1133   `callnum_split` int(1) DEFAULT '0',
1134   `text_justify` char(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'L',
1135   `format_string` varchar(210) NOT NULL DEFAULT 'barcode',
1136   `layout_xml` text NOT NULL,
1137   `creator` char(15) NOT NULL DEFAULT 'Labels',
1138   PRIMARY KEY (`layout_id`)
1139 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1140
1141 --
1142 -- Table structure for table `creator_templates`
1143 --
1144
1145 DROP TABLE IF EXISTS `creator_templates`;
1146 SET @saved_cs_client     = @@character_set_client;
1147 SET character_set_client = utf8;
1148 CREATE TABLE `creator_templates` (
1149   `template_id` int(4) NOT NULL AUTO_INCREMENT,
1150   `profile_id` int(4) DEFAULT NULL,
1151   `template_code` char(100) NOT NULL DEFAULT 'DEFAULT TEMPLATE',
1152   `template_desc` char(100) NOT NULL DEFAULT 'Default description',
1153   `page_width` float NOT NULL DEFAULT '0',
1154   `page_height` float NOT NULL DEFAULT '0',
1155   `label_width` float NOT NULL DEFAULT '0',
1156   `label_height` float NOT NULL DEFAULT '0',
1157   `top_text_margin` float NOT NULL DEFAULT '0',
1158   `left_text_margin` float NOT NULL DEFAULT '0',
1159   `top_margin` float NOT NULL DEFAULT '0',
1160   `left_margin` float NOT NULL DEFAULT '0',
1161   `cols` int(2) NOT NULL DEFAULT '0',
1162   `rows` int(2) NOT NULL DEFAULT '0',
1163   `col_gap` float NOT NULL DEFAULT '0',
1164   `row_gap` float NOT NULL DEFAULT '0',
1165   `units` char(20) NOT NULL DEFAULT 'POINT',
1166   `creator` char(15) NOT NULL DEFAULT 'Labels',
1167   PRIMARY KEY (`template_id`),
1168   KEY `template_profile_fk_constraint` (`profile_id`)
1169 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1170
1171 --
1172 -- Table structure for table `letter`
1173 --
1174
1175 DROP TABLE IF EXISTS `letter`;
1176 CREATE TABLE `letter` ( -- table for all notice templates in Koha
1177   `module` varchar(20) NOT NULL default '', -- Koha module that triggers this notice
1178   `code` varchar(20) NOT NULL default '', -- unique identifier for this notice
1179   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1180   `name` varchar(100) NOT NULL default '', -- plain text name for this notice
1181   `is_html` tinyint(1) default 0,
1182   `title` varchar(200) NOT NULL default '', -- subject line of the notice
1183   `content` text, -- body text for the notice
1184   PRIMARY KEY  (`module`,`code`, `branchcode`)
1185 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1186
1187 --
1188 -- Table structure for table `marc_subfield_structure`
1189 --
1190
1191 DROP TABLE IF EXISTS `marc_subfield_structure`;
1192 CREATE TABLE `marc_subfield_structure` (
1193   `tagfield` varchar(3) NOT NULL default '',
1194   `tagsubfield` varchar(1) NOT NULL default '' COLLATE utf8_bin,
1195   `liblibrarian` varchar(255) NOT NULL default '',
1196   `libopac` varchar(255) NOT NULL default '',
1197   `repeatable` tinyint(4) NOT NULL default 0,
1198   `mandatory` tinyint(4) NOT NULL default 0,
1199   `kohafield` varchar(40) default NULL,
1200   `tab` tinyint(1) default NULL,
1201   `authorised_value` varchar(20) default NULL,
1202   `authtypecode` varchar(20) default NULL,
1203   `value_builder` varchar(80) default NULL,
1204   `isurl` tinyint(1) default NULL,
1205   `hidden` tinyint(1) default NULL,
1206   `frameworkcode` varchar(4) NOT NULL default '',
1207   `seealso` varchar(1100) default NULL,
1208   `link` varchar(80) default NULL,
1209   `defaultvalue` text default NULL,
1210   PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
1211   KEY `kohafield_2` (`kohafield`),
1212   KEY `tab` (`frameworkcode`,`tab`),
1213   KEY `kohafield` (`frameworkcode`,`kohafield`)
1214 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1215
1216 --
1217 -- Table structure for table `marc_tag_structure`
1218 --
1219
1220 DROP TABLE IF EXISTS `marc_tag_structure`;
1221 CREATE TABLE `marc_tag_structure` (
1222   `tagfield` varchar(3) NOT NULL default '',
1223   `liblibrarian` varchar(255) NOT NULL default '',
1224   `libopac` varchar(255) NOT NULL default '',
1225   `repeatable` tinyint(4) NOT NULL default 0,
1226   `mandatory` tinyint(4) NOT NULL default 0,
1227   `authorised_value` varchar(10) default NULL,
1228   `frameworkcode` varchar(4) NOT NULL default '',
1229   PRIMARY KEY  (`frameworkcode`,`tagfield`)
1230 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1231
1232 --
1233 -- Table structure for table `marc_matchers`
1234 --
1235
1236 DROP TABLE IF EXISTS `marc_matchers`;
1237 CREATE TABLE `marc_matchers` (
1238   `matcher_id` int(11) NOT NULL auto_increment,
1239   `code` varchar(10) NOT NULL default '',
1240   `description` varchar(255) NOT NULL default '',
1241   `record_type` varchar(10) NOT NULL default 'biblio',
1242   `threshold` int(11) NOT NULL default 0,
1243   PRIMARY KEY (`matcher_id`),
1244   KEY `code` (`code`),
1245   KEY `record_type` (`record_type`)
1246 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1247
1248 --
1249 -- Table structure for table `matchpoints`
1250 --
1251 DROP TABLE IF EXISTS `matchpoints`;
1252 CREATE TABLE `matchpoints` (
1253   `matcher_id` int(11) NOT NULL,
1254   `matchpoint_id` int(11) NOT NULL auto_increment,
1255   `search_index` varchar(30) NOT NULL default '',
1256   `score` int(11) NOT NULL default 0,
1257   PRIMARY KEY (`matchpoint_id`),
1258   CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
1259   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
1260 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1261
1262
1263 --
1264 -- Table structure for table `matchpoint_components`
1265 --
1266 DROP TABLE IF EXISTS `matchpoint_components`;
1267 CREATE TABLE `matchpoint_components` (
1268   `matchpoint_id` int(11) NOT NULL,
1269   `matchpoint_component_id` int(11) NOT NULL auto_increment,
1270   sequence int(11) NOT NULL default 0,
1271   tag varchar(3) NOT NULL default '',
1272   subfields varchar(40) NOT NULL default '',
1273   offset int(4) NOT NULL default 0,
1274   length int(4) NOT NULL default 0,
1275   PRIMARY KEY (`matchpoint_component_id`),
1276   KEY `by_sequence` (`matchpoint_id`, `sequence`),
1277   CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
1278   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1279 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1280
1281 --
1282 -- Table structure for table `matcher_component_norms`
1283 --
1284 DROP TABLE IF EXISTS `matchpoint_component_norms`;
1285 CREATE TABLE `matchpoint_component_norms` (
1286   `matchpoint_component_id` int(11) NOT NULL,
1287   `sequence`  int(11) NOT NULL default 0,
1288   `norm_routine` varchar(50) NOT NULL default '',
1289   KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
1290   CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
1291   REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
1292 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1293
1294 --
1295 -- Table structure for table `matcher_matchpoints`
1296 --
1297 DROP TABLE IF EXISTS `matcher_matchpoints`;
1298 CREATE TABLE `matcher_matchpoints` (
1299   `matcher_id` int(11) NOT NULL,
1300   `matchpoint_id` int(11) NOT NULL,
1301   CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
1302   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1303   CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
1304   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1305 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1306
1307 --
1308 -- Table structure for table `matchchecks`
1309 --
1310 DROP TABLE IF EXISTS `matchchecks`;
1311 CREATE TABLE `matchchecks` (
1312   `matcher_id` int(11) NOT NULL,
1313   `matchcheck_id` int(11) NOT NULL auto_increment,
1314   `source_matchpoint_id` int(11) NOT NULL,
1315   `target_matchpoint_id` int(11) NOT NULL,
1316   PRIMARY KEY (`matchcheck_id`),
1317   CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
1318   REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1319   CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
1320   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1321   CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
1322   REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
1323 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1324
1325 --
1326 -- Table structure for table `need_merge_authorities`
1327 --
1328
1329 DROP TABLE IF EXISTS `need_merge_authorities`;
1330 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)
1331   `id` int NOT NULL auto_increment PRIMARY KEY, -- unique id
1332   `authid` bigint NOT NULL, -- reference to authority record
1333   `done` tinyint DEFAULT 0  -- indication whether merge has been executed (0=not done, 1= done, 2= in progress)
1334 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1335
1336 --
1337 -- Table structure for table `notifys`
1338 --
1339
1340 DROP TABLE IF EXISTS `notifys`;
1341 CREATE TABLE `notifys` (
1342   `notify_id` int(11) NOT NULL default 0,
1343   `borrowernumber` int(11) NOT NULL default 0,
1344   `itemnumber` int(11) NOT NULL default 0,
1345   `notify_date` date default NULL,
1346   `notify_send_date` date default NULL,
1347   `notify_level` int(1) NOT NULL default 0,
1348   `method` varchar(20) NOT NULL default ''
1349 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1350
1351 --
1352 -- Table structure for table `nozebra`
1353 --
1354
1355 DROP TABLE IF EXISTS `nozebra`;
1356 CREATE TABLE `nozebra` (
1357   `server` varchar(20)     NOT NULL,
1358   `indexname` varchar(40)  NOT NULL,
1359   `value` varchar(250)     NOT NULL,
1360   `biblionumbers` longtext NOT NULL,
1361   KEY `indexname` (`server`,`indexname`),
1362   KEY `value` (`server`,`value`))
1363   ENGINE=InnoDB DEFAULT CHARSET=utf8;
1364
1365 --
1366 -- Table structure for table `oai_sets`
1367 --
1368
1369 DROP TABLE IF EXISTS `oai_sets`;
1370 CREATE TABLE `oai_sets` (
1371   `id` int(11) NOT NULL auto_increment,
1372   `spec` varchar(80) NOT NULL UNIQUE,
1373   `name` varchar(80) NOT NULL,
1374   PRIMARY KEY (`id`)
1375 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1376
1377 --
1378 -- Table structure for table `oai_sets_descriptions`
1379 --
1380
1381 DROP TABLE IF EXISTS `oai_sets_descriptions`;
1382 CREATE TABLE `oai_sets_descriptions` (
1383   `set_id` int(11) NOT NULL,
1384   `description` varchar(255) NOT NULL,
1385   CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1386 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1387
1388 --
1389 -- Table structure for table `oai_sets_mappings`
1390 --
1391
1392 DROP TABLE IF EXISTS `oai_sets_mappings`;
1393 CREATE TABLE `oai_sets_mappings` (
1394   `set_id` int(11) NOT NULL,
1395   `marcfield` char(3) NOT NULL,
1396   `marcsubfield` char(1) NOT NULL,
1397   `marcvalue` varchar(80) NOT NULL,
1398   CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1399 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1400
1401 --
1402 -- Table structure for table `oai_sets_biblios`
1403 --
1404
1405 DROP TABLE IF EXISTS `oai_sets_biblios`;
1406 CREATE TABLE `oai_sets_biblios` (
1407   `biblionumber` int(11) NOT NULL,
1408   `set_id` int(11) NOT NULL,
1409   PRIMARY KEY (`biblionumber`, `set_id`),
1410   CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1411   CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1412 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1413
1414 --
1415 -- Table structure for table `old_issues`
1416 --
1417
1418 DROP TABLE IF EXISTS `old_issues`;
1419 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1420   `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1421   `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1422   `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
1423   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1424   `issuingbranch` varchar(18) default NULL,
1425   `returndate` datetime default NULL, -- date the item was returned
1426   `lastreneweddate` datetime default NULL, -- date the item was last renewed
1427   `return` varchar(4) default NULL,
1428   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
1429   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1430   `issuedate` datetime default NULL, -- date the item was checked out or issued
1431   KEY `old_issuesborridx` (`borrowernumber`),
1432   KEY `old_issuesitemidx` (`itemnumber`),
1433   KEY `old_bordate` (`borrowernumber`,`timestamp`),
1434   CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1435     ON DELETE SET NULL ON UPDATE SET NULL,
1436   CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1437     ON DELETE SET NULL ON UPDATE SET NULL
1438 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1439
1440 --
1441 -- Table structure for table `old_reserves`
1442 --
1443 DROP TABLE IF EXISTS `old_reserves`;
1444 CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have been completed (either filled or cancelled)
1445   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron this hold is for
1446   `reservedate` date default NULL, -- the date the hold was places
1447   `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bib record this hold is on
1448   `constrainttype` varchar(1) default NULL,
1449   `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
1450   `notificationdate` date default NULL, -- currently unused
1451   `reminderdate` date default NULL, -- currently unused
1452   `cancellationdate` date default NULL, -- the date this hold was cancelled
1453   `reservenotes` mediumtext, -- notes related to this hold
1454   `priority` smallint(6) default NULL, -- where in the queue the patron sits
1455   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
1456   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
1457   `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
1458   `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1459   `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)
1460   `lowestPriority` tinyint(1) NOT NULL,
1461   KEY `old_reserves_borrowernumber` (`borrowernumber`),
1462   KEY `old_reserves_biblionumber` (`biblionumber`),
1463   KEY `old_reserves_itemnumber` (`itemnumber`),
1464   KEY `old_reserves_branchcode` (`branchcode`),
1465   CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1466     ON DELETE SET NULL ON UPDATE SET NULL,
1467   CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1468     ON DELETE SET NULL ON UPDATE SET NULL,
1469   CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1470     ON DELETE SET NULL ON UPDATE SET NULL
1471 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1472
1473 --
1474 -- Table structure for table `opac_news`
1475 --
1476
1477 DROP TABLE IF EXISTS `opac_news`;
1478 CREATE TABLE `opac_news` ( -- data from the news tool
1479   `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
1480   `title` varchar(250) NOT NULL default '', -- title of the news article
1481   `new` text NOT NULL, -- the body of your news article
1482   `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)
1483   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time
1484   `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible
1485   `number` int(11) default NULL, -- the order in which this article appears in that specific location
1486   PRIMARY KEY  (`idnew`)
1487 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1488
1489 --
1490 -- Table structure for table `overduerules`
1491 --
1492
1493 DROP TABLE IF EXISTS `overduerules`;
1494 CREATE TABLE `overduerules` ( -- overdue notice status and triggers
1495   `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)
1496   `categorycode` varchar(10) NOT NULL default '', -- foreign key from the categories table to define which patron category this rule is for
1497   `delay1` int(4) default NULL, -- number of days after the item is overdue that the first notice is sent
1498   `letter1` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the first notice
1499   `debarred1` varchar(1) default 0, -- is the patron restricted when the first notice is sent (1 for yes, 0 for no)
1500   `delay2` int(4) default NULL, -- number of days after the item is overdue that the second notice is sent
1501   `debarred2` varchar(1) default 0, -- is the patron restricted when the second notice is sent (1 for yes, 0 for no)
1502   `letter2` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the second notice
1503   `delay3` int(4) default NULL, -- number of days after the item is overdue that the third notice is sent
1504   `letter3` varchar(20) default NULL, -- foreign key from the letter table to define which notice should be sent as the third notice
1505   `debarred3` int(1) default 0, -- is the patron restricted when the third notice is sent (1 for yes, 0 for no)
1506   PRIMARY KEY  (`branchcode`,`categorycode`)
1507 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1508
1509 --
1510 -- Table structure for table `patroncards`
1511 --
1512
1513 DROP TABLE IF EXISTS `patroncards`;
1514 CREATE TABLE `patroncards` (
1515   `cardid` int(11) NOT NULL auto_increment,
1516   `batch_id` varchar(10) NOT NULL default '1',
1517   `borrowernumber` int(11) NOT NULL,
1518   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1519    PRIMARY KEY  (`cardid`),
1520    KEY `patroncards_ibfk_1` (`borrowernumber`),
1521    CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1522 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1523
1524 --
1525 -- Table structure for table `patronimage`
1526 --
1527
1528 DROP TABLE IF EXISTS `patronimage`;
1529 CREATE TABLE `patronimage` (
1530   `cardnumber` varchar(16) NOT NULL,
1531   `mimetype` varchar(15) NOT NULL,
1532   `imagefile` mediumblob NOT NULL,
1533   PRIMARY KEY  (`cardnumber`),
1534   CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1535 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1536
1537 -- Table structure for table `pending_offline_operations`
1538 --
1539 -- this table is MyISAM, InnoDB tables are growing only and this table is filled/emptied/filled/emptied...
1540 -- so MyISAM is better in this case
1541
1542 CREATE TABLE `pending_offline_operations` (
1543   `operationid` int(11) NOT NULL AUTO_INCREMENT,
1544   `userid` varchar(30) NOT NULL,
1545   `branchcode` varchar(10) NOT NULL,
1546   `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
1547   `action` varchar(10) NOT NULL,
1548   `barcode` varchar(20) NOT NULL,
1549   `cardnumber` varchar(16) DEFAULT NULL,
1550   PRIMARY KEY (`operationid`)
1551 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
1552
1553
1554
1555 --
1556 -- Table structure for table `printers`
1557 --
1558
1559 DROP TABLE IF EXISTS `printers`;
1560 CREATE TABLE `printers` (
1561   `printername` varchar(40) NOT NULL default '',
1562   `printqueue` varchar(20) default NULL,
1563   `printtype` varchar(20) default NULL,
1564   PRIMARY KEY  (`printername`)
1565 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1566
1567 --
1568 -- Table structure for table `printers_profile`
1569 --
1570
1571 DROP TABLE IF EXISTS `printers_profile`;
1572 CREATE TABLE `printers_profile` (
1573   `profile_id` int(4) NOT NULL auto_increment,
1574   `printer_name` varchar(40) NOT NULL default 'Default Printer',
1575   `template_id` int(4) NOT NULL default '0',
1576   `paper_bin` varchar(20) NOT NULL default 'Bypass',
1577   `offset_horz` float NOT NULL default '0',
1578   `offset_vert` float NOT NULL default '0',
1579   `creep_horz` float NOT NULL default '0',
1580   `creep_vert` float NOT NULL default '0',
1581   `units` char(20) NOT NULL default 'POINT',
1582   `creator` char(15) NOT NULL DEFAULT 'Labels',
1583   PRIMARY KEY  (`profile_id`),
1584   UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`,`creator`)
1585 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1586
1587 --
1588 -- Table structure for table `repeatable_holidays`
1589 --
1590
1591 DROP TABLE IF EXISTS `repeatable_holidays`;
1592 CREATE TABLE `repeatable_holidays` ( -- information for the days the library is closed
1593   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1594   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
1595   `weekday` smallint(6) default NULL, -- day of the week (0=Sunday, 1=Monday, etc) this closing is repeated on
1596   `day` smallint(6) default NULL, -- day of the month this closing is on
1597   `month` smallint(6) default NULL, -- month this closing is in
1598   `title` varchar(50) NOT NULL default '', -- title of this closing
1599   `description` text NOT NULL, -- description for this closing
1600   PRIMARY KEY  (`id`)
1601 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1602
1603 --
1604 -- Table structure for table `reports_dictionary`
1605 --
1606
1607 DROP TABLE IF EXISTS `reports_dictionary`;
1608 CREATE TABLE reports_dictionary ( -- definitions (or snippets of SQL) stored for use in reports
1609    `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1610    `name` varchar(255) default NULL, -- name for this definition
1611    `description` text, -- description for this definition
1612    `date_created` datetime default NULL, -- date and time this definition was created
1613    `date_modified` datetime default NULL, -- date and time this definition was last modified
1614    `saved_sql` text, -- SQL snippet for us in reports
1615    `area` int(11) default NULL, -- Koha module this definition is for (1 = Circulation, 2 = Catalog, 3 = Patrons, 4 = Acquistions, 5 = Accounts)
1616    PRIMARY KEY  (`id`)
1617 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1618
1619 --
1620 -- Table structure for table `reserveconstraints`
1621 --
1622
1623 DROP TABLE IF EXISTS `reserveconstraints`;
1624 CREATE TABLE `reserveconstraints` (
1625   `borrowernumber` int(11) NOT NULL default 0,
1626   `reservedate` date default NULL,
1627   `biblionumber` int(11) NOT NULL default 0,
1628   `biblioitemnumber` int(11) default NULL,
1629   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
1630 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1631
1632 --
1633 -- Table structure for table `reserves`
1634 --
1635
1636 DROP TABLE IF EXISTS `reserves`;
1637 CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
1638   `borrowernumber` int(11) NOT NULL default 0, -- foreign key from the borrowers table defining which patron this hold is for
1639   `reservedate` date default NULL, -- the date the hold was places
1640   `biblionumber` int(11) NOT NULL default 0, -- foreign key from the biblio table defining which bib record this hold is on
1641   `constrainttype` varchar(1) default NULL,
1642   `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at
1643   `notificationdate` date default NULL, -- currently unused
1644   `reminderdate` date default NULL, -- currently unused
1645   `cancellationdate` date default NULL, -- the date this hold was cancelled
1646   `reservenotes` mediumtext, -- notes related to this hold
1647   `priority` smallint(6) default NULL, -- where in the queue the patron sits
1648   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
1649   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this hold was last updated
1650   `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
1651   `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
1652   `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)
1653   `lowestPriority` tinyint(1) NOT NULL,
1654   KEY priorityfoundidx (priority,found),
1655   KEY `borrowernumber` (`borrowernumber`),
1656   KEY `biblionumber` (`biblionumber`),
1657   KEY `itemnumber` (`itemnumber`),
1658   KEY `branchcode` (`branchcode`),
1659   CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1660   CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1661   CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1662   CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1663 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1664
1665 --
1666 -- Table structure for table `reviews`
1667 --
1668
1669 DROP TABLE IF EXISTS `reviews`;
1670 CREATE TABLE `reviews` ( -- patron opac comments
1671   `reviewid` int(11) NOT NULL auto_increment, -- unique identifier for this comment
1672   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron left this comment
1673   `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bibliographic record this comment is for
1674   `review` text, -- the body of the comment
1675   `approved` tinyint(4) default NULL, -- whether this comment has been approved by a librarian (1 for yes, 0 for no)
1676   `datereviewed` datetime default NULL, -- the date the comment was left
1677   PRIMARY KEY  (`reviewid`),
1678   CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
1679   CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1680 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1681
1682 --
1683 -- Table structure for table `roadtype`
1684 --
1685
1686 DROP TABLE IF EXISTS `roadtype`;
1687 CREATE TABLE `roadtype` ( -- road types defined in administration and used in patron management
1688   `roadtypeid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha for each road type
1689   `road_type` varchar(100) NOT NULL default '', -- text for road type
1690   PRIMARY KEY  (`roadtypeid`)
1691 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1692
1693 --
1694 -- Table structure for table `saved_sql`
1695 --
1696
1697 DROP TABLE IF EXISTS `saved_sql`;
1698 CREATE TABLE saved_sql (
1699    `id` int(11) NOT NULL auto_increment,
1700    `borrowernumber` int(11) default NULL,
1701    `date_created` datetime default NULL,
1702    `last_modified` datetime default NULL,
1703    `savedsql` text,
1704    `last_run` datetime default NULL,
1705    `report_name` varchar(255) default NULL,
1706    `type` varchar(255) default NULL,
1707    `notes` text,
1708    PRIMARY KEY  (`id`),
1709    KEY boridx (`borrowernumber`)
1710 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1711
1712
1713 --
1714 -- Table structure for `saved_reports`
1715 --
1716
1717 DROP TABLE IF EXISTS `saved_reports`;
1718 CREATE TABLE saved_reports (
1719    `id` int(11) NOT NULL auto_increment,
1720    `report_id` int(11) default NULL,
1721    `report` longtext,
1722    `date_run` datetime default NULL,
1723    PRIMARY KEY  (`id`)
1724 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1725
1726
1727 --
1728 -- Table structure for table `search_history`
1729 --
1730
1731 DROP TABLE IF EXISTS `search_history`;
1732 CREATE TABLE IF NOT EXISTS `search_history` (
1733   `userid` int(11) NOT NULL,
1734   `sessionid` varchar(32) NOT NULL,
1735   `query_desc` varchar(255) NOT NULL,
1736   `query_cgi` varchar(255) NOT NULL,
1737   `total` int(11) NOT NULL,
1738   `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
1739   KEY `userid` (`userid`),
1740   KEY `sessionid` (`sessionid`)
1741 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
1742
1743
1744 --
1745 -- Table structure for table `serial`
1746 --
1747
1748 DROP TABLE IF EXISTS `serial`;
1749 CREATE TABLE `serial` (
1750   `serialid` int(11) NOT NULL auto_increment,
1751   `biblionumber` varchar(100) NOT NULL default '',
1752   `subscriptionid` varchar(100) NOT NULL default '',
1753   `serialseq` varchar(100) NOT NULL default '',
1754   `status` tinyint(4) NOT NULL default 0,
1755   `planneddate` date default NULL,
1756   `notes` text,
1757   `publisheddate` date default NULL,
1758   `itemnumber` text default NULL,
1759   `claimdate` date default NULL,
1760   `routingnotes` text,
1761   PRIMARY KEY  (`serialid`)
1762 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1763
1764 --
1765 -- Table structure for table `sessions`
1766 --
1767
1768 DROP TABLE IF EXISTS sessions;
1769 CREATE TABLE sessions (
1770   `id` varchar(32) NOT NULL,
1771   `a_session` text NOT NULL,
1772   UNIQUE KEY id (id)
1773 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1774
1775 --
1776 -- Table structure for table `special_holidays`
1777 --
1778
1779 DROP TABLE IF EXISTS `special_holidays`;
1780 CREATE TABLE `special_holidays` ( -- non repeatable holidays/library closings
1781   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1782   `branchcode` varchar(10) NOT NULL default '', -- foreign key from the branches table, defines which branch this closing is for
1783   `day` smallint(6) NOT NULL default 0, -- day of the month this closing is on
1784   `month` smallint(6) NOT NULL default 0, -- month this closing is in
1785   `year` smallint(6) NOT NULL default 0, -- year this closing is in
1786   `isexception` smallint(1) NOT NULL default 1, -- is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)
1787   `title` varchar(50) NOT NULL default '', -- title for this closing
1788   `description` text NOT NULL, -- description of this closing
1789   PRIMARY KEY  (`id`)
1790 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1791
1792 --
1793 -- Table structure for table `statistics`
1794 --
1795
1796 DROP TABLE IF EXISTS `statistics`;
1797 CREATE TABLE `statistics` ( -- information related to transactions (circulation and fines) in Koha
1798   `datetime` datetime default NULL, -- date and time of the transaction
1799   `branch` varchar(10) default NULL, -- foreign key, branch where the transaction occurred
1800   `proccode` varchar(4) default NULL, -- proceedure code 
1801   `value` double(16,4) default NULL, -- monetary value associated with the transaction
1802   `type` varchar(16) default NULL, -- transaction type (locause, issue, return, renew, writeoff, payment, Credit*)
1803   `other` mediumtext,
1804   `usercode` varchar(10) default NULL,
1805   `itemnumber` int(11) default NULL, -- foreign key from the items table, links transaction to a specific item
1806   `itemtype` varchar(10) default NULL, -- foreign key from the itemtypes table, links transaction to a specific item type
1807   `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table, links transaction to a specific borrower
1808   `associatedborrower` int(11) default NULL,
1809   KEY `timeidx` (`datetime`)
1810 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1811
1812 --
1813 -- Table structure for table `stopwords`
1814 --
1815
1816 DROP TABLE IF EXISTS `stopwords`;
1817   CREATE TABLE `stopwords` (
1818   `word` varchar(255) default NULL
1819 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1820
1821 --
1822 -- Table structure for table `subscription`
1823 --
1824
1825 DROP TABLE IF EXISTS `subscription`;
1826 CREATE TABLE `subscription` (
1827   `biblionumber` int(11) NOT NULL default 0,
1828   `subscriptionid` int(11) NOT NULL auto_increment,
1829   `librarian` varchar(100) default '',
1830   `startdate` date default NULL,
1831   `aqbooksellerid` int(11) default 0,
1832   `cost` int(11) default 0,
1833   `aqbudgetid` int(11) default 0,
1834   `weeklength` int(11) default 0,
1835   `monthlength` int(11) default 0,
1836   `numberlength` int(11) default 0,
1837   `periodicity` tinyint(4) default 0,
1838   `dow` varchar(100) default '',
1839   `numberingmethod` varchar(100) default '',
1840   `notes` mediumtext,
1841   `status` varchar(100) NOT NULL default '',
1842   `add1` int(11) default 0,
1843   `every1` int(11) default 0,
1844   `whenmorethan1` int(11) default 0,
1845   `setto1` int(11) default NULL,
1846   `lastvalue1` int(11) default NULL,
1847   `add2` int(11) default 0,
1848   `every2` int(11) default 0,
1849   `whenmorethan2` int(11) default 0,
1850   `setto2` int(11) default NULL,
1851   `lastvalue2` int(11) default NULL,
1852   `add3` int(11) default 0,
1853   `every3` int(11) default 0,
1854   `innerloop1` int(11) default 0,
1855   `innerloop2` int(11) default 0,
1856   `innerloop3` int(11) default 0,
1857   `whenmorethan3` int(11) default 0,
1858   `setto3` int(11) default NULL,
1859   `lastvalue3` int(11) default NULL,
1860   `issuesatonce` tinyint(3) NOT NULL default 1,
1861   `firstacquidate` date default NULL,
1862   `manualhistory` tinyint(1) NOT NULL default 0,
1863   `irregularity` text,
1864   `letter` varchar(20) default NULL,
1865   `numberpattern` tinyint(3) default 0,
1866   `distributedto` text,
1867   `internalnotes` longtext,
1868   `callnumber` text,
1869   `location` varchar(80) NULL default '',
1870   `branchcode` varchar(10) NOT NULL default '',
1871   `hemisphere` tinyint(3) default 0,
1872   `lastbranch` varchar(10),
1873   `serialsadditems` tinyint(1) NOT NULL default '0',
1874   `staffdisplaycount` VARCHAR(10) NULL,
1875   `opacdisplaycount` VARCHAR(10) NULL,
1876   `graceperiod` int(11) NOT NULL default '0',
1877   `enddate` date default NULL,
1878   PRIMARY KEY  (`subscriptionid`)
1879 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1880
1881 --
1882 -- Table structure for table `subscriptionhistory`
1883 --
1884
1885 DROP TABLE IF EXISTS `subscriptionhistory`;
1886 CREATE TABLE `subscriptionhistory` (
1887   `biblionumber` int(11) NOT NULL default 0,
1888   `subscriptionid` int(11) NOT NULL default 0,
1889   `histstartdate` date default NULL,
1890   `histenddate` date default NULL,
1891   `missinglist` longtext NOT NULL,
1892   `recievedlist` longtext NOT NULL,
1893   `opacnote` varchar(150) NOT NULL default '',
1894   `librariannote` varchar(150) NOT NULL default '',
1895   PRIMARY KEY  (`subscriptionid`),
1896   KEY `biblionumber` (`biblionumber`)
1897 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1898
1899 --
1900 -- Table structure for table `subscriptionroutinglist`
1901 --
1902
1903 DROP TABLE IF EXISTS `subscriptionroutinglist`;
1904 CREATE TABLE `subscriptionroutinglist` ( -- information related to the routing lists attached to subscriptions
1905   `routingid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
1906   `borrowernumber` int(11) NOT NULL, -- foreign key from the borrowers table, defines with patron is on the routing list
1907   `ranking` int(11) default NULL, -- where the patron stands in line to receive the serial
1908   `subscriptionid` int(11) NOT NULL, -- foreign key from the subscription table, defines which subscription this routing list is for
1909   PRIMARY KEY  (`routingid`),
1910   UNIQUE (`subscriptionid`, `borrowernumber`),
1911   CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1912     ON DELETE CASCADE ON UPDATE CASCADE,
1913   CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`)
1914     ON DELETE CASCADE ON UPDATE CASCADE
1915 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1916
1917 --
1918 -- Table structure for table `suggestions`
1919 --
1920
1921 DROP TABLE IF EXISTS `suggestions`;
1922 CREATE TABLE `suggestions` ( -- purchase suggestions
1923   `suggestionid` int(8) NOT NULL auto_increment, -- unique identifier assigned automatically by Koha
1924   `suggestedby` int(11) NOT NULL default 0, -- borrowernumber for the person making the suggestion, foreign key linking to the borrowers table
1925   `suggesteddate` date NOT NULL default 0, -- date the suggestion was submitted
1926   `managedby` int(11) default NULL, -- borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table
1927   `manageddate` date default NULL, -- date the suggestion was updated
1928    acceptedby INT(11) default NULL, -- borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table
1929    accepteddate date default NULL, -- date the suggestion was marked as accepted
1930    rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table
1931    rejecteddate date default NULL, -- date the suggestion was marked as rejected
1932   `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)
1933   `note` mediumtext, -- note entered on the suggestion
1934   `author` varchar(80) default NULL, -- author of the suggested item
1935   `title` varchar(80) default NULL, -- title of the suggested item
1936   `copyrightdate` smallint(6) default NULL, -- copyright date of the suggested item
1937   `publishercode` varchar(255) default NULL, -- publisher of the suggested item
1938   `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  -- date and time the suggestion was updated
1939   `volumedesc` varchar(255) default NULL,
1940   `publicationyear` smallint(6) default 0,
1941   `place` varchar(255) default NULL, -- publication place of the suggested item
1942   `isbn` varchar(30) default NULL, -- isbn of the suggested item
1943   `mailoverseeing` smallint(1) default 0,
1944   `biblionumber` int(11) default NULL, -- foreign key linking the suggestion to the biblio table after the suggestion has been ordered
1945   `reason` text, -- reason for accepting or rejecting the suggestion
1946   `patronreason` text, -- reason for making the suggestion
1947    budgetid INT(11), -- foreign key linking the suggested budget to the aqbudgets table
1948    branchcode VARCHAR(10) default NULL, -- foreign key linking the suggested branch to the branches table
1949    collectiontitle text default NULL, -- collection name for the suggested item
1950    itemtype VARCHAR(30) default NULL, -- suggested item type 
1951         quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased
1952         currency VARCHAR(3) default NULL, -- suggested currency for the suggested price
1953         price DECIMAL(28,6) default NULL, -- suggested price
1954         total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
1955   PRIMARY KEY  (`suggestionid`),
1956   KEY `suggestedby` (`suggestedby`),
1957   KEY `managedby` (`managedby`)
1958 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1959
1960 --
1961 -- Table structure for table `systempreferences`
1962 --
1963
1964 DROP TABLE IF EXISTS `systempreferences`;
1965 CREATE TABLE `systempreferences` ( -- global system preferences
1966   `variable` varchar(50) NOT NULL default '', -- system preference name
1967   `value` text, -- system preference values
1968   `options` mediumtext, -- options for multiple choice system preferences
1969   `explanation` text, -- descriptive text for the system preference
1970   `type` varchar(20) default NULL, -- type of question this preference asks (multiple choice, plain text, yes or no, etc)
1971   PRIMARY KEY  (`variable`)
1972 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1973
1974 --
1975 -- Table structure for table `tags`
1976 --
1977
1978 DROP TABLE IF EXISTS `tags`;
1979 CREATE TABLE `tags` (
1980   `entry` varchar(255) NOT NULL default '',
1981   `weight` bigint(20) NOT NULL default 0,
1982   PRIMARY KEY  (`entry`)
1983 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1984
1985 --
1986 -- Table structure for table `tags_all`
1987 --
1988
1989 DROP TABLE IF EXISTS `tags_all`;
1990 CREATE TABLE `tags_all` (
1991   `tag_id`         int(11) NOT NULL auto_increment,
1992   `borrowernumber` int(11) NOT NULL,
1993   `biblionumber`   int(11) NOT NULL,
1994   `term`      varchar(255) NOT NULL,
1995   `language`       int(4) default NULL,
1996   `date_created` datetime  NOT NULL,
1997   PRIMARY KEY  (`tag_id`),
1998   KEY `tags_borrowers_fk_1` (`borrowernumber`),
1999   KEY `tags_biblionumber_fk_1` (`biblionumber`),
2000   CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
2001         REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2002   CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
2003         REFERENCES `biblio`     (`biblionumber`)  ON DELETE CASCADE ON UPDATE CASCADE
2004 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2005
2006 --
2007 -- Table structure for table `tags_approval`
2008 --
2009
2010 DROP TABLE IF EXISTS `tags_approval`;
2011 CREATE TABLE `tags_approval` (
2012   `term`   varchar(255) NOT NULL,
2013   `approved`     int(1) NOT NULL default '0',
2014   `date_approved` datetime       default NULL,
2015   `approved_by` int(11)          default NULL,
2016   `weight_total` int(9) NOT NULL default '1',
2017   PRIMARY KEY  (`term`),
2018   KEY `tags_approval_borrowers_fk_1` (`approved_by`),
2019   CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
2020         REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2021 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2022
2023 --
2024 -- Table structure for table `tags_index`
2025 --
2026
2027 DROP TABLE IF EXISTS `tags_index`;
2028 CREATE TABLE `tags_index` (
2029   `term`    varchar(255) NOT NULL,
2030   `biblionumber` int(11) NOT NULL,
2031   `weight`        int(9) NOT NULL default '1',
2032   PRIMARY KEY  (`term`,`biblionumber`),
2033   KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
2034   CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
2035         REFERENCES `tags_approval` (`term`)  ON DELETE CASCADE ON UPDATE CASCADE,
2036   CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
2037         REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2038 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2039
2040 --
2041 -- Table structure for table `userflags`
2042 --
2043
2044 DROP TABLE IF EXISTS `userflags`;
2045 CREATE TABLE `userflags` (
2046   `bit` int(11) NOT NULL default 0,
2047   `flag` varchar(30) default NULL,
2048   `flagdesc` varchar(255) default NULL,
2049   `defaulton` int(11) default NULL,
2050   PRIMARY KEY  (`bit`)
2051 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2052
2053 --
2054 -- Table structure for table `virtualshelves`
2055 --
2056
2057 DROP TABLE IF EXISTS `virtualshelves`;
2058 CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) 
2059   `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2060   `shelfname` varchar(255) default NULL, -- name of the list
2061   `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)
2062   `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2063   `sortfield` varchar(16) default NULL, -- the field this list is sorted on
2064   `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2065   `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2066   `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2067   `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2068   PRIMARY KEY  (`shelfnumber`),
2069   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 VirtualShelves.pm
2070 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2071
2072 --
2073 -- Table structure for table `virtualshelfcontents`
2074 --
2075
2076 DROP TABLE IF EXISTS `virtualshelfcontents`;
2077 CREATE TABLE `virtualshelfcontents` ( -- information about the titles in a list (or virtual shelf)
2078   `shelfnumber` int(11) NOT NULL default 0, -- foreign key linking to the virtualshelves table, defines the list that this record has been added to
2079   `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
2080   `flags` int(11) default NULL,
2081   `dateadded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- date and time this bib record was added to the list
2082   `borrowernumber` int, -- borrower number that created this list entry (only the first one is saved: no need for use in/as key)
2083   KEY `shelfnumber` (`shelfnumber`),
2084   KEY `biblionumber` (`biblionumber`),
2085   CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2086   CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2087   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 VirtualShelves.pm
2088 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2089
2090 --
2091 -- Table structure for table `virtualshelfshares`
2092 --
2093
2094 DROP TABLE IF EXISTS `virtualshelfshares`;
2095 CREATE TABLE `virtualshelfshares` ( -- shared private lists
2096   `id` int AUTO_INCREMENT PRIMARY KEY,  -- unique key
2097   `shelfnumber` int NOT NULL,  -- foreign key for virtualshelves
2098   `borrowernumber` int,  -- borrower that accepted access to this list
2099   `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
2100   `sharedate` datetime,  -- date of invitation or acceptance of invitation
2101   CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2102   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 VirtualShelves.pm
2103 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2104
2105 --
2106 -- Table structure for table `z3950servers`
2107 --
2108
2109 DROP TABLE IF EXISTS `z3950servers`;
2110 CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets used in cataloging
2111   `host` varchar(255) default NULL, -- target's host name
2112   `port` int(11) default NULL, -- port number used to connect to target
2113   `db` varchar(255) default NULL, -- target's database name
2114   `userid` varchar(255) default NULL, -- username needed to log in to target
2115   `password` varchar(255) default NULL, -- password needed to log in to target
2116   `name` mediumtext, -- name given to the target by the library
2117   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2118   `checked` smallint(6) default NULL, -- whether this target is checked by default  (1 for yes, 0 for no)
2119   `rank` int(11) default NULL, -- where this target appears in the list of targets
2120   `syntax` varchar(80) default NULL, -- marc format provided by this target
2121   `timeout` int(11) NOT NULL DEFAULT '0',
2122   `icon` text, -- unused in Koha
2123   `position` enum('primary','secondary','') NOT NULL default 'primary',
2124   `type` enum('zed','opensearch') NOT NULL default 'zed',
2125   `encoding` text default NULL, -- characters encoding provided by this target
2126   `description` text NOT NULL, -- unused in Koha
2127   PRIMARY KEY  (`id`)
2128 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2129
2130 --
2131 -- Table structure for table `zebraqueue`
2132 --
2133
2134 DROP TABLE IF EXISTS `zebraqueue`;
2135 CREATE TABLE `zebraqueue` (
2136   `id` int(11) NOT NULL auto_increment,
2137   `biblio_auth_number` bigint(20) unsigned NOT NULL default '0',
2138   `operation` char(20) NOT NULL default '',
2139   `server` char(20) NOT NULL default '',
2140   `done` int(11) NOT NULL default '0',
2141   `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2142   PRIMARY KEY  (`id`),
2143   KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)
2144 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2145
2146 --
2147 -- Table structure for table `services_throttle`
2148 --
2149
2150 DROP TABLE IF EXISTS `services_throttle`;
2151 CREATE TABLE `services_throttle` (
2152   `service_type` varchar(10) NOT NULL default '',
2153   `service_count` varchar(45) default NULL,
2154   PRIMARY KEY  (`service_type`)
2155 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2156
2157 --
2158 -- Table structure for table `language_subtag_registry`
2159 -- http://www.w3.org/International/articles/language-tags/
2160 -- RFC4646
2161 --
2162
2163 DROP TABLE IF EXISTS language_subtag_registry;
2164 CREATE TABLE language_subtag_registry (
2165         subtag varchar(25),
2166         type varchar(25), -- language-script-region-variant-extension-privateuse
2167         description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
2168         added date,
2169         id int(11) NOT NULL auto_increment,
2170         PRIMARY KEY  (`id`),
2171         KEY `subtag` (`subtag`)
2172 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2173
2174 --
2175 -- Table structure for table `language_rfc4646_to_iso639`
2176 -- TODO: add suppress_scripts
2177 -- this maps three letter codes defined in iso639.2 back to their
2178 -- two letter equivilents in rfc4646 (LOC maintains iso639+)
2179 --
2180
2181 DROP TABLE IF EXISTS language_rfc4646_to_iso639;
2182 CREATE TABLE language_rfc4646_to_iso639 (
2183         rfc4646_subtag varchar(25),
2184         iso639_2_code varchar(25),
2185         id int(11) NOT NULL auto_increment,
2186         PRIMARY KEY  (`id`),
2187         KEY `rfc4646_subtag` (`rfc4646_subtag`)
2188 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2189
2190 --
2191 -- Table structure for table `language_descriptions`
2192 --
2193
2194 DROP TABLE IF EXISTS language_descriptions;
2195 CREATE TABLE language_descriptions (
2196         subtag varchar(25),
2197         type varchar(25),
2198         lang varchar(25),
2199         description varchar(255),
2200         id int(11) NOT NULL auto_increment,
2201         PRIMARY KEY  (`id`),
2202         KEY `lang` (`lang`),
2203         KEY `subtag_type_lang` (`subtag`, `type`, `lang`)
2204 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2205
2206 --
2207 -- Table structure for table `language_script_bidi`
2208 -- bi-directional support, keyed by script subcode
2209 --
2210
2211 DROP TABLE IF EXISTS language_script_bidi;
2212 CREATE TABLE language_script_bidi (
2213         rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
2214         bidi varchar(3), -- rtl ltr
2215         KEY `rfc4646_subtag` (`rfc4646_subtag`)
2216 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2217
2218 --
2219 -- Table structure for table `language_script_mapping`
2220 -- TODO: need to map language subtags to script subtags for detection
2221 -- of bidi when script is not specified (like ar, he)
2222 --
2223
2224 DROP TABLE IF EXISTS language_script_mapping;
2225 CREATE TABLE language_script_mapping (
2226         language_subtag varchar(25),
2227         script_subtag varchar(25),
2228         KEY `language_subtag` (`language_subtag`)
2229 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2230
2231 --
2232 -- Table structure for table `permissions`
2233 --
2234
2235 DROP TABLE IF EXISTS `permissions`;
2236 CREATE TABLE `permissions` (
2237   `module_bit` int(11) NOT NULL DEFAULT 0,
2238   `code` varchar(64) DEFAULT NULL,
2239   `description` varchar(255) DEFAULT NULL,
2240   PRIMARY KEY  (`module_bit`, `code`),
2241   CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
2242     ON DELETE CASCADE ON UPDATE CASCADE
2243 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2244
2245 --
2246 -- Table structure for table `serialitems`
2247 --
2248
2249 DROP TABLE IF EXISTS `serialitems`;
2250 CREATE TABLE `serialitems` (
2251         `itemnumber` int(11) NOT NULL,
2252         `serialid` int(11) NOT NULL,
2253         UNIQUE KEY `serialitemsidx` (`itemnumber`),
2254         KEY `serialitems_sfk_1` (`serialid`),
2255         CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
2256         CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
2257 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2258
2259 --
2260 -- Table structure for table `user_permissions`
2261 --
2262
2263 DROP TABLE IF EXISTS `user_permissions`;
2264 CREATE TABLE `user_permissions` (
2265   `borrowernumber` int(11) NOT NULL DEFAULT 0,
2266   `module_bit` int(11) NOT NULL DEFAULT 0,
2267   `code` varchar(64) DEFAULT NULL,
2268   CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
2269     ON DELETE CASCADE ON UPDATE CASCADE,
2270   CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`) REFERENCES `permissions` (`module_bit`, `code`)
2271     ON DELETE CASCADE ON UPDATE CASCADE
2272 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2273
2274 --
2275 -- Table structure for table `tmp_holdsqueue`
2276 --
2277
2278 DROP TABLE IF EXISTS `tmp_holdsqueue`;
2279 CREATE TABLE `tmp_holdsqueue` (
2280   `biblionumber` int(11) default NULL,
2281   `itemnumber` int(11) default NULL,
2282   `barcode` varchar(20) default NULL,
2283   `surname` mediumtext NOT NULL,
2284   `firstname` text,
2285   `phone` text,
2286   `borrowernumber` int(11) NOT NULL,
2287   `cardnumber` varchar(16) default NULL,
2288   `reservedate` date default NULL,
2289   `title` mediumtext,
2290   `itemcallnumber` varchar(255) default NULL,
2291   `holdingbranch` varchar(10) default NULL,
2292   `pickbranch` varchar(10) default NULL,
2293   `notes` text,
2294   `item_level_request` tinyint(4) NOT NULL default 0
2295 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2296
2297 --
2298 -- Table structure for table `message_queue`
2299 --
2300
2301 DROP TABLE IF EXISTS `message_queue`;
2302 CREATE TABLE `message_queue` (
2303   `message_id` int(11) NOT NULL auto_increment,
2304   `borrowernumber` int(11) default NULL,
2305   `subject` text,
2306   `content` text,
2307   `metadata` text DEFAULT NULL,
2308   `letter_code` varchar(64) DEFAULT NULL,
2309   `message_transport_type` varchar(20) NOT NULL,
2310   `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
2311   `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2312   `to_address` mediumtext,
2313   `from_address` mediumtext,
2314   `content_type` text,
2315   KEY `message_id` (`message_id`),
2316   KEY `borrowernumber` (`borrowernumber`),
2317   KEY `message_transport_type` (`message_transport_type`),
2318   CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2319   CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
2320 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2321
2322 --
2323 -- Table structure for table `message_transport_types`
2324 --
2325
2326 DROP TABLE IF EXISTS `message_transport_types`;
2327 CREATE TABLE `message_transport_types` (
2328   `message_transport_type` varchar(20) NOT NULL,
2329   PRIMARY KEY  (`message_transport_type`)
2330 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2331
2332 --
2333 -- Table structure for table `message_attributes`
2334 --
2335
2336 DROP TABLE IF EXISTS `message_attributes`;
2337 CREATE TABLE `message_attributes` (
2338   `message_attribute_id` int(11) NOT NULL auto_increment,
2339   `message_name` varchar(40) NOT NULL default '',
2340   `takes_days` tinyint(1) NOT NULL default '0',
2341   PRIMARY KEY  (`message_attribute_id`),
2342   UNIQUE KEY `message_name` (`message_name`)
2343 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2344
2345 --
2346 -- Table structure for table `message_transports`
2347 --
2348
2349 DROP TABLE IF EXISTS `message_transports`;
2350 CREATE TABLE `message_transports` (
2351   `message_attribute_id` int(11) NOT NULL,
2352   `message_transport_type` varchar(20) NOT NULL,
2353   `is_digest` tinyint(1) NOT NULL default '0',
2354   `letter_module` varchar(20) NOT NULL default '',
2355   `letter_code` varchar(20) NOT NULL default '',
2356   `branchcode` varchar(10) NOT NULL default '',
2357   PRIMARY KEY  (`message_attribute_id`,`message_transport_type`,`is_digest`),
2358   KEY `message_transport_type` (`message_transport_type`),
2359   KEY `letter_module` (`letter_module`,`letter_code`),
2360   CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2361   CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
2362   CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`, `branchcode`) REFERENCES `letter` (`module`, `code`, `branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2363 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2364
2365 --
2366 -- Table structure for table `borrower_message_preferences`
2367 --
2368
2369 DROP TABLE IF EXISTS `borrower_message_preferences`;
2370 CREATE TABLE `borrower_message_preferences` (
2371   `borrower_message_preference_id` int(11) NOT NULL auto_increment,
2372   `borrowernumber` int(11) default NULL,
2373   `categorycode` varchar(10) default NULL,
2374   `message_attribute_id` int(11) default '0',
2375   `days_in_advance` int(11) default '0',
2376   `wants_digest` tinyint(1) NOT NULL default '0',
2377   PRIMARY KEY  (`borrower_message_preference_id`),
2378   KEY `borrowernumber` (`borrowernumber`),
2379   KEY `categorycode` (`categorycode`),
2380   KEY `message_attribute_id` (`message_attribute_id`),
2381   CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2382   CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2383   CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
2384 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2385
2386 --
2387 -- Table structure for table `borrower_message_transport_preferences`
2388 --
2389
2390 DROP TABLE IF EXISTS `borrower_message_transport_preferences`;
2391 CREATE TABLE `borrower_message_transport_preferences` (
2392   `borrower_message_preference_id` int(11) NOT NULL default '0',
2393   `message_transport_type` varchar(20) NOT NULL default '0',
2394   PRIMARY KEY  (`borrower_message_preference_id`,`message_transport_type`),
2395   KEY `message_transport_type` (`message_transport_type`),
2396   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,
2397   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
2398 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2399
2400 --
2401 -- Table structure for the table branch_transfer_limits
2402 --
2403
2404 DROP TABLE IF EXISTS `branch_transfer_limits`;
2405 CREATE TABLE branch_transfer_limits (
2406     limitId int(8) NOT NULL auto_increment,
2407     toBranch varchar(10) NOT NULL,
2408     fromBranch varchar(10) NOT NULL,
2409     itemtype varchar(10) NULL,
2410     ccode varchar(10) NULL,
2411     PRIMARY KEY  (limitId)
2412 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2413
2414 --
2415 -- Table structure for table `item_circulation_alert_preferences`
2416 --
2417
2418 DROP TABLE IF EXISTS `item_circulation_alert_preferences`;
2419 CREATE TABLE `item_circulation_alert_preferences` (
2420   `id` int(11) NOT NULL auto_increment,
2421   `branchcode` varchar(10) NOT NULL,
2422   `categorycode` varchar(10) NOT NULL,
2423   `item_type` varchar(10) NOT NULL,
2424   `notification` varchar(16) NOT NULL,
2425   PRIMARY KEY  (`id`),
2426   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`, `notification`)
2427 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2428
2429 --
2430 -- Table structure for table `messages`
2431 --
2432 DROP TABLE IF EXISTS `messages`;
2433 CREATE TABLE `messages` ( -- circulation messages left via the patron's check out screen
2434   `message_id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2435   `borrowernumber` int(11) NOT NULL, -- foreign key linking this message to the borrowers table
2436   `branchcode` varchar(10) default NULL, -- foreign key linking the message to the branches table
2437   `message_type` varchar(1) NOT NULL, -- whether the message is for the librarians (L) or the patron (B)
2438   `message` text NOT NULL, -- the text of the message
2439   `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- the date and time the message was written
2440   PRIMARY KEY (`message_id`)
2441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2442
2443 --
2444 -- Table structure for table `accountlines`
2445 --
2446
2447 DROP TABLE IF EXISTS `accountlines`;
2448 CREATE TABLE `accountlines` (
2449   `borrowernumber` int(11) NOT NULL default 0,
2450   `accountno` smallint(6) NOT NULL default 0,
2451   `itemnumber` int(11) default NULL,
2452   `date` date default NULL,
2453   `amount` decimal(28,6) default NULL,
2454   `description` mediumtext,
2455   `dispute` mediumtext,
2456   `accounttype` varchar(5) default NULL,
2457   `amountoutstanding` decimal(28,6) default NULL,
2458   `lastincrement` decimal(28,6) default NULL,
2459   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2460   `notify_id` int(11) NOT NULL default 0,
2461   `notify_level` int(2) NOT NULL default 0,
2462   `note` text NULL default NULL,
2463   `manager_id` int(11) NULL,
2464   KEY `acctsborridx` (`borrowernumber`),
2465   KEY `timeidx` (`timestamp`),
2466   KEY `itemnumber` (`itemnumber`),
2467   CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2468   CONSTRAINT `accountlines_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
2469 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2470
2471 --
2472 -- Table structure for table `accountoffsets`
2473 --
2474
2475 DROP TABLE IF EXISTS `accountoffsets`;
2476 CREATE TABLE `accountoffsets` (
2477   `borrowernumber` int(11) NOT NULL default 0,
2478   `accountno` smallint(6) NOT NULL default 0,
2479   `offsetaccount` smallint(6) NOT NULL default 0,
2480   `offsetamount` decimal(28,6) default NULL,
2481   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2482   CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2483 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2484
2485 --
2486 -- Table structure for table `action_logs`
2487 --
2488
2489 DROP TABLE IF EXISTS `action_logs`;
2490 CREATE TABLE `action_logs` (
2491   `action_id` int(11) NOT NULL auto_increment,
2492   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2493   `user` int(11) NOT NULL default 0,
2494   `module` text,
2495   `action` text,
2496   `object` int(11) default NULL,
2497   `info` text,
2498   PRIMARY KEY (`action_id`),
2499   KEY  (`timestamp`,`user`)
2500 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2501
2502 --
2503 -- Table structure for table `alert`
2504 --
2505
2506 DROP TABLE IF EXISTS `alert`;
2507 CREATE TABLE `alert` (
2508   `alertid` int(11) NOT NULL auto_increment,
2509   `borrowernumber` int(11) NOT NULL default 0,
2510   `type` varchar(10) NOT NULL default '',
2511   `externalid` varchar(20) NOT NULL default '',
2512   PRIMARY KEY  (`alertid`),
2513   KEY `borrowernumber` (`borrowernumber`),
2514   KEY `type` (`type`,`externalid`)
2515 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2516
2517 --
2518 -- Table structure for table `aqbasketgroups`
2519 --
2520
2521 DROP TABLE IF EXISTS `aqbasketgroups`;
2522 CREATE TABLE `aqbasketgroups` (
2523   `id` int(11) NOT NULL auto_increment,
2524   `name` varchar(50) default NULL,
2525   `closed` tinyint(1) default NULL,
2526   `booksellerid` int(11) NOT NULL,
2527   `deliveryplace` varchar(10) default NULL,
2528   `freedeliveryplace` text default NULL,
2529   `deliverycomment` varchar(255) default NULL,
2530   `billingplace` varchar(10) default NULL,
2531   PRIMARY KEY  (`id`),
2532   KEY `booksellerid` (`booksellerid`),
2533   CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2534 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2535
2536 --
2537 -- Table structure for table `aqbasket`
2538 --
2539
2540 DROP TABLE IF EXISTS `aqbasket`;
2541 CREATE TABLE `aqbasket` (
2542   `basketno` int(11) NOT NULL auto_increment,
2543   `basketname` varchar(50) default NULL,
2544   `note` mediumtext,
2545   `booksellernote` mediumtext,
2546   `contractnumber` int(11),
2547   `creationdate` date default NULL,
2548   `closedate` date default NULL,
2549   `booksellerid` int(11) NOT NULL default 1,
2550   `authorisedby` varchar(10) default NULL,
2551   `booksellerinvoicenumber` mediumtext,
2552   `basketgroupid` int(11),
2553   PRIMARY KEY  (`basketno`),
2554   KEY `booksellerid` (`booksellerid`),
2555   KEY `basketgroupid` (`basketgroupid`),
2556   KEY `contractnumber` (`contractnumber`),
2557   CONSTRAINT `aqbasket_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE,
2558   CONSTRAINT `aqbasket_ibfk_2` FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`),
2559   CONSTRAINT `aqbasket_ibfk_3` FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE
2560 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2561
2562 --
2563 -- Table structure for table `aqbooksellers`
2564 --
2565
2566 DROP TABLE IF EXISTS `aqbooksellers`;
2567 CREATE TABLE `aqbooksellers` ( -- information about the vendors listed in acquisitions
2568   `id` int(11) NOT NULL auto_increment, -- primary key and unique identifier assigned by Koha
2569   `name` mediumtext NOT NULL, -- vendor name
2570   `address1` mediumtext, -- first line of vendor physical address
2571   `address2` mediumtext, -- second line of vendor physical address
2572   `address3` mediumtext, -- third line of vendor physical address
2573   `address4` mediumtext, -- fourth line of vendor physical address
2574   `phone` varchar(30) default NULL, -- vendor phone number
2575   `accountnumber` mediumtext, -- unused in Koha
2576   `othersupplier` mediumtext,  -- unused in Koha
2577   `currency` varchar(3) NOT NULL default '', -- unused in Koha
2578   `booksellerfax` mediumtext, -- vendor fax number
2579   `notes` mediumtext, -- order notes
2580   `bookselleremail` mediumtext, -- vendor email
2581   `booksellerurl` mediumtext, -- unused in Koha
2582   `contact` varchar(100) default NULL, -- name of contact at vendor
2583   `postal` mediumtext, -- vendor postal address (all lines)
2584   `url` varchar(255) default NULL, -- vendor web address
2585   `contpos` varchar(100) default NULL, -- contact person's position
2586   `contphone` varchar(100) default NULL, -- contact's phone number
2587   `contfax` varchar(100) default NULL,  -- contact's fax number
2588   `contaltphone` varchar(100) default NULL, -- contact's alternate phone number
2589   `contemail` varchar(100) default NULL, -- contact's email address
2590   `contnotes` mediumtext, -- notes related to the contact
2591   `active` tinyint(4) default NULL, -- is this vendor active (1 for yes, 0 for no)
2592   `listprice` varchar(10) default NULL, -- currency code for list prices
2593   `invoiceprice` varchar(10) default NULL, -- currency code for invoice prices
2594   `gstreg` tinyint(4) default NULL, -- is your library charged tax (1 for yes, 0 for no)
2595   `listincgst` tinyint(4) default NULL, -- is tax included in list prices (1 for yes, 0 for no)
2596   `invoiceincgst` tinyint(4) default NULL, -- is tax included in invoice prices (1 for yes, 0 for no)
2597   `gstrate` decimal(6,4) default NULL, -- the tax rate the library is charged
2598   `discount` float(6,4) default NULL, -- discount offered on all items ordered from this vendor
2599   `fax` varchar(50) default NULL, -- vendor fax number
2600   PRIMARY KEY  (`id`),
2601   KEY `listprice` (`listprice`),
2602   KEY `invoiceprice` (`invoiceprice`),
2603   CONSTRAINT `aqbooksellers_ibfk_1` FOREIGN KEY (`listprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE,
2604   CONSTRAINT `aqbooksellers_ibfk_2` FOREIGN KEY (`invoiceprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE
2605 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2606
2607 --
2608 -- Table structure for table `aqbudgets`
2609 --
2610
2611 DROP TABLE IF EXISTS `aqbudgets`;
2612 CREATE TABLE `aqbudgets` (
2613   `budget_id` int(11) NOT NULL auto_increment,
2614   `budget_parent_id` int(11) default NULL,
2615   `budget_code` varchar(30) default NULL,
2616   `budget_name` varchar(80) default NULL,
2617   `budget_branchcode` varchar(10) default NULL,
2618   `budget_amount` decimal(28,6) NULL default '0.00',
2619   `budget_encumb` decimal(28,6) NULL default '0.00',
2620   `budget_expend` decimal(28,6) NULL default '0.00',
2621   `budget_notes` mediumtext,
2622   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2623   `budget_period_id` int(11) default NULL,
2624   `sort1_authcat` varchar(80) default NULL,
2625   `sort2_authcat` varchar(80) default NULL,
2626   `budget_owner_id` int(11) default NULL,
2627   `budget_permission` int(1) default '0',
2628   PRIMARY KEY  (`budget_id`)
2629 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2630
2631
2632 --
2633 -- Table structure for table `aqbudgetperiods`
2634 --
2635
2636
2637 DROP TABLE IF EXISTS `aqbudgetperiods`;
2638 CREATE TABLE `aqbudgetperiods` (
2639   `budget_period_id` int(11) NOT NULL auto_increment,
2640   `budget_period_startdate` date NOT NULL,
2641   `budget_period_enddate` date NOT NULL,
2642   `budget_period_active` tinyint(1) default '0',
2643   `budget_period_description` mediumtext,
2644   `budget_period_total` decimal(28,6),
2645   `budget_period_locked` tinyint(1) default NULL,
2646   `sort1_authcat` varchar(10) default NULL,
2647   `sort2_authcat` varchar(10) default NULL,
2648   PRIMARY KEY  (`budget_period_id`)
2649 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2650
2651 --
2652 -- Table structure for table `aqbudgets_planning`
2653 --
2654
2655 DROP TABLE IF EXISTS `aqbudgets_planning`;
2656 CREATE TABLE `aqbudgets_planning` (
2657   `plan_id` int(11) NOT NULL auto_increment,
2658   `budget_id` int(11) NOT NULL,
2659   `budget_period_id` int(11) NOT NULL,
2660   `estimated_amount` decimal(28,6) default NULL,
2661   `authcat` varchar(30) NOT NULL,
2662   `authvalue` varchar(30) NOT NULL,
2663   `display` tinyint(1) DEFAULT 1,
2664   PRIMARY KEY  (`plan_id`),
2665   CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
2666 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2667
2668 --
2669 -- Table structure for table 'aqcontract'
2670 --
2671
2672 DROP TABLE IF EXISTS `aqcontract`;
2673 CREATE TABLE `aqcontract` (
2674   `contractnumber` int(11) NOT NULL auto_increment,
2675   `contractstartdate` date default NULL,
2676   `contractenddate` date default NULL,
2677   `contractname` varchar(50) default NULL,
2678   `contractdescription` mediumtext,
2679   `booksellerid` int(11) not NULL,
2680   PRIMARY KEY  (`contractnumber`),
2681   CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2682        REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2683 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2684
2685 --
2686 -- Table structure for table `aqorderdelivery`
2687 --
2688
2689 DROP TABLE IF EXISTS `aqorderdelivery`;
2690 CREATE TABLE `aqorderdelivery` (
2691   `ordernumber` date default NULL,
2692   `deliverynumber` smallint(6) NOT NULL default 0,
2693   `deliverydate` varchar(18) default NULL,
2694   `qtydelivered` smallint(6) default NULL,
2695   `deliverycomments` mediumtext
2696 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2697
2698 --
2699 -- Table structure for table `aqorders`
2700 --
2701
2702 DROP TABLE IF EXISTS `aqorders`;
2703 CREATE TABLE `aqorders` (
2704   `ordernumber` int(11) NOT NULL auto_increment,
2705   `biblionumber` int(11) default NULL,
2706   `entrydate` date default NULL,
2707   `quantity` smallint(6) default NULL,
2708   `currency` varchar(3) default NULL,
2709   `listprice` decimal(28,6) default NULL,
2710   `totalamount` decimal(28,6) default NULL,
2711   `datereceived` date default NULL,
2712   `booksellerinvoicenumber` mediumtext,
2713   `freight` decimal(28,6) default NULL,
2714   `unitprice` decimal(28,6) default NULL,
2715   `quantityreceived` smallint(6) NOT NULL default 0,
2716   `cancelledby` varchar(10) default NULL,
2717   `datecancellationprinted` date default NULL,
2718   `notes` mediumtext,
2719   `supplierreference` mediumtext,
2720   `purchaseordernumber` mediumtext,
2721   `subscription` tinyint(1) default NULL,
2722   `serialid` varchar(30) default NULL,
2723   `basketno` int(11) default NULL,
2724   `biblioitemnumber` int(11) default NULL,
2725   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2726   `rrp` decimal(13,2) default NULL,
2727   `ecost` decimal(13,2) default NULL,
2728   `gst` decimal(13,2) default NULL,
2729   `budget_id` int(11) NOT NULL,
2730   `budgetgroup_id` int(11) NOT NULL,
2731   `budgetdate` date default NULL,
2732   `sort1` varchar(80) default NULL,
2733   `sort2` varchar(80) default NULL,
2734   `sort1_authcat` varchar(10) default NULL,
2735   `sort2_authcat` varchar(10) default NULL,
2736   `uncertainprice` tinyint(1),
2737   `claims_count` int(11) default 0,
2738   `claimed_date` date default NULL,
2739   PRIMARY KEY  (`ordernumber`),
2740   KEY `basketno` (`basketno`),
2741   KEY `biblionumber` (`biblionumber`),
2742   KEY `budget_id` (`budget_id`),
2743   CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2744   CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2745 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2746
2747
2748 --
2749 -- Table structure for table `aqorders_items`
2750 --
2751
2752 DROP TABLE IF EXISTS `aqorders_items`;
2753 CREATE TABLE `aqorders_items` (
2754   `ordernumber` int(11) NOT NULL,
2755   `itemnumber` int(11) NOT NULL,
2756   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2757   PRIMARY KEY  (`itemnumber`),
2758   KEY `ordernumber` (`ordernumber`)
2759 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2760
2761 --
2762 -- Table structure for table `fieldmapping`
2763 --
2764
2765 DROP TABLE IF EXISTS `fieldmapping`;
2766 CREATE TABLE `fieldmapping` ( -- koha to keyword mapping
2767   `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2768   `field` varchar(255) NOT NULL, -- keyword to be mapped to (ex. subtitle)
2769   `frameworkcode` char(4) NOT NULL default '', -- foreign key from the biblio_framework table to link this mapping to a specific framework
2770   `fieldcode` char(3) NOT NULL, -- marc field number to map to this keyword
2771   `subfieldcode` char(1) NOT NULL, -- marc subfield associated with the fieldcode to map to this keyword
2772   PRIMARY KEY  (`id`)
2773 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2774
2775 --
2776 -- Table structure for table `biblioimages`
2777 --
2778
2779 DROP TABLE IF EXISTS `biblioimages`;
2780
2781 CREATE TABLE `biblioimages` (
2782  `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
2783  `biblionumber` int(11) NOT NULL,
2784  `mimetype` varchar(15) NOT NULL,
2785  `imagefile` mediumblob NOT NULL,
2786  `thumbnail` mediumblob NOT NULL,
2787  PRIMARY KEY (`imagenumber`),
2788  CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2789 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2790
2791 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2792 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2793 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2794 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
2795 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
2796 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
2797 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
2798 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
2799