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