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