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