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