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