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