Bug 32437: Add Objects for ImportAuths
[koha.git] / installer / data / mysql / kohastructure.sql
1 -- MariaDB dump 10.19  Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64)
2 --
3 -- Host: db    Database: koha_kohadev
4 -- ------------------------------------------------------
5 -- Server version       10.10.2-MariaDB-1:10.10.2+maria~ubu2204
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 /*!40101 SET NAMES utf8mb4 */;
11 /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
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 `account_credit_types`
20 --
21
22 DROP TABLE IF EXISTS `account_credit_types`;
23 /*!40101 SET @saved_cs_client     = @@character_set_client */;
24 /*!40101 SET character_set_client = utf8 */;
25 CREATE TABLE `account_credit_types` (
26   `code` varchar(80) NOT NULL,
27   `description` varchar(200) DEFAULT NULL,
28   `can_be_added_manually` tinyint(4) NOT NULL DEFAULT 1,
29   `credit_number_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is autogeneration of credit number enabled for this credit type',
30   `is_system` tinyint(1) NOT NULL DEFAULT 0,
31   `archived` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote if this till is archived or not',
32   PRIMARY KEY (`code`)
33 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
34 /*!40101 SET character_set_client = @saved_cs_client */;
35
36 --
37 -- Table structure for table `account_credit_types_branches`
38 --
39
40 DROP TABLE IF EXISTS `account_credit_types_branches`;
41 /*!40101 SET @saved_cs_client     = @@character_set_client */;
42 /*!40101 SET character_set_client = utf8 */;
43 CREATE TABLE `account_credit_types_branches` (
44   `credit_type_code` varchar(80) DEFAULT NULL,
45   `branchcode` varchar(10) DEFAULT NULL,
46   KEY `credit_type_code` (`credit_type_code`),
47   KEY `branchcode` (`branchcode`),
48   CONSTRAINT `account_credit_types_branches_ibfk_1` FOREIGN KEY (`credit_type_code`) REFERENCES `account_credit_types` (`code`) ON DELETE CASCADE,
49   CONSTRAINT `account_credit_types_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
50 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
51 /*!40101 SET character_set_client = @saved_cs_client */;
52
53 --
54 -- Table structure for table `account_debit_types`
55 --
56
57 DROP TABLE IF EXISTS `account_debit_types`;
58 /*!40101 SET @saved_cs_client     = @@character_set_client */;
59 /*!40101 SET character_set_client = utf8 */;
60 CREATE TABLE `account_debit_types` (
61   `code` varchar(80) NOT NULL,
62   `description` varchar(200) DEFAULT NULL,
63   `can_be_invoiced` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'boolean flag to denote if this debit type is available for manual invoicing',
64   `can_be_sold` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote if this debit type is available at point of sale',
65   `default_amount` decimal(28,6) DEFAULT NULL,
66   `is_system` tinyint(1) NOT NULL DEFAULT 0,
67   `archived` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote if this till is archived or not',
68   PRIMARY KEY (`code`)
69 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
70 /*!40101 SET character_set_client = @saved_cs_client */;
71
72 --
73 -- Table structure for table `account_debit_types_branches`
74 --
75
76 DROP TABLE IF EXISTS `account_debit_types_branches`;
77 /*!40101 SET @saved_cs_client     = @@character_set_client */;
78 /*!40101 SET character_set_client = utf8 */;
79 CREATE TABLE `account_debit_types_branches` (
80   `debit_type_code` varchar(80) DEFAULT NULL,
81   `branchcode` varchar(10) DEFAULT NULL,
82   KEY `debit_type_code` (`debit_type_code`),
83   KEY `branchcode` (`branchcode`),
84   CONSTRAINT `account_debit_types_branches_ibfk_1` FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON DELETE CASCADE,
85   CONSTRAINT `account_debit_types_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
86 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
87 /*!40101 SET character_set_client = @saved_cs_client */;
88
89 --
90 -- Table structure for table `account_offsets`
91 --
92
93 DROP TABLE IF EXISTS `account_offsets`;
94 /*!40101 SET @saved_cs_client     = @@character_set_client */;
95 /*!40101 SET character_set_client = utf8 */;
96 CREATE TABLE `account_offsets` (
97   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for each offset',
98   `credit_id` int(11) DEFAULT NULL COMMENT 'The id of the accountline the increased the patron''s balance',
99   `debit_id` int(11) DEFAULT NULL COMMENT 'The id of the accountline that decreased the patron''s balance',
100   `type` enum('CREATE','APPLY','VOID','OVERDUE_INCREASE','OVERDUE_DECREASE') NOT NULL COMMENT 'The type of offset this is',
101   `amount` decimal(26,6) NOT NULL COMMENT 'The amount of the change',
102   `created_on` timestamp NOT NULL DEFAULT current_timestamp(),
103   PRIMARY KEY (`id`),
104   KEY `account_offsets_ibfk_p` (`credit_id`),
105   KEY `account_offsets_ibfk_f` (`debit_id`),
106   CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
107   CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE
108 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
109 /*!40101 SET character_set_client = @saved_cs_client */;
110
111 --
112 -- Table structure for table `accountlines`
113 --
114
115 DROP TABLE IF EXISTS `accountlines`;
116 /*!40101 SET @saved_cs_client     = @@character_set_client */;
117 /*!40101 SET character_set_client = utf8 */;
118 CREATE TABLE `accountlines` (
119   `accountlines_id` int(11) NOT NULL AUTO_INCREMENT,
120   `issue_id` int(11) DEFAULT NULL,
121   `borrowernumber` int(11) DEFAULT NULL,
122   `itemnumber` int(11) DEFAULT NULL,
123   `date` timestamp NULL DEFAULT NULL,
124   `amount` decimal(28,6) DEFAULT NULL,
125   `description` longtext DEFAULT NULL,
126   `credit_type_code` varchar(80) DEFAULT NULL,
127   `debit_type_code` varchar(80) DEFAULT NULL,
128   `credit_number` varchar(20) DEFAULT NULL COMMENT 'autogenerated number for credits',
129   `status` varchar(16) DEFAULT NULL,
130   `payment_type` varchar(80) DEFAULT NULL COMMENT 'optional authorised value PAYMENT_TYPE',
131   `amountoutstanding` decimal(28,6) DEFAULT NULL,
132   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
133   `note` mediumtext DEFAULT NULL,
134   `manager_id` int(11) DEFAULT NULL,
135   `register_id` int(11) DEFAULT NULL,
136   `interface` varchar(16) NOT NULL,
137   `branchcode` varchar(10) DEFAULT NULL COMMENT 'the branchcode of the library where a payment was made, a manual invoice created, etc.',
138   PRIMARY KEY (`accountlines_id`),
139   KEY `acctsborridx` (`borrowernumber`),
140   KEY `timeidx` (`timestamp`),
141   KEY `credit_type_code` (`credit_type_code`),
142   KEY `debit_type_code` (`debit_type_code`),
143   KEY `itemnumber` (`itemnumber`),
144   KEY `branchcode` (`branchcode`),
145   KEY `manager_id` (`manager_id`),
146   KEY `accountlines_ibfk_registers` (`register_id`),
147   CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
148   CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
149   CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
150   CONSTRAINT `accountlines_ibfk_credit_type` FOREIGN KEY (`credit_type_code`) REFERENCES `account_credit_types` (`code`) ON UPDATE CASCADE,
151   CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON UPDATE CASCADE,
152   CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
153   CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
154 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
155 /*!40101 SET character_set_client = @saved_cs_client */;
156
157 --
158 -- Table structure for table `action_logs`
159 --
160
161 DROP TABLE IF EXISTS `action_logs`;
162 /*!40101 SET @saved_cs_client     = @@character_set_client */;
163 /*!40101 SET character_set_client = utf8 */;
164 CREATE TABLE `action_logs` (
165   `action_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for each action',
166   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the action took place',
167   `user` int(11) NOT NULL DEFAULT 0 COMMENT 'the staff member who performed the action (borrowers.borrowernumber)',
168   `module` mediumtext DEFAULT NULL COMMENT 'the module this action was taken against',
169   `action` mediumtext DEFAULT NULL COMMENT 'the action (includes things like DELETED, ADDED, MODIFY, etc)',
170   `object` int(11) DEFAULT NULL COMMENT 'the object that the action was taken against (could be a borrowernumber, itemnumber, etc)',
171   `info` mediumtext DEFAULT NULL COMMENT 'information about the action (usually includes SQL statement)',
172   `interface` varchar(30) DEFAULT NULL COMMENT 'the context this action was taken in',
173   `script` varchar(255) DEFAULT NULL COMMENT 'the name of the cron script that caused this change',
174   `trace` TEXT DEFAULT NULL COMMENT 'An optional stack trace enabled by ActionLogsTraceDepth',
175   PRIMARY KEY (`action_id`),
176   KEY `timestamp_idx` (`timestamp`),
177   KEY `user_idx` (`user`),
178   KEY `module_idx` (`module`(191)),
179   KEY `action_idx` (`action`(191)),
180   KEY `object_idx` (`object`),
181   KEY `info_idx` (`info`(191)),
182   KEY `interface` (`interface`)
183 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
184 /*!40101 SET character_set_client = @saved_cs_client */;
185
186 --
187 -- Table structure for table `additional_contents`
188 --
189
190 DROP TABLE IF EXISTS `additional_contents`;
191 /*!40101 SET @saved_cs_client     = @@character_set_client */;
192 /*!40101 SET character_set_client = utf8 */;
193 CREATE TABLE `additional_contents` (
194   `idnew` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content',
195   `category` varchar(20) NOT NULL COMMENT 'category for the additional content',
196   `code` varchar(100) NOT NULL COMMENT 'code to group content per lang',
197   `location` varchar(255) NOT NULL COMMENT 'location of the additional content',
198   `branchcode` varchar(10) DEFAULT NULL COMMENT 'branch code users to create branch specific additional content, NULL is every branch.',
199   `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content',
200   `content` mediumtext NOT NULL COMMENT 'the body of your additional content',
201   `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'location for the additional content(koha is the staff interface, slip is the circulation receipt and language codes are for the opac)',
202   `published_on` date DEFAULT NULL COMMENT 'publication date',
203   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
204   `expirationdate` date DEFAULT NULL COMMENT 'date the additional content is set to expire or no longer be visible',
205   `number` int(11) DEFAULT NULL COMMENT 'the order in which this additional content appears in that specific location',
206   `borrowernumber` int(11) DEFAULT NULL COMMENT 'The user who created the additional content',
207   PRIMARY KEY (`idnew`),
208   UNIQUE KEY `additional_contents_uniq` (`category`,`code`,`branchcode`,`lang`),
209   KEY `additional_contents_borrowernumber_fk` (`borrowernumber`),
210   KEY `additional_contents_branchcode_ibfk` (`branchcode`),
211   CONSTRAINT `additional_contents_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
212   CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
213 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
214 /*!40101 SET character_set_client = @saved_cs_client */;
215
216 --
217 -- Table structure for table `additional_field_values`
218 --
219
220 DROP TABLE IF EXISTS `additional_field_values`;
221 /*!40101 SET @saved_cs_client     = @@character_set_client */;
222 /*!40101 SET character_set_client = utf8 */;
223 CREATE TABLE `additional_field_values` (
224   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
225   `field_id` int(11) NOT NULL COMMENT 'foreign key references additional_fields(id)',
226   `record_id` int(11) NOT NULL COMMENT 'record_id',
227   `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value for this field',
228   PRIMARY KEY (`id`),
229   UNIQUE KEY `field_record` (`field_id`,`record_id`),
230   CONSTRAINT `afv_fk` FOREIGN KEY (`field_id`) REFERENCES `additional_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
231 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
232 /*!40101 SET character_set_client = @saved_cs_client */;
233
234 --
235 -- Table structure for table `additional_fields`
236 --
237
238 DROP TABLE IF EXISTS `additional_fields`;
239 /*!40101 SET @saved_cs_client     = @@character_set_client */;
240 /*!40101 SET character_set_client = utf8 */;
241 CREATE TABLE `additional_fields` (
242   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
243   `tablename` varchar(255) NOT NULL DEFAULT '' COMMENT 'tablename of the new field',
244   `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the field',
245   `authorised_value_category` varchar(32) NOT NULL DEFAULT '' COMMENT 'is an authorised value category',
246   `marcfield` varchar(16) NOT NULL DEFAULT '' COMMENT 'contains the marc field to copied into the record',
247   `searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field searchable?',
248   PRIMARY KEY (`id`),
249   UNIQUE KEY `fields_uniq` (`tablename`(191),`name`(191))
250 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
251 /*!40101 SET character_set_client = @saved_cs_client */;
252
253 --
254 -- Table structure for table `advanced_editor_macros`
255 --
256
257 DROP TABLE IF EXISTS `advanced_editor_macros`;
258 /*!40101 SET @saved_cs_client     = @@character_set_client */;
259 /*!40101 SET character_set_client = utf8 */;
260 CREATE TABLE `advanced_editor_macros` (
261   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the macro',
262   `name` varchar(80) NOT NULL COMMENT 'Name of the macro',
263   `macro` longtext DEFAULT NULL COMMENT 'The macro code itself',
264   `borrowernumber` int(11) DEFAULT NULL COMMENT 'ID of the borrower who created this macro',
265   `shared` tinyint(1) DEFAULT 0 COMMENT 'Bit to define if shared or private macro',
266   PRIMARY KEY (`id`),
267   KEY `borrower_macro_fk` (`borrowernumber`),
268   CONSTRAINT `borrower_macro_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
269 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
270 /*!40101 SET character_set_client = @saved_cs_client */;
271
272 --
273 -- Table structure for table `alert`
274 --
275
276 DROP TABLE IF EXISTS `alert`;
277 /*!40101 SET @saved_cs_client     = @@character_set_client */;
278 /*!40101 SET character_set_client = utf8 */;
279 CREATE TABLE `alert` (
280   `alertid` int(11) NOT NULL AUTO_INCREMENT,
281   `borrowernumber` int(11) NOT NULL DEFAULT 0,
282   `type` varchar(10) NOT NULL DEFAULT '',
283   `externalid` varchar(20) NOT NULL DEFAULT '',
284   PRIMARY KEY (`alertid`),
285   KEY `borrowernumber` (`borrowernumber`),
286   KEY `type` (`type`,`externalid`),
287   CONSTRAINT `alert_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
288 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
289 /*!40101 SET character_set_client = @saved_cs_client */;
290
291 --
292 -- Table structure for table `api_keys`
293 --
294
295 DROP TABLE IF EXISTS `api_keys`;
296 /*!40101 SET @saved_cs_client     = @@character_set_client */;
297 /*!40101 SET character_set_client = utf8 */;
298 CREATE TABLE `api_keys` (
299   `client_id` varchar(191) NOT NULL COMMENT 'API client ID',
300   `secret` varchar(191) NOT NULL COMMENT 'API client secret used for API authentication',
301   `description` varchar(255) NOT NULL COMMENT 'API client description',
302   `patron_id` int(11) NOT NULL COMMENT 'Foreign key to the borrowers table',
303   `active` tinyint(1) NOT NULL DEFAULT 1 COMMENT '0 means this API key is revoked',
304   PRIMARY KEY (`client_id`),
305   UNIQUE KEY `secret` (`secret`),
306   KEY `patron_id` (`patron_id`),
307   CONSTRAINT `api_keys_fk_patron_id` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
308 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
309 /*!40101 SET character_set_client = @saved_cs_client */;
310
311 --
312 -- Table structure for table `aqbasket`
313 --
314
315 DROP TABLE IF EXISTS `aqbasket`;
316 /*!40101 SET @saved_cs_client     = @@character_set_client */;
317 /*!40101 SET character_set_client = utf8 */;
318 CREATE TABLE `aqbasket` (
319   `basketno` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key, Koha defined number',
320   `basketname` varchar(50) DEFAULT NULL COMMENT 'name given to the basket at creation',
321   `note` longtext DEFAULT NULL COMMENT 'the internal note added at basket creation',
322   `booksellernote` longtext DEFAULT NULL COMMENT 'the vendor note added at basket creation',
323   `contractnumber` int(11) DEFAULT NULL COMMENT 'links this basket to the aqcontract table (aqcontract.contractnumber)',
324   `creationdate` date DEFAULT NULL COMMENT 'the date the basket was created',
325   `closedate` date DEFAULT NULL COMMENT 'the date the basket was closed',
326   `booksellerid` int(11) NOT NULL DEFAULT 1 COMMENT 'the Koha assigned ID for the vendor (aqbooksellers.id)',
327   `authorisedby` varchar(10) DEFAULT NULL COMMENT 'the borrowernumber of the person who created the basket',
328   `booksellerinvoicenumber` longtext DEFAULT NULL COMMENT 'appears to always be NULL',
329   `basketgroupid` int(11) DEFAULT NULL COMMENT 'links this basket to its group (aqbasketgroups.id)',
330   `deliveryplace` varchar(10) DEFAULT NULL COMMENT 'basket delivery place',
331   `billingplace` varchar(10) DEFAULT NULL COMMENT 'basket billing place',
332   `branch` varchar(10) DEFAULT NULL COMMENT 'basket branch',
333   `is_standing` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'orders in this basket are standing',
334   `create_items` enum('ordering','receiving','cataloguing') DEFAULT NULL COMMENT 'when items should be created for orders in this basket',
335   PRIMARY KEY (`basketno`),
336   KEY `booksellerid` (`booksellerid`),
337   KEY `basketgroupid` (`basketgroupid`),
338   KEY `contractnumber` (`contractnumber`),
339   KEY `authorisedby` (`authorisedby`),
340   KEY `aqbasket_ibfk_4` (`branch`),
341   CONSTRAINT `aqbasket_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE,
342   CONSTRAINT `aqbasket_ibfk_2` FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`),
343   CONSTRAINT `aqbasket_ibfk_3` FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE,
344   CONSTRAINT `aqbasket_ibfk_4` FOREIGN KEY (`branch`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
345 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
346 /*!40101 SET character_set_client = @saved_cs_client */;
347
348 --
349 -- Table structure for table `aqbasketgroups`
350 --
351
352 DROP TABLE IF EXISTS `aqbasketgroups`;
353 /*!40101 SET @saved_cs_client     = @@character_set_client */;
354 /*!40101 SET character_set_client = utf8 */;
355 CREATE TABLE `aqbasketgroups` (
356   `id` int(11) NOT NULL AUTO_INCREMENT,
357   `name` varchar(50) DEFAULT NULL,
358   `closed` tinyint(1) DEFAULT NULL,
359   `booksellerid` int(11) NOT NULL,
360   `deliveryplace` varchar(10) DEFAULT NULL,
361   `freedeliveryplace` mediumtext DEFAULT NULL,
362   `deliverycomment` varchar(255) DEFAULT NULL,
363   `billingplace` varchar(10) DEFAULT NULL,
364   PRIMARY KEY (`id`),
365   KEY `booksellerid` (`booksellerid`),
366   CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
367 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
368 /*!40101 SET character_set_client = @saved_cs_client */;
369
370 --
371 -- Table structure for table `aqbasketusers`
372 --
373
374 DROP TABLE IF EXISTS `aqbasketusers`;
375 /*!40101 SET @saved_cs_client     = @@character_set_client */;
376 /*!40101 SET character_set_client = utf8 */;
377 CREATE TABLE `aqbasketusers` (
378   `basketno` int(11) NOT NULL,
379   `borrowernumber` int(11) NOT NULL,
380   PRIMARY KEY (`basketno`,`borrowernumber`),
381   KEY `aqbasketusers_ibfk_2` (`borrowernumber`),
382   CONSTRAINT `aqbasketusers_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
383   CONSTRAINT `aqbasketusers_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
384 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
385 /*!40101 SET character_set_client = @saved_cs_client */;
386
387 --
388 -- Table structure for table `aqbooksellers`
389 --
390
391 DROP TABLE IF EXISTS `aqbooksellers`;
392 /*!40101 SET @saved_cs_client     = @@character_set_client */;
393 /*!40101 SET character_set_client = utf8 */;
394 CREATE TABLE `aqbooksellers` (
395   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique identifier assigned by Koha',
396   `name` longtext NOT NULL COMMENT 'vendor name',
397   `address1` longtext DEFAULT NULL COMMENT 'first line of vendor physical address',
398   `address2` longtext DEFAULT NULL COMMENT 'second line of vendor physical address',
399   `address3` longtext DEFAULT NULL COMMENT 'third line of vendor physical address',
400   `address4` longtext DEFAULT NULL COMMENT 'fourth line of vendor physical address',
401   `phone` varchar(30) DEFAULT NULL COMMENT 'vendor phone number',
402   `accountnumber` longtext DEFAULT NULL COMMENT 'vendor account number',
403   `type` varchar(255) DEFAULT NULL,
404   `notes` longtext DEFAULT NULL COMMENT 'order notes',
405   `postal` longtext DEFAULT NULL COMMENT 'vendor postal address (all lines)',
406   `url` varchar(255) DEFAULT NULL COMMENT 'vendor web address',
407   `active` tinyint(4) DEFAULT NULL COMMENT 'is this vendor active (1 for yes, 0 for no)',
408   `listprice` varchar(10) DEFAULT NULL COMMENT 'currency code for list prices',
409   `invoiceprice` varchar(10) DEFAULT NULL COMMENT 'currency code for invoice prices',
410   `gstreg` tinyint(4) DEFAULT NULL COMMENT 'is your library charged tax (1 for yes, 0 for no)',
411   `listincgst` tinyint(4) DEFAULT NULL COMMENT 'is tax included in list prices (1 for yes, 0 for no)',
412   `invoiceincgst` tinyint(4) DEFAULT NULL COMMENT 'is tax included in invoice prices (1 for yes, 0 for no)',
413   `tax_rate` decimal(6,4) DEFAULT NULL COMMENT 'the tax rate the library is charged',
414   `discount` float(6,4) DEFAULT NULL COMMENT 'discount offered on all items ordered from this vendor',
415   `fax` varchar(50) DEFAULT NULL COMMENT 'vendor fax number',
416   `deliverytime` int(11) DEFAULT NULL COMMENT 'vendor delivery time',
417   `external_id` varchar(255) DEFAULT NULL COMMENT 'external id of the vendor',
418   PRIMARY KEY (`id`),
419   KEY `listprice` (`listprice`),
420   KEY `invoiceprice` (`invoiceprice`),
421   KEY `name` (`name`(191)),
422   CONSTRAINT `aqbooksellers_ibfk_1` FOREIGN KEY (`listprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE,
423   CONSTRAINT `aqbooksellers_ibfk_2` FOREIGN KEY (`invoiceprice`) REFERENCES `currency` (`currency`) ON DELETE CASCADE ON UPDATE CASCADE
424 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
425 /*!40101 SET character_set_client = @saved_cs_client */;
426
427 --
428 -- Table structure for table `aqbudgetborrowers`
429 --
430
431 DROP TABLE IF EXISTS `aqbudgetborrowers`;
432 /*!40101 SET @saved_cs_client     = @@character_set_client */;
433 /*!40101 SET character_set_client = utf8 */;
434 CREATE TABLE `aqbudgetborrowers` (
435   `budget_id` int(11) NOT NULL,
436   `borrowernumber` int(11) NOT NULL,
437   PRIMARY KEY (`budget_id`,`borrowernumber`),
438   KEY `aqbudgetborrowers_ibfk_2` (`borrowernumber`),
439   CONSTRAINT `aqbudgetborrowers_ibfk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
440   CONSTRAINT `aqbudgetborrowers_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
442 /*!40101 SET character_set_client = @saved_cs_client */;
443
444 --
445 -- Table structure for table `aqbudgetperiods`
446 --
447
448 DROP TABLE IF EXISTS `aqbudgetperiods`;
449 /*!40101 SET @saved_cs_client     = @@character_set_client */;
450 /*!40101 SET character_set_client = utf8 */;
451 CREATE TABLE `aqbudgetperiods` (
452   `budget_period_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique number assigned by Koha',
453   `budget_period_startdate` date NOT NULL COMMENT 'date when the budget starts',
454   `budget_period_enddate` date NOT NULL COMMENT 'date when the budget ends',
455   `budget_period_active` tinyint(1) DEFAULT 0 COMMENT 'whether this budget is active or not (1 for yes, 0 for no)',
456   `budget_period_description` longtext DEFAULT NULL COMMENT 'description assigned to this budget',
457   `budget_period_total` decimal(28,6) DEFAULT NULL COMMENT 'total amount available in this budget',
458   `budget_period_locked` tinyint(1) DEFAULT NULL COMMENT 'whether this budget is locked or not (1 for yes, 0 for no)',
459   `sort1_authcat` varchar(10) DEFAULT NULL COMMENT 'statistical category for this budget',
460   `sort2_authcat` varchar(10) DEFAULT NULL COMMENT 'second statistical category for this budget',
461   PRIMARY KEY (`budget_period_id`)
462 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
463 /*!40101 SET character_set_client = @saved_cs_client */;
464
465 --
466 -- Table structure for table `aqbudgets`
467 --
468
469 DROP TABLE IF EXISTS `aqbudgets`;
470 /*!40101 SET @saved_cs_client     = @@character_set_client */;
471 /*!40101 SET character_set_client = utf8 */;
472 CREATE TABLE `aqbudgets` (
473   `budget_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique number assigned to each fund by Koha',
474   `budget_parent_id` int(11) DEFAULT NULL COMMENT 'if this fund is a child of another this will include the parent id (aqbudgets.budget_id)',
475   `budget_code` varchar(30) DEFAULT NULL COMMENT 'code assigned to the fund by the user',
476   `budget_name` varchar(80) DEFAULT NULL COMMENT 'name assigned to the fund by the user',
477   `budget_branchcode` varchar(10) DEFAULT NULL COMMENT 'branch that this fund belongs to (branches.branchcode)',
478   `budget_amount` decimal(28,6) DEFAULT 0.000000 COMMENT 'total amount for this fund',
479   `budget_encumb` decimal(28,6) DEFAULT 0.000000 COMMENT 'budget warning at percentage',
480   `budget_expend` decimal(28,6) DEFAULT 0.000000 COMMENT 'budget warning at amount',
481   `budget_notes` longtext DEFAULT NULL COMMENT 'notes related to this fund',
482   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this fund was last touched (created or modified)',
483   `budget_period_id` int(11) DEFAULT NULL COMMENT 'id of the budget that this fund belongs to (aqbudgetperiods.budget_period_id)',
484   `sort1_authcat` varchar(80) DEFAULT NULL COMMENT 'statistical category for this fund',
485   `sort2_authcat` varchar(80) DEFAULT NULL COMMENT 'second statistical category for this fund',
486   `budget_owner_id` int(11) DEFAULT NULL COMMENT 'borrowernumber of the person who owns this fund (borrowers.borrowernumber)',
487   `budget_permission` int(1) DEFAULT 0 COMMENT 'level of permission for this fund (used only by the owner, only by the library, or anyone)',
488   PRIMARY KEY (`budget_id`),
489   KEY `budget_parent_id` (`budget_parent_id`),
490   KEY `budget_code` (`budget_code`),
491   KEY `budget_branchcode` (`budget_branchcode`),
492   KEY `budget_period_id` (`budget_period_id`),
493   KEY `budget_owner_id` (`budget_owner_id`),
494   CONSTRAINT `aqbudgetperiods_ibfk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
495 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
496 /*!40101 SET character_set_client = @saved_cs_client */;
497
498 --
499 -- Table structure for table `aqbudgets_planning`
500 --
501
502 DROP TABLE IF EXISTS `aqbudgets_planning`;
503 /*!40101 SET @saved_cs_client     = @@character_set_client */;
504 /*!40101 SET character_set_client = utf8 */;
505 CREATE TABLE `aqbudgets_planning` (
506   `plan_id` int(11) NOT NULL AUTO_INCREMENT,
507   `budget_id` int(11) NOT NULL,
508   `budget_period_id` int(11) NOT NULL,
509   `estimated_amount` decimal(28,6) DEFAULT NULL,
510   `authcat` varchar(30) NOT NULL,
511   `authvalue` varchar(30) NOT NULL,
512   `display` tinyint(1) DEFAULT 1,
513   PRIMARY KEY (`plan_id`),
514   KEY `budget_period_id` (`budget_period_id`),
515   KEY `aqbudgets_planning_ifbk_1` (`budget_id`),
516   CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
517 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
518 /*!40101 SET character_set_client = @saved_cs_client */;
519
520 --
521 -- Table structure for table `aqcontacts`
522 --
523
524 DROP TABLE IF EXISTS `aqcontacts`;
525 /*!40101 SET @saved_cs_client     = @@character_set_client */;
526 /*!40101 SET character_set_client = utf8 */;
527 CREATE TABLE `aqcontacts` (
528   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique number assigned by Koha',
529   `name` varchar(100) DEFAULT NULL COMMENT 'name of contact at vendor',
530   `position` varchar(100) DEFAULT NULL COMMENT 'contact person''s position',
531   `phone` varchar(100) DEFAULT NULL COMMENT 'contact''s phone number',
532   `altphone` varchar(100) DEFAULT NULL COMMENT 'contact''s alternate phone number',
533   `fax` varchar(100) DEFAULT NULL COMMENT 'contact''s fax number',
534   `email` varchar(100) DEFAULT NULL COMMENT 'contact''s email address',
535   `notes` longtext DEFAULT NULL COMMENT 'notes related to the contact',
536   `orderacquisition` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'should this contact receive acquisition orders',
537   `claimacquisition` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'should this contact receive acquisitions claims',
538   `claimissues` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'should this contact receive serial claims',
539   `acqprimary` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is this the primary contact for acquisitions messages',
540   `serialsprimary` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is this the primary contact for serials messages',
541   `booksellerid` int(11) NOT NULL,
542   PRIMARY KEY (`id`),
543   KEY `booksellerid_aqcontacts_fk` (`booksellerid`),
544   CONSTRAINT `booksellerid_aqcontacts_fk` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
545 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
546 /*!40101 SET character_set_client = @saved_cs_client */;
547
548 --
549 -- Table structure for table `aqcontract`
550 --
551
552 DROP TABLE IF EXISTS `aqcontract`;
553 /*!40101 SET @saved_cs_client     = @@character_set_client */;
554 /*!40101 SET character_set_client = utf8 */;
555 CREATE TABLE `aqcontract` (
556   `contractnumber` int(11) NOT NULL AUTO_INCREMENT,
557   `contractstartdate` date DEFAULT NULL,
558   `contractenddate` date DEFAULT NULL,
559   `contractname` varchar(50) DEFAULT NULL,
560   `contractdescription` longtext DEFAULT NULL,
561   `booksellerid` int(11) NOT NULL,
562   PRIMARY KEY (`contractnumber`),
563   KEY `booksellerid_fk1` (`booksellerid`),
564   CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
565 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
566 /*!40101 SET character_set_client = @saved_cs_client */;
567
568 --
569 -- Table structure for table `aqinvoice_adjustments`
570 --
571
572 DROP TABLE IF EXISTS `aqinvoice_adjustments`;
573 /*!40101 SET @saved_cs_client     = @@character_set_client */;
574 /*!40101 SET character_set_client = utf8 */;
575 CREATE TABLE `aqinvoice_adjustments` (
576   `adjustment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key for adjustments',
577   `invoiceid` int(11) NOT NULL COMMENT 'foreign key to link an adjustment to an invoice',
578   `adjustment` decimal(28,6) DEFAULT NULL COMMENT 'amount of adjustment',
579   `reason` varchar(80) DEFAULT NULL COMMENT 'reason for adjustment defined by authorised values in ADJ_REASON category',
580   `note` mediumtext DEFAULT NULL COMMENT 'text to explain adjustment',
581   `budget_id` int(11) DEFAULT NULL COMMENT 'optional link to budget to apply adjustment to',
582   `encumber_open` smallint(1) NOT NULL DEFAULT 1 COMMENT 'whether or not to encumber the funds when invoice is still open, 1 = yes, 0 = no',
583   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'timestamp  of last adjustment to adjustment',
584   PRIMARY KEY (`adjustment_id`),
585   KEY `aqinvoice_adjustments_fk_invoiceid` (`invoiceid`),
586   KEY `aqinvoice_adjustments_fk_budget_id` (`budget_id`),
587   CONSTRAINT `aqinvoice_adjustments_fk_budget_id` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE,
588   CONSTRAINT `aqinvoice_adjustments_fk_invoiceid` FOREIGN KEY (`invoiceid`) REFERENCES `aqinvoices` (`invoiceid`) ON DELETE CASCADE ON UPDATE CASCADE
589 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
590 /*!40101 SET character_set_client = @saved_cs_client */;
591
592 --
593 -- Table structure for table `aqinvoices`
594 --
595
596 DROP TABLE IF EXISTS `aqinvoices`;
597 /*!40101 SET @saved_cs_client     = @@character_set_client */;
598 /*!40101 SET character_set_client = utf8 */;
599 CREATE TABLE `aqinvoices` (
600   `invoiceid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID of the invoice, primary key',
601   `invoicenumber` longtext NOT NULL COMMENT 'Name of invoice',
602   `booksellerid` int(11) NOT NULL COMMENT 'foreign key to aqbooksellers',
603   `shipmentdate` date DEFAULT NULL COMMENT 'date of shipment',
604   `billingdate` date DEFAULT NULL COMMENT 'date of billing',
605   `closedate` date DEFAULT NULL COMMENT 'invoice close date, NULL means the invoice is open',
606   `shipmentcost` decimal(28,6) DEFAULT NULL COMMENT 'shipment cost',
607   `shipmentcost_budgetid` int(11) DEFAULT NULL COMMENT 'foreign key to aqbudgets, link the shipment cost to a budget',
608   `message_id` int(11) DEFAULT NULL COMMENT 'foreign key to edifact invoice message',
609   PRIMARY KEY (`invoiceid`),
610   KEY `aqinvoices_fk_aqbooksellerid` (`booksellerid`),
611   KEY `edifact_msg_fk` (`message_id`),
612   KEY `aqinvoices_fk_shipmentcost_budgetid` (`shipmentcost_budgetid`),
613   CONSTRAINT `aqinvoices_fk_aqbooksellerid` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
614   CONSTRAINT `aqinvoices_fk_shipmentcost_budgetid` FOREIGN KEY (`shipmentcost_budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE,
615   CONSTRAINT `edifact_msg_fk` FOREIGN KEY (`message_id`) REFERENCES `edifact_messages` (`id`) ON DELETE SET NULL
616 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
617 /*!40101 SET character_set_client = @saved_cs_client */;
618
619 --
620 -- Table structure for table `aqorder_users`
621 --
622
623 DROP TABLE IF EXISTS `aqorder_users`;
624 /*!40101 SET @saved_cs_client     = @@character_set_client */;
625 /*!40101 SET character_set_client = utf8 */;
626 CREATE TABLE `aqorder_users` (
627   `ordernumber` int(11) NOT NULL COMMENT 'the order this patrons receive notifications from (aqorders.ordernumber)',
628   `borrowernumber` int(11) NOT NULL COMMENT 'the borrowernumber for the patron receiving notifications for this order (borrowers.borrowernumber)',
629   PRIMARY KEY (`ordernumber`,`borrowernumber`),
630   KEY `aqorder_users_ibfk_2` (`borrowernumber`),
631   CONSTRAINT `aqorder_users_ibfk_1` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
632   CONSTRAINT `aqorder_users_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
633 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
634 /*!40101 SET character_set_client = @saved_cs_client */;
635
636 --
637 -- Table structure for table `aqorders`
638 --
639
640 DROP TABLE IF EXISTS `aqorders`;
641 /*!40101 SET @saved_cs_client     = @@character_set_client */;
642 /*!40101 SET character_set_client = utf8 */;
643 CREATE TABLE `aqorders` (
644   `ordernumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique identifier assigned by Koha to each line',
645   `biblionumber` int(11) DEFAULT NULL COMMENT 'links the order to the biblio being ordered (biblio.biblionumber)',
646   `entrydate` date DEFAULT NULL COMMENT 'the date the bib was added to the basket',
647   `quantity` smallint(6) DEFAULT NULL COMMENT 'the quantity ordered',
648   `currency` varchar(10) DEFAULT NULL COMMENT 'the currency used for the purchase',
649   `listprice` decimal(28,6) DEFAULT NULL COMMENT 'the vendor price for this line item',
650   `datereceived` date DEFAULT NULL COMMENT 'the date this order was received',
651   `invoiceid` int(11) DEFAULT NULL COMMENT 'id of invoice',
652   `freight` decimal(28,6) DEFAULT NULL COMMENT 'shipping costs (not used)',
653   `unitprice` decimal(28,6) DEFAULT NULL COMMENT 'the actual cost entered when receiving this line item',
654   `unitprice_tax_excluded` decimal(28,6) DEFAULT NULL COMMENT 'the unit price excluding tax (on receiving)',
655   `unitprice_tax_included` decimal(28,6) DEFAULT NULL COMMENT 'the unit price including tax (on receiving)',
656   `quantityreceived` smallint(6) NOT NULL DEFAULT 0 COMMENT 'the quantity that have been received so far',
657   `created_by` int(11) DEFAULT NULL COMMENT 'the borrowernumber of order line''s creator',
658   `datecancellationprinted` date DEFAULT NULL COMMENT 'the date the line item was deleted',
659   `cancellationreason` mediumtext DEFAULT NULL COMMENT 'reason of cancellation',
660   `order_internalnote` longtext DEFAULT NULL COMMENT 'notes related to this order line, made for staff',
661   `order_vendornote` longtext DEFAULT NULL COMMENT 'notes related to this order line, made for vendor',
662   `purchaseordernumber` longtext DEFAULT NULL COMMENT 'not used? always NULL',
663   `basketno` int(11) DEFAULT NULL COMMENT 'links this order line to a specific basket (aqbasket.basketno)',
664   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this order line was last modified',
665   `rrp` decimal(13,2) DEFAULT NULL COMMENT 'the retail cost for this line item',
666   `replacementprice` decimal(28,6) DEFAULT NULL COMMENT 'the replacement cost for this line item',
667   `rrp_tax_excluded` decimal(28,6) DEFAULT NULL COMMENT 'the replacement cost excluding tax',
668   `rrp_tax_included` decimal(28,6) DEFAULT NULL COMMENT 'the replacement cost including tax',
669   `ecost` decimal(13,2) DEFAULT NULL COMMENT 'the replacement cost for this line item',
670   `ecost_tax_excluded` decimal(28,6) DEFAULT NULL COMMENT 'the estimated cost excluding tax',
671   `ecost_tax_included` decimal(28,6) DEFAULT NULL COMMENT 'the estimated cost including tax',
672   `tax_rate_bak` decimal(6,4) DEFAULT NULL COMMENT 'the tax rate for this line item (%)',
673   `tax_rate_on_ordering` decimal(6,4) DEFAULT NULL COMMENT 'the tax rate on ordering for this line item (%)',
674   `tax_rate_on_receiving` decimal(6,4) DEFAULT NULL COMMENT 'the tax rate on receiving for this line item (%)',
675   `tax_value_bak` decimal(28,6) DEFAULT NULL COMMENT 'the tax value for this line item',
676   `tax_value_on_ordering` decimal(28,6) DEFAULT NULL COMMENT 'the tax value on ordering for this line item',
677   `tax_value_on_receiving` decimal(28,6) DEFAULT NULL COMMENT 'the tax value on receiving for this line item',
678   `discount` float(6,4) DEFAULT NULL COMMENT 'the discount for this line item (%)',
679   `budget_id` int(11) NOT NULL COMMENT 'the fund this order goes against (aqbudgets.budget_id)',
680   `budgetdate` date DEFAULT NULL COMMENT 'not used? always NULL',
681   `sort1` varchar(80) DEFAULT NULL COMMENT 'statistical field',
682   `sort2` varchar(80) DEFAULT NULL COMMENT 'second statistical field',
683   `sort1_authcat` varchar(10) DEFAULT NULL,
684   `sort2_authcat` varchar(10) DEFAULT NULL,
685   `uncertainprice` tinyint(1) DEFAULT NULL COMMENT 'was this price uncertain (1 for yes, 0 for no)',
686   `subscriptionid` int(11) DEFAULT NULL COMMENT 'links this order line to a subscription (subscription.subscriptionid)',
687   `parent_ordernumber` int(11) DEFAULT NULL COMMENT 'ordernumber of parent order line, or same as ordernumber if no parent',
688   `orderstatus` varchar(16) DEFAULT 'new' COMMENT 'the current status for this line item. Can be ''new'', ''ordered'', ''partial'', ''complete'' or ''cancelled''',
689   `line_item_id` varchar(35) DEFAULT NULL COMMENT 'Supplier''s article id for Edifact orderline',
690   `suppliers_reference_number` varchar(35) DEFAULT NULL COMMENT 'Suppliers unique edifact quote ref',
691   `suppliers_reference_qualifier` varchar(3) DEFAULT NULL COMMENT 'Type of number above usually ''QLI''',
692   `suppliers_report` mediumtext DEFAULT NULL COMMENT 'reports received from suppliers',
693   `estimated_delivery_date` date DEFAULT NULL COMMENT 'Estimated delivery date',
694   `invoice_unitprice` decimal(28,6) DEFAULT NULL COMMENT 'the unit price in foreign currency',
695   `invoice_currency` varchar(10) DEFAULT NULL COMMENT 'the currency of the invoice_unitprice',
696   PRIMARY KEY (`ordernumber`),
697   KEY `basketno` (`basketno`),
698   KEY `biblionumber` (`biblionumber`),
699   KEY `budget_id` (`budget_id`),
700   KEY `parent_ordernumber` (`parent_ordernumber`),
701   KEY `orderstatus` (`orderstatus`),
702   KEY `aqorders_created_by` (`created_by`),
703   KEY `aqorders_ibfk_3` (`invoiceid`),
704   KEY `aqorders_subscriptionid` (`subscriptionid`),
705   KEY `aqorders_currency` (`currency`),
706   CONSTRAINT `aqorders_budget_id_fk` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
707   CONSTRAINT `aqorders_created_by` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
708   CONSTRAINT `aqorders_currency` FOREIGN KEY (`currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL,
709   CONSTRAINT `aqorders_invoice_currency` FOREIGN KEY (`invoice_currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL,
710   CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
711   CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
712   CONSTRAINT `aqorders_ibfk_3` FOREIGN KEY (`invoiceid`) REFERENCES `aqinvoices` (`invoiceid`) ON DELETE SET NULL ON UPDATE CASCADE,
713   CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
714 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
715 /*!40101 SET character_set_client = @saved_cs_client */;
716
717 --
718 -- Table structure for table `aqorders_claims`
719 --
720
721 DROP TABLE IF EXISTS `aqorders_claims`;
722 /*!40101 SET @saved_cs_client     = @@character_set_client */;
723 /*!40101 SET character_set_client = utf8 */;
724 CREATE TABLE `aqorders_claims` (
725   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID of the claims',
726   `ordernumber` int(11) NOT NULL COMMENT 'order linked to this claim',
727   `claimed_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date of the claims',
728   PRIMARY KEY (`id`),
729   KEY `aqorders_claims_ibfk_1` (`ordernumber`),
730   CONSTRAINT `aqorders_claims_ibfk_1` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE CASCADE ON UPDATE CASCADE
731 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
732 /*!40101 SET character_set_client = @saved_cs_client */;
733
734 --
735 -- Table structure for table `aqorders_items`
736 --
737
738 DROP TABLE IF EXISTS `aqorders_items`;
739 /*!40101 SET @saved_cs_client     = @@character_set_client */;
740 /*!40101 SET character_set_client = utf8 */;
741 CREATE TABLE `aqorders_items` (
742   `ordernumber` int(11) NOT NULL COMMENT 'the order this item is attached to (aqorders.ordernumber)',
743   `itemnumber` int(11) NOT NULL COMMENT 'the item number for this item (items.itemnumber)',
744   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this order item was last touched',
745   PRIMARY KEY (`itemnumber`),
746   KEY `ordernumber` (`ordernumber`),
747   CONSTRAINT `aqorders_items_ibfk_1` FOREIGN KEY (`ordernumber`) REFERENCES `aqorders` (`ordernumber`) ON DELETE CASCADE ON UPDATE CASCADE
748 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
749 /*!40101 SET character_set_client = @saved_cs_client */;
750
751 --
752 -- Table structure for table `aqorders_transfers`
753 --
754
755 DROP TABLE IF EXISTS `aqorders_transfers`;
756 /*!40101 SET @saved_cs_client     = @@character_set_client */;
757 /*!40101 SET character_set_client = utf8 */;
758 CREATE TABLE `aqorders_transfers` (
759   `ordernumber_from` int(11) DEFAULT NULL,
760   `ordernumber_to` int(11) DEFAULT NULL,
761   `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
762   UNIQUE KEY `ordernumber_from` (`ordernumber_from`),
763   UNIQUE KEY `ordernumber_to` (`ordernumber_to`),
764   CONSTRAINT `aqorders_transfers_ordernumber_from` FOREIGN KEY (`ordernumber_from`) REFERENCES `aqorders` (`ordernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
765   CONSTRAINT `aqorders_transfers_ordernumber_to` FOREIGN KEY (`ordernumber_to`) REFERENCES `aqorders` (`ordernumber`) ON DELETE SET NULL ON UPDATE CASCADE
766 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
767 /*!40101 SET character_set_client = @saved_cs_client */;
768
769 --
770 -- Table structure for table `article_requests`
771 --
772
773 DROP TABLE IF EXISTS `article_requests`;
774 /*!40101 SET @saved_cs_client     = @@character_set_client */;
775 /*!40101 SET character_set_client = utf8 */;
776 CREATE TABLE `article_requests` (
777   `id` int(11) NOT NULL AUTO_INCREMENT,
778   `borrowernumber` int(11) NOT NULL,
779   `biblionumber` int(11) NOT NULL,
780   `itemnumber` int(11) DEFAULT NULL,
781   `branchcode` varchar(10) DEFAULT NULL,
782   `title` mediumtext DEFAULT NULL,
783   `author` mediumtext DEFAULT NULL,
784   `volume` mediumtext DEFAULT NULL,
785   `issue` mediumtext DEFAULT NULL,
786   `date` mediumtext DEFAULT NULL,
787   `pages` mediumtext DEFAULT NULL,
788   `chapters` mediumtext DEFAULT NULL,
789   `patron_notes` mediumtext DEFAULT NULL,
790   `status` enum('REQUESTED','PENDING','PROCESSING','COMPLETED','CANCELED') NOT NULL DEFAULT 'REQUESTED',
791   `notes` mediumtext DEFAULT NULL,
792   `format` enum('PHOTOCOPY','SCAN') NOT NULL DEFAULT 'PHOTOCOPY',
793   `urls` mediumtext DEFAULT NULL,
794   `cancellation_reason` varchar(80) DEFAULT NULL COMMENT 'optional authorised value AR_CANCELLATION',
795   `debit_id` int(11) DEFAULT NULL COMMENT 'Debit line with cost for article scan request',
796   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Be careful with two timestamps in one table not allowing NULL',
797   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
798   `toc_request` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'borrower requested table of contents',
799   PRIMARY KEY (`id`),
800   KEY `borrowernumber` (`borrowernumber`),
801   KEY `biblionumber` (`biblionumber`),
802   KEY `itemnumber` (`itemnumber`),
803   KEY `branchcode` (`branchcode`),
804   KEY `debit_id` (`debit_id`),
805   CONSTRAINT `article_requests_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
806   CONSTRAINT `article_requests_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
807   CONSTRAINT `article_requests_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
808   CONSTRAINT `article_requests_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
809   CONSTRAINT `article_requests_ibfk_5` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE SET NULL ON UPDATE CASCADE
810 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
811 /*!40101 SET character_set_client = @saved_cs_client */;
812
813 --
814 -- Table structure for table `audio_alerts`
815 --
816
817 DROP TABLE IF EXISTS `audio_alerts`;
818 /*!40101 SET @saved_cs_client     = @@character_set_client */;
819 /*!40101 SET character_set_client = utf8 */;
820 CREATE TABLE `audio_alerts` (
821   `id` int(11) NOT NULL AUTO_INCREMENT,
822   `precedence` smallint(5) unsigned NOT NULL,
823   `selector` varchar(255) NOT NULL,
824   `sound` varchar(255) NOT NULL,
825   PRIMARY KEY (`id`),
826   KEY `precedence` (`precedence`)
827 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
828 /*!40101 SET character_set_client = @saved_cs_client */;
829
830 --
831 -- Table structure for table `auth_header`
832 --
833
834 DROP TABLE IF EXISTS `auth_header`;
835 /*!40101 SET @saved_cs_client     = @@character_set_client */;
836 /*!40101 SET character_set_client = utf8 */;
837 CREATE TABLE `auth_header` (
838   `authid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
839   `authtypecode` varchar(10) NOT NULL DEFAULT '',
840   `datecreated` date DEFAULT NULL,
841   `modification_time` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
842   `origincode` varchar(20) DEFAULT NULL,
843   `authtrees` longtext DEFAULT NULL,
844   `marc` blob DEFAULT NULL,
845   `linkid` bigint(20) DEFAULT NULL,
846   `marcxml` longtext NOT NULL,
847   PRIMARY KEY (`authid`),
848   KEY `origincode` (`origincode`)
849 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
850 /*!40101 SET character_set_client = @saved_cs_client */;
851
852 --
853 -- Table structure for table `auth_subfield_structure`
854 --
855
856 DROP TABLE IF EXISTS `auth_subfield_structure`;
857 /*!40101 SET @saved_cs_client     = @@character_set_client */;
858 /*!40101 SET character_set_client = utf8 */;
859 CREATE TABLE `auth_subfield_structure` (
860   `authtypecode` varchar(10) NOT NULL DEFAULT '',
861   `tagfield` varchar(3) NOT NULL DEFAULT '',
862   `tagsubfield` varchar(1) NOT NULL DEFAULT '',
863   `liblibrarian` varchar(255) NOT NULL DEFAULT '',
864   `libopac` varchar(255) NOT NULL DEFAULT '',
865   `repeatable` tinyint(4) NOT NULL DEFAULT 0,
866   `mandatory` tinyint(4) NOT NULL DEFAULT 0,
867   `tab` tinyint(1) DEFAULT NULL,
868   `authorised_value` varchar(32) DEFAULT NULL,
869   `value_builder` varchar(80) DEFAULT NULL,
870   `seealso` varchar(255) DEFAULT NULL,
871   `isurl` tinyint(1) DEFAULT NULL,
872   `hidden` tinyint(3) NOT NULL DEFAULT 0,
873   `linkid` tinyint(1) NOT NULL DEFAULT 0,
874   `kohafield` varchar(45) DEFAULT '',
875   `frameworkcode` varchar(10) NOT NULL DEFAULT '',
876   `defaultvalue` mediumtext DEFAULT NULL,
877   `display_order` int(2) NOT NULL DEFAULT 0,
878   PRIMARY KEY (`authtypecode`,`tagfield`,`tagsubfield`),
879   KEY `tab` (`authtypecode`,`tab`),
880   CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
881 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
882 /*!40101 SET character_set_client = @saved_cs_client */;
883
884 --
885 -- Table structure for table `auth_tag_structure`
886 --
887
888 DROP TABLE IF EXISTS `auth_tag_structure`;
889 /*!40101 SET @saved_cs_client     = @@character_set_client */;
890 /*!40101 SET character_set_client = utf8 */;
891 CREATE TABLE `auth_tag_structure` (
892   `authtypecode` varchar(10) NOT NULL DEFAULT '',
893   `tagfield` varchar(3) NOT NULL DEFAULT '',
894   `liblibrarian` varchar(255) NOT NULL DEFAULT '',
895   `libopac` varchar(255) NOT NULL DEFAULT '',
896   `repeatable` tinyint(4) NOT NULL DEFAULT 0,
897   `mandatory` tinyint(4) NOT NULL DEFAULT 0,
898   `authorised_value` varchar(32) DEFAULT NULL,
899   PRIMARY KEY (`authtypecode`,`tagfield`),
900   CONSTRAINT `auth_tag_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
901 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
902 /*!40101 SET character_set_client = @saved_cs_client */;
903
904 --
905 -- Table structure for table `auth_types`
906 --
907
908 DROP TABLE IF EXISTS `auth_types`;
909 /*!40101 SET @saved_cs_client     = @@character_set_client */;
910 /*!40101 SET character_set_client = utf8 */;
911 CREATE TABLE `auth_types` (
912   `authtypecode` varchar(10) NOT NULL DEFAULT '',
913   `authtypetext` varchar(255) NOT NULL DEFAULT '',
914   `auth_tag_to_report` varchar(3) NOT NULL DEFAULT '',
915   `summary` longtext NOT NULL,
916   PRIMARY KEY (`authtypecode`)
917 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
918 /*!40101 SET character_set_client = @saved_cs_client */;
919
920 --
921 -- Table structure for table `authorised_value_categories`
922 --
923
924 DROP TABLE IF EXISTS `authorised_value_categories`;
925 /*!40101 SET @saved_cs_client     = @@character_set_client */;
926 /*!40101 SET character_set_client = utf8 */;
927 CREATE TABLE `authorised_value_categories` (
928   `category_name` varchar(32) NOT NULL DEFAULT '',
929   `is_system` tinyint(1) DEFAULT 0,
930   PRIMARY KEY (`category_name`)
931 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
932 /*!40101 SET character_set_client = @saved_cs_client */;
933
934 --
935 -- Table structure for table `authorised_values`
936 --
937
938 DROP TABLE IF EXISTS `authorised_values`;
939 /*!40101 SET @saved_cs_client     = @@character_set_client */;
940 /*!40101 SET character_set_client = utf8 */;
941 CREATE TABLE `authorised_values` (
942   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify the authorized value',
943   `category` varchar(32) NOT NULL DEFAULT '' COMMENT 'key used to identify the authorized value category',
944   `authorised_value` varchar(80) NOT NULL DEFAULT '' COMMENT 'code use to identify the authorized value',
945   `lib` varchar(200) DEFAULT NULL COMMENT 'authorized value description as printed in the staff interface',
946   `lib_opac` varchar(200) DEFAULT NULL COMMENT 'authorized value description as printed in the OPAC',
947   `imageurl` varchar(200) DEFAULT NULL COMMENT 'authorized value URL',
948   PRIMARY KEY (`id`),
949   UNIQUE KEY `av_uniq` (`category`,`authorised_value`),
950   KEY `name` (`category`),
951   KEY `lib` (`lib`(191)),
952   KEY `auth_value_idx` (`authorised_value`),
953   CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE
954 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
955 /*!40101 SET character_set_client = @saved_cs_client */;
956
957 --
958 -- Table structure for table `authorised_values_branches`
959 --
960
961 DROP TABLE IF EXISTS `authorised_values_branches`;
962 /*!40101 SET @saved_cs_client     = @@character_set_client */;
963 /*!40101 SET character_set_client = utf8 */;
964 CREATE TABLE `authorised_values_branches` (
965   `av_id` int(11) NOT NULL,
966   `branchcode` varchar(10) NOT NULL,
967   KEY `av_id` (`av_id`),
968   KEY `branchcode` (`branchcode`),
969   CONSTRAINT `authorised_values_branches_ibfk_1` FOREIGN KEY (`av_id`) REFERENCES `authorised_values` (`id`) ON DELETE CASCADE,
970   CONSTRAINT `authorised_values_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
971 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
972 /*!40101 SET character_set_client = @saved_cs_client */;
973
974 --
975 -- Table structure for table `background_jobs`
976 --
977
978 DROP TABLE IF EXISTS `background_jobs`;
979 /*!40101 SET @saved_cs_client     = @@character_set_client */;
980 /*!40101 SET character_set_client = utf8 */;
981 CREATE TABLE `background_jobs` (
982   `id` int(11) NOT NULL AUTO_INCREMENT,
983   `status` varchar(32) DEFAULT NULL,
984   `progress` int(11) DEFAULT NULL,
985   `size` int(11) DEFAULT NULL,
986   `borrowernumber` int(11) DEFAULT NULL,
987   `type` varchar(64) DEFAULT NULL,
988   `queue` varchar(191) NOT NULL DEFAULT 'default' COMMENT 'Name of the queue the job is sent to',
989   `data` longtext DEFAULT NULL,
990   `context` longtext DEFAULT NULL COMMENT 'JSON-serialized context information for the job',
991   `enqueued_on` datetime DEFAULT NULL,
992   `started_on` datetime DEFAULT NULL,
993   `ended_on` datetime DEFAULT NULL,
994   PRIMARY KEY (`id`),
995   KEY `borrowernumber` (`borrowernumber`),
996   KEY `queue` (`queue`),
997   KEY `status` (`status`)
998 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
999 /*!40101 SET character_set_client = @saved_cs_client */;
1000
1001 --
1002 -- Table structure for table `biblio`
1003 --
1004
1005 DROP TABLE IF EXISTS `biblio`;
1006 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1007 /*!40101 SET character_set_client = utf8 */;
1008 CREATE TABLE `biblio` (
1009   `biblionumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned to each bibliographic record',
1010   `frameworkcode` varchar(4) NOT NULL DEFAULT '' COMMENT 'foreign key from the biblio_framework table to identify which framework was used in cataloging this record',
1011   `author` longtext DEFAULT NULL COMMENT 'statement of responsibility from MARC record (100$a in MARC21)',
1012   `title` longtext DEFAULT NULL COMMENT 'title (without the subtitle) from the MARC record (245$a in MARC21)',
1013   `medium` longtext DEFAULT NULL COMMENT 'medium from the MARC record (245$h in MARC21)',
1014   `subtitle` longtext DEFAULT NULL COMMENT 'remainder of the title from the MARC record (245$b in MARC21)',
1015   `part_number` longtext DEFAULT NULL COMMENT 'part number from the MARC record (245$n in MARC21)',
1016   `part_name` longtext DEFAULT NULL COMMENT 'part name from the MARC record (245$p in MARC21)',
1017   `unititle` longtext DEFAULT NULL COMMENT 'uniform title (without the subtitle) from the MARC record (240$a in MARC21)',
1018   `notes` longtext DEFAULT NULL COMMENT 'values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)',
1019   `serial` tinyint(1) DEFAULT NULL COMMENT 'Boolean indicating whether biblio is for a serial',
1020   `seriestitle` longtext DEFAULT NULL,
1021   `copyrightdate` smallint(6) DEFAULT NULL COMMENT 'publication or copyright date from the MARC record',
1022   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this record was last touched',
1023   `datecreated` date NOT NULL COMMENT 'the date this record was added to Koha',
1024   `abstract` longtext DEFAULT NULL COMMENT 'summary from the MARC record (520$a in MARC21)',
1025   PRIMARY KEY (`biblionumber`),
1026   KEY `blbnoidx` (`biblionumber`)
1027 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1028 /*!40101 SET character_set_client = @saved_cs_client */;
1029
1030 --
1031 -- Table structure for table `biblio_framework`
1032 --
1033
1034 DROP TABLE IF EXISTS `biblio_framework`;
1035 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1036 /*!40101 SET character_set_client = utf8 */;
1037 CREATE TABLE `biblio_framework` (
1038   `frameworkcode` varchar(4) NOT NULL DEFAULT '' COMMENT 'the unique code assigned to the framework',
1039   `frameworktext` varchar(255) NOT NULL DEFAULT '' COMMENT 'the description/name given to the framework',
1040   PRIMARY KEY (`frameworkcode`)
1041 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1042 /*!40101 SET character_set_client = @saved_cs_client */;
1043
1044 --
1045 -- Table structure for table `biblio_metadata`
1046 --
1047
1048 DROP TABLE IF EXISTS `biblio_metadata`;
1049 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1050 /*!40101 SET character_set_client = utf8 */;
1051 CREATE TABLE `biblio_metadata` (
1052   `id` int(11) NOT NULL AUTO_INCREMENT,
1053   `biblionumber` int(11) NOT NULL,
1054   `format` varchar(16) NOT NULL,
1055   `schema` varchar(16) NOT NULL,
1056   `metadata` longtext NOT NULL,
1057   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
1058   PRIMARY KEY (`id`),
1059   UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`schema`),
1060   KEY `timestamp` (`timestamp`),
1061   CONSTRAINT `record_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1062 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1063 /*!40101 SET character_set_client = @saved_cs_client */;
1064
1065 --
1066 -- Table structure for table `biblioitems`
1067 --
1068
1069 DROP TABLE IF EXISTS `biblioitems`;
1070 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1071 /*!40101 SET character_set_client = utf8 */;
1072 CREATE TABLE `biblioitems` (
1073   `biblioitemnumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key, unique identifier assigned by Koha',
1074   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key linking this table to the biblio table',
1075   `volume` longtext DEFAULT NULL,
1076   `number` longtext DEFAULT NULL,
1077   `itemtype` varchar(10) DEFAULT NULL COMMENT 'biblio level item type (MARC21 942$c)',
1078   `isbn` longtext DEFAULT NULL COMMENT 'ISBN (MARC21 020$a)',
1079   `issn` longtext DEFAULT NULL COMMENT 'ISSN (MARC21 022$a)',
1080   `ean` longtext DEFAULT NULL,
1081   `publicationyear` mediumtext DEFAULT NULL,
1082   `publishercode` varchar(255) DEFAULT NULL COMMENT 'publisher (MARC21 260$b)',
1083   `volumedate` date DEFAULT NULL,
1084   `volumedesc` mediumtext DEFAULT NULL COMMENT 'volume information (MARC21 362$a)',
1085   `collectiontitle` longtext DEFAULT NULL,
1086   `collectionissn` mediumtext DEFAULT NULL,
1087   `collectionvolume` longtext DEFAULT NULL,
1088   `editionstatement` mediumtext DEFAULT NULL,
1089   `editionresponsibility` mediumtext DEFAULT NULL,
1090   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
1091   `illus` varchar(255) DEFAULT NULL COMMENT 'illustrations (MARC21 300$b)',
1092   `pages` varchar(255) DEFAULT NULL COMMENT 'number of pages (MARC21 300$c)',
1093   `notes` longtext DEFAULT NULL,
1094   `size` varchar(255) DEFAULT NULL COMMENT 'material size (MARC21 300$c)',
1095   `place` varchar(255) DEFAULT NULL COMMENT 'publication place (MARC21 260$a)',
1096   `lccn` varchar(25) DEFAULT NULL COMMENT 'library of congress control number (MARC21 010$a)',
1097   `url` mediumtext DEFAULT NULL COMMENT 'url (MARC21 856$u)',
1098   `cn_source` varchar(10) DEFAULT NULL COMMENT 'classification source (MARC21 942$2)',
1099   `cn_class` varchar(30) DEFAULT NULL,
1100   `cn_item` varchar(10) DEFAULT NULL,
1101   `cn_suffix` varchar(10) DEFAULT NULL,
1102   `cn_sort` varchar(255) DEFAULT NULL COMMENT 'normalized version of the call number used for sorting',
1103   `agerestriction` varchar(255) DEFAULT NULL COMMENT 'target audience/age restriction from the bib record (MARC21 521$a)',
1104   `totalissues` int(10) DEFAULT NULL,
1105   PRIMARY KEY (`biblioitemnumber`),
1106   KEY `bibinoidx` (`biblioitemnumber`),
1107   KEY `bibnoidx` (`biblionumber`),
1108   KEY `itemtype_idx` (`itemtype`),
1109   KEY `isbn` (`isbn`(191)),
1110   KEY `issn` (`issn`(191)),
1111   KEY `ean` (`ean`(191)),
1112   KEY `publishercode` (`publishercode`(191)),
1113   KEY `timestamp` (`timestamp`),
1114   CONSTRAINT `biblioitems_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1115 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1116 /*!40101 SET character_set_client = @saved_cs_client */;
1117
1118 --
1119 -- Table structure for table `borrower_attribute_types`
1120 --
1121
1122 DROP TABLE IF EXISTS `borrower_attribute_types`;
1123 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1124 /*!40101 SET character_set_client = utf8 */;
1125 CREATE TABLE `borrower_attribute_types` (
1126   `code` varchar(10) NOT NULL COMMENT 'unique key used to identify each custom field',
1127   `description` varchar(255) NOT NULL COMMENT 'description for each custom field',
1128   `repeatable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines whether one patron/borrower can have multiple values for this custom field  (1 for yes, 0 for no)',
1129   `unique_id` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this value needs to be unique (1 for yes, 0 for no)',
1130   `opac_display` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is visible to patrons on their account in the OPAC (1 for yes, 0 for no)',
1131   `opac_editable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is editable by patrons on their account in the OPAC (1 for yes, 0 for no)',
1132   `staff_searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is searchable via the patron search in the staff interface (1 for yes, 0 for no)',
1133   `authorised_value_category` varchar(32) DEFAULT NULL COMMENT 'foreign key from authorised_values that links this custom field to an authorized value category',
1134   `display_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field displays in checkout screens',
1135   `category_code` varchar(10) DEFAULT NULL COMMENT 'defines a category for an attribute_type',
1136   `class` varchar(255) NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type',
1137   `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)',
1138   `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not',
1139   PRIMARY KEY (`code`),
1140   KEY `auth_val_cat_idx` (`authorised_value_category`),
1141   KEY `category_code` (`category_code`),
1142   CONSTRAINT `borrower_attribute_types_ibfk_1` FOREIGN KEY (`category_code`) REFERENCES `categories` (`categorycode`)
1143 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1144 /*!40101 SET character_set_client = @saved_cs_client */;
1145
1146 --
1147 -- Table structure for table `borrower_attribute_types_branches`
1148 --
1149
1150 DROP TABLE IF EXISTS `borrower_attribute_types_branches`;
1151 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1152 /*!40101 SET character_set_client = utf8 */;
1153 CREATE TABLE `borrower_attribute_types_branches` (
1154   `bat_code` varchar(10) DEFAULT NULL,
1155   `b_branchcode` varchar(10) DEFAULT NULL,
1156   KEY `bat_code` (`bat_code`),
1157   KEY `b_branchcode` (`b_branchcode`),
1158   CONSTRAINT `borrower_attribute_types_branches_ibfk_1` FOREIGN KEY (`bat_code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE,
1159   CONSTRAINT `borrower_attribute_types_branches_ibfk_2` FOREIGN KEY (`b_branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
1160 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1161 /*!40101 SET character_set_client = @saved_cs_client */;
1162
1163 --
1164 -- Table structure for table `borrower_attributes`
1165 --
1166
1167 DROP TABLE IF EXISTS `borrower_attributes`;
1168 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1169 /*!40101 SET character_set_client = utf8 */;
1170 CREATE TABLE `borrower_attributes` (
1171   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Row id field',
1172   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key from the borrowers table, defines which patron/borrower has this attribute',
1173   `code` varchar(10) NOT NULL COMMENT 'foreign key from the borrower_attribute_types table, defines which custom field this value was entered for',
1174   `attribute` varchar(255) DEFAULT NULL COMMENT 'custom patron field value',
1175   PRIMARY KEY (`id`),
1176   KEY `borrowernumber` (`borrowernumber`),
1177   KEY `code_attribute` (`code`,`attribute`(191)),
1178   CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1179   CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE
1180 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1181 /*!40101 SET character_set_client = @saved_cs_client */;
1182
1183 --
1184 -- Table structure for table `borrower_debarments`
1185 --
1186
1187 DROP TABLE IF EXISTS `borrower_debarments`;
1188 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1189 /*!40101 SET character_set_client = utf8 */;
1190 CREATE TABLE `borrower_debarments` (
1191   `borrower_debarment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the restriction',
1192   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key for borrowers.borrowernumber for patron who is restricted',
1193   `expiration` date DEFAULT NULL COMMENT 'expiration date of the restriction',
1194   `type` varchar(50) NOT NULL COMMENT 'type of restriction, FK to restriction_types.code',
1195   `comment` mediumtext DEFAULT NULL COMMENT 'comments about the restriction',
1196   `manager_id` int(11) DEFAULT NULL COMMENT 'foreign key for borrowers.borrowernumber for the librarian managing the restriction',
1197   `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date the restriction was added',
1198   `updated` timestamp NULL DEFAULT NULL COMMENT 'date the restriction was updated',
1199   PRIMARY KEY (`borrower_debarment_id`),
1200   KEY `borrowernumber` (`borrowernumber`),
1201   KEY `borrower_debarments_ibfk_2` (`type`),
1202   CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1203   CONSTRAINT `borrower_debarments_ibfk_2` FOREIGN KEY (`type`) REFERENCES `restriction_types` (`code`) ON DELETE NO ACTION ON UPDATE CASCADE
1204 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1205 /*!40101 SET character_set_client = @saved_cs_client */;
1206
1207 --
1208 -- Table structure for table `borrower_files`
1209 --
1210
1211 DROP TABLE IF EXISTS `borrower_files`;
1212 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1213 /*!40101 SET character_set_client = utf8 */;
1214 CREATE TABLE `borrower_files` (
1215   `file_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key',
1216   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key linking to the patron via the borrowernumber',
1217   `file_name` varchar(255) NOT NULL COMMENT 'file name',
1218   `file_type` varchar(255) NOT NULL COMMENT 'type of file',
1219   `file_description` varchar(255) DEFAULT NULL COMMENT 'description given to the file',
1220   `file_content` longblob NOT NULL COMMENT 'the file',
1221   `date_uploaded` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the file was added',
1222   PRIMARY KEY (`file_id`),
1223   KEY `borrowernumber` (`borrowernumber`),
1224   CONSTRAINT `borrower_files_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1225 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1226 /*!40101 SET character_set_client = @saved_cs_client */;
1227
1228 --
1229 -- Table structure for table `borrower_message_preferences`
1230 --
1231
1232 DROP TABLE IF EXISTS `borrower_message_preferences`;
1233 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1234 /*!40101 SET character_set_client = utf8 */;
1235 CREATE TABLE `borrower_message_preferences` (
1236   `borrower_message_preference_id` int(11) NOT NULL AUTO_INCREMENT,
1237   `borrowernumber` int(11) DEFAULT NULL,
1238   `categorycode` varchar(10) DEFAULT NULL,
1239   `message_attribute_id` int(11) DEFAULT 0,
1240   `days_in_advance` int(11) DEFAULT 0,
1241   `wants_digest` tinyint(1) NOT NULL DEFAULT 0,
1242   PRIMARY KEY (`borrower_message_preference_id`),
1243   KEY `borrowernumber` (`borrowernumber`),
1244   KEY `categorycode` (`categorycode`),
1245   KEY `message_attribute_id` (`message_attribute_id`),
1246   CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1247   CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1248   CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE
1249 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1250 /*!40101 SET character_set_client = @saved_cs_client */;
1251
1252 --
1253 -- Table structure for table `borrower_message_transport_preferences`
1254 --
1255
1256 DROP TABLE IF EXISTS `borrower_message_transport_preferences`;
1257 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1258 /*!40101 SET character_set_client = utf8 */;
1259 CREATE TABLE `borrower_message_transport_preferences` (
1260   `borrower_message_preference_id` int(11) NOT NULL DEFAULT 0,
1261   `message_transport_type` varchar(20) NOT NULL DEFAULT '0',
1262   PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
1263   KEY `message_transport_type` (`message_transport_type`),
1264   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,
1265   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
1266 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1267 /*!40101 SET character_set_client = @saved_cs_client */;
1268
1269 --
1270 -- Table structure for table `borrower_modifications`
1271 --
1272
1273 DROP TABLE IF EXISTS `borrower_modifications`;
1274 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1275 /*!40101 SET character_set_client = utf8 */;
1276 CREATE TABLE `borrower_modifications` (
1277   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
1278   `verification_token` varchar(255) NOT NULL DEFAULT '',
1279   `changed_fields` mediumtext DEFAULT NULL,
1280   `borrowernumber` int(11) NOT NULL DEFAULT 0,
1281   `cardnumber` varchar(32) DEFAULT NULL,
1282   `surname` longtext DEFAULT NULL,
1283   `firstname` mediumtext DEFAULT NULL,
1284   `middle_name` longtext DEFAULT NULL COMMENT 'patron/borrower''s middle name',
1285   `title` longtext DEFAULT NULL,
1286   `othernames` longtext DEFAULT NULL,
1287   `initials` mediumtext DEFAULT NULL,
1288   `pronouns` longtext DEFAULT NULL,
1289   `streetnumber` varchar(10) DEFAULT NULL,
1290   `streettype` varchar(50) DEFAULT NULL,
1291   `address` longtext DEFAULT NULL,
1292   `address2` mediumtext DEFAULT NULL,
1293   `city` longtext DEFAULT NULL,
1294   `state` mediumtext DEFAULT NULL,
1295   `zipcode` varchar(25) DEFAULT NULL,
1296   `country` mediumtext DEFAULT NULL,
1297   `email` longtext DEFAULT NULL,
1298   `phone` mediumtext DEFAULT NULL,
1299   `mobile` varchar(50) DEFAULT NULL,
1300   `fax` longtext DEFAULT NULL,
1301   `emailpro` mediumtext DEFAULT NULL,
1302   `phonepro` mediumtext DEFAULT NULL,
1303   `B_streetnumber` varchar(10) DEFAULT NULL,
1304   `B_streettype` varchar(50) DEFAULT NULL,
1305   `B_address` varchar(100) DEFAULT NULL,
1306   `B_address2` mediumtext DEFAULT NULL,
1307   `B_city` longtext DEFAULT NULL,
1308   `B_state` mediumtext DEFAULT NULL,
1309   `B_zipcode` varchar(25) DEFAULT NULL,
1310   `B_country` mediumtext DEFAULT NULL,
1311   `B_email` mediumtext DEFAULT NULL,
1312   `B_phone` longtext DEFAULT NULL,
1313   `dateofbirth` date DEFAULT NULL,
1314   `branchcode` varchar(10) DEFAULT NULL,
1315   `categorycode` varchar(10) DEFAULT NULL,
1316   `dateenrolled` date DEFAULT NULL,
1317   `dateexpiry` date DEFAULT NULL,
1318   `date_renewed` date DEFAULT NULL,
1319   `gonenoaddress` tinyint(1) DEFAULT NULL,
1320   `lost` tinyint(1) DEFAULT NULL,
1321   `debarred` date DEFAULT NULL,
1322   `debarredcomment` varchar(255) DEFAULT NULL,
1323   `contactname` longtext DEFAULT NULL,
1324   `contactfirstname` mediumtext DEFAULT NULL,
1325   `contacttitle` mediumtext DEFAULT NULL,
1326   `borrowernotes` longtext DEFAULT NULL,
1327   `relationship` varchar(100) DEFAULT NULL,
1328   `sex` varchar(1) DEFAULT NULL,
1329   `password` varchar(30) DEFAULT NULL,
1330   `flags` int(11) DEFAULT NULL,
1331   `userid` varchar(75) DEFAULT NULL,
1332   `opacnote` longtext DEFAULT NULL,
1333   `contactnote` varchar(255) DEFAULT NULL,
1334   `sort1` varchar(80) DEFAULT NULL,
1335   `sort2` varchar(80) DEFAULT NULL,
1336   `altcontactfirstname` varchar(255) DEFAULT NULL,
1337   `altcontactsurname` varchar(255) DEFAULT NULL,
1338   `altcontactaddress1` varchar(255) DEFAULT NULL,
1339   `altcontactaddress2` varchar(255) DEFAULT NULL,
1340   `altcontactaddress3` varchar(255) DEFAULT NULL,
1341   `altcontactstate` mediumtext DEFAULT NULL,
1342   `altcontactzipcode` varchar(50) DEFAULT NULL,
1343   `altcontactcountry` mediumtext DEFAULT NULL,
1344   `altcontactphone` varchar(50) DEFAULT NULL,
1345   `smsalertnumber` varchar(50) DEFAULT NULL,
1346   `privacy` int(11) DEFAULT NULL,
1347   `extended_attributes` mediumtext DEFAULT NULL,
1348   `gdpr_proc_consent` datetime DEFAULT NULL COMMENT 'data processing consent',
1349   `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes',
1350   PRIMARY KEY (`verification_token`(191),`borrowernumber`),
1351   KEY `verification_token` (`verification_token`(191)),
1352   KEY `borrowernumber` (`borrowernumber`)
1353 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1354 /*!40101 SET character_set_client = @saved_cs_client */;
1355
1356 --
1357 -- Table structure for table `borrower_password_recovery`
1358 --
1359
1360 DROP TABLE IF EXISTS `borrower_password_recovery`;
1361 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1362 /*!40101 SET character_set_client = utf8 */;
1363 CREATE TABLE `borrower_password_recovery` (
1364   `borrowernumber` int(11) NOT NULL COMMENT 'the user asking a password recovery',
1365   `uuid` varchar(128) NOT NULL COMMENT 'a unique string to identify a password recovery attempt',
1366   `valid_until` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'a time limit on the password recovery attempt',
1367   PRIMARY KEY (`borrowernumber`),
1368   KEY `borrowernumber` (`borrowernumber`)
1369 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1370 /*!40101 SET character_set_client = @saved_cs_client */;
1371
1372 --
1373 -- Table structure for table `borrower_relationships`
1374 --
1375
1376 DROP TABLE IF EXISTS `borrower_relationships`;
1377 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1378 /*!40101 SET character_set_client = utf8 */;
1379 CREATE TABLE `borrower_relationships` (
1380   `id` int(11) NOT NULL AUTO_INCREMENT,
1381   `guarantor_id` int(11) NOT NULL,
1382   `guarantee_id` int(11) NOT NULL,
1383   `relationship` varchar(100) NOT NULL,
1384   PRIMARY KEY (`id`),
1385   UNIQUE KEY `guarantor_guarantee_idx` (`guarantor_id`,`guarantee_id`),
1386   KEY `r_guarantee` (`guarantee_id`),
1387   CONSTRAINT `r_guarantee` FOREIGN KEY (`guarantee_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1388   CONSTRAINT `r_guarantor` FOREIGN KEY (`guarantor_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1389 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1390 /*!40101 SET character_set_client = @saved_cs_client */;
1391
1392 --
1393 -- Table structure for table `borrowers`
1394 --
1395
1396 DROP TABLE IF EXISTS `borrowers`;
1397 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1398 /*!40101 SET character_set_client = utf8 */;
1399 CREATE TABLE `borrowers` (
1400   `borrowernumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key, Koha assigned ID number for patrons/borrowers',
1401   `cardnumber` varchar(32) DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1402   `surname` longtext DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1403   `firstname` mediumtext DEFAULT NULL COMMENT 'patron/borrower''s first name',
1404   `middle_name` longtext DEFAULT NULL COMMENT 'patron/borrower''s middle name',
1405   `title` longtext DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1406   `othernames` longtext DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1407   `initials` mediumtext DEFAULT NULL COMMENT 'initials for your patron/borrower',
1408   `pronouns` longtext DEFAULT NULL COMMENT 'patron/borrower pronouns',
1409   `streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your patron/borrower''s primary address',
1410   `streettype` tinytext DEFAULT NULL COMMENT 'the street type (Rd., Blvd, etc) for your patron/borrower''s primary address',
1411   `address` longtext DEFAULT NULL COMMENT 'the first address line for your patron/borrower''s primary address',
1412   `address2` mediumtext DEFAULT NULL COMMENT 'the second address line for your patron/borrower''s primary address',
1413   `city` longtext DEFAULT NULL COMMENT 'the city or town for your patron/borrower''s primary address',
1414   `state` mediumtext DEFAULT NULL COMMENT 'the state or province for your patron/borrower''s primary address',
1415   `zipcode` tinytext DEFAULT NULL COMMENT 'the zip or postal code for your patron/borrower''s primary address',
1416   `country` mediumtext DEFAULT NULL COMMENT 'the country for your patron/borrower''s primary address',
1417   `email` longtext DEFAULT NULL COMMENT 'the primary email address for your patron/borrower''s primary address',
1418   `phone` mediumtext DEFAULT NULL COMMENT 'the primary phone number for your patron/borrower''s primary address',
1419   `mobile` tinytext DEFAULT NULL COMMENT 'the other phone number for your patron/borrower''s primary address',
1420   `fax` longtext DEFAULT NULL COMMENT 'the fax number for your patron/borrower''s primary address',
1421   `emailpro` mediumtext DEFAULT NULL COMMENT 'the secondary email addres for your patron/borrower''s primary address',
1422   `phonepro` mediumtext DEFAULT NULL COMMENT 'the secondary phone number for your patron/borrower''s primary address',
1423   `B_streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your patron/borrower''s alternate address',
1424   `B_streettype` tinytext DEFAULT NULL COMMENT 'the street type (Rd., Blvd, etc) for your patron/borrower''s alternate address',
1425   `B_address` mediumtext DEFAULT NULL COMMENT 'the first address line for your patron/borrower''s alternate address',
1426   `B_address2` mediumtext DEFAULT NULL COMMENT 'the second address line for your patron/borrower''s alternate address',
1427   `B_city` longtext DEFAULT NULL COMMENT 'the city or town for your patron/borrower''s alternate address',
1428   `B_state` mediumtext DEFAULT NULL COMMENT 'the state for your patron/borrower''s alternate address',
1429   `B_zipcode` tinytext DEFAULT NULL COMMENT 'the zip or postal code for your patron/borrower''s alternate address',
1430   `B_country` mediumtext DEFAULT NULL COMMENT 'the country for your patron/borrower''s alternate address',
1431   `B_email` mediumtext DEFAULT NULL COMMENT 'the patron/borrower''s alternate email address',
1432   `B_phone` longtext DEFAULT NULL COMMENT 'the patron/borrower''s alternate phone number',
1433   `dateofbirth` date DEFAULT NULL COMMENT 'the patron/borrower''s date of birth (YYYY-MM-DD)',
1434   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the branches table, includes the code of the patron/borrower''s home branch',
1435   `categorycode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the categories table, includes the code of the patron category',
1436   `dateenrolled` date DEFAULT NULL COMMENT 'date the patron was added to Koha (YYYY-MM-DD)',
1437   `dateexpiry` date DEFAULT NULL COMMENT 'date the patron/borrower''s card is set to expire (YYYY-MM-DD)',
1438   `password_expiration_date` date DEFAULT NULL COMMENT 'date the patron/borrower''s password is set to expire (YYYY-MM-DD)',
1439   `date_renewed` date DEFAULT NULL COMMENT 'date the patron/borrower''s card was last renewed',
1440   `gonenoaddress` tinyint(1) DEFAULT NULL COMMENT 'set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address',
1441   `lost` tinyint(1) DEFAULT NULL COMMENT 'set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card',
1442   `debarred` date DEFAULT NULL COMMENT 'until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)',
1443   `debarredcomment` varchar(255) DEFAULT NULL COMMENT 'comment on the stop of the patron',
1444   `contactname` longtext DEFAULT NULL COMMENT 'used for children and profesionals to include surname or last name of guarantor or organization name',
1445   `contactfirstname` mediumtext DEFAULT NULL COMMENT 'used for children to include first name of guarantor',
1446   `contacttitle` mediumtext DEFAULT NULL COMMENT 'used for children to include title (Mr., Mrs., etc) of guarantor',
1447   `borrowernotes` longtext DEFAULT NULL COMMENT 'a note on the patron/borrower''s account that is only visible in the staff interface',
1448   `relationship` varchar(100) DEFAULT NULL COMMENT 'used for children to include the relationship to their guarantor',
1449   `sex` varchar(1) DEFAULT NULL COMMENT 'patron/borrower''s gender',
1450   `password` varchar(60) DEFAULT NULL COMMENT 'patron/borrower''s Bcrypt encrypted password',
1451   `secret` mediumtext DEFAULT NULL COMMENT 'Secret for 2FA',
1452   `auth_method` enum('password','two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method',
1453   `flags` int(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions',
1454   `userid` varchar(75) DEFAULT NULL COMMENT 'patron/borrower''s opac and/or staff interface log in',
1455   `opacnote` longtext DEFAULT NULL COMMENT 'a note on the patron/borrower''s account that is visible in the OPAC and staff interface',
1456   `contactnote` varchar(255) DEFAULT NULL COMMENT 'a note related to the patron/borrower''s alternate address',
1457   `sort1` varchar(80) DEFAULT NULL COMMENT 'a field that can be used for any information unique to the library',
1458   `sort2` varchar(80) DEFAULT NULL COMMENT 'a field that can be used for any information unique to the library',
1459   `altcontactfirstname` mediumtext DEFAULT NULL COMMENT 'first name of alternate contact for the patron/borrower',
1460   `altcontactsurname` mediumtext DEFAULT NULL COMMENT 'surname or last name of the alternate contact for the patron/borrower',
1461   `altcontactaddress1` mediumtext DEFAULT NULL COMMENT 'the first address line for the alternate contact for the patron/borrower',
1462   `altcontactaddress2` mediumtext DEFAULT NULL COMMENT 'the second address line for the alternate contact for the patron/borrower',
1463   `altcontactaddress3` mediumtext DEFAULT NULL COMMENT 'the city for the alternate contact for the patron/borrower',
1464   `altcontactstate` mediumtext DEFAULT NULL COMMENT 'the state for the alternate contact for the patron/borrower',
1465   `altcontactzipcode` mediumtext DEFAULT NULL COMMENT 'the zipcode for the alternate contact for the patron/borrower',
1466   `altcontactcountry` mediumtext DEFAULT NULL COMMENT 'the country for the alternate contact for the patron/borrower',
1467   `altcontactphone` mediumtext DEFAULT NULL COMMENT 'the phone number for the alternate contact for the patron/borrower',
1468   `smsalertnumber` varchar(50) DEFAULT NULL COMMENT 'the mobile phone number where the patron/borrower would like to receive notices (if SMS turned on)',
1469   `sms_provider_id` int(11) DEFAULT NULL COMMENT 'the provider of the mobile phone number defined in smsalertnumber',
1470   `privacy` int(11) NOT NULL DEFAULT 1 COMMENT 'patron/borrower''s privacy settings related to their checkout history',
1471   `privacy_guarantor_fines` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'controls if relatives can see this patron''s fines',
1472   `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'controls if relatives can see this patron''s checkouts',
1473   `checkprevcheckout` varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.',
1474   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'time of last change could be useful for synchronization with external systems (among others)',
1475   `lastseen` datetime DEFAULT NULL COMMENT 'last time a patron has been seen (connected at the OPAC or staff interface)',
1476   `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang to use to send notices to this patron',
1477   `login_attempts` int(4) NOT NULL DEFAULT 0 COMMENT 'number of failed login attemps',
1478   `overdrive_auth_token` mediumtext DEFAULT NULL COMMENT 'persist OverDrive auth token',
1479   `anonymized` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'flag for data anonymization',
1480   `autorenew_checkouts` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'flag for allowing auto-renewal',
1481   `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes',
1482   PRIMARY KEY (`borrowernumber`),
1483   UNIQUE KEY `cardnumber` (`cardnumber`),
1484   UNIQUE KEY `userid` (`userid`),
1485   KEY `categorycode` (`categorycode`),
1486   KEY `branchcode` (`branchcode`),
1487   KEY `surname_idx` (`surname`(191)),
1488   KEY `firstname_idx` (`firstname`(191)),
1489   KEY `othernames_idx` (`othernames`(191)),
1490   KEY `sms_provider_id` (`sms_provider_id`),
1491   CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
1492   CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`),
1493   CONSTRAINT `borrowers_ibfk_3` FOREIGN KEY (`sms_provider_id`) REFERENCES `sms_providers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
1494 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1495 /*!40101 SET character_set_client = @saved_cs_client */;
1496
1497 --
1498 -- Table structure for table `branch_transfer_limits`
1499 --
1500
1501 DROP TABLE IF EXISTS `branch_transfer_limits`;
1502 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1503 /*!40101 SET character_set_client = utf8 */;
1504 CREATE TABLE `branch_transfer_limits` (
1505   `limitId` int(8) NOT NULL AUTO_INCREMENT,
1506   `toBranch` varchar(10) NOT NULL,
1507   `fromBranch` varchar(10) NOT NULL,
1508   `itemtype` varchar(10) DEFAULT NULL,
1509   `ccode` varchar(80) DEFAULT NULL,
1510   PRIMARY KEY (`limitId`)
1511 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1512 /*!40101 SET character_set_client = @saved_cs_client */;
1513
1514 --
1515 -- Table structure for table `branches`
1516 --
1517
1518 DROP TABLE IF EXISTS `branches`;
1519 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1520 /*!40101 SET character_set_client = utf8 */;
1521 CREATE TABLE `branches` (
1522   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'a unique key assigned to each branch',
1523   `branchname` longtext NOT NULL COMMENT 'the name of your library or branch',
1524   `branchaddress1` longtext DEFAULT NULL COMMENT 'the first address line of for your library or branch',
1525   `branchaddress2` longtext DEFAULT NULL COMMENT 'the second address line of for your library or branch',
1526   `branchaddress3` longtext DEFAULT NULL COMMENT 'the third address line of for your library or branch',
1527   `branchzip` varchar(25) DEFAULT NULL COMMENT 'the zip or postal code for your library or branch',
1528   `branchcity` longtext DEFAULT NULL COMMENT 'the city or province for your library or branch',
1529   `branchstate` longtext DEFAULT NULL COMMENT 'the state for your library or branch',
1530   `branchcountry` mediumtext DEFAULT NULL COMMENT 'the county for your library or branch',
1531   `branchphone` longtext DEFAULT NULL COMMENT 'the primary phone for your library or branch',
1532   `branchfax` longtext DEFAULT NULL COMMENT 'the fax number for your library or branch',
1533   `branchemail` longtext DEFAULT NULL COMMENT 'the primary email address for your library or branch',
1534   `branchillemail` longtext DEFAULT NULL COMMENT 'the ILL staff email address for your library or branch',
1535   `branchreplyto` longtext DEFAULT NULL COMMENT 'the email to be used as a Reply-To',
1536   `branchreturnpath` longtext DEFAULT NULL COMMENT 'the email to be used as Return-Path',
1537   `branchurl` longtext DEFAULT NULL COMMENT 'the URL for your library or branch''s website',
1538   `issuing` tinyint(4) DEFAULT NULL COMMENT 'unused in Koha',
1539   `branchip` varchar(15) DEFAULT NULL COMMENT 'the IP address for your library or branch',
1540   `branchnotes` longtext DEFAULT NULL COMMENT 'notes related to your library or branch',
1541   `geolocation` varchar(255) DEFAULT NULL COMMENT 'geolocation of your library',
1542   `marcorgcode` varchar(16) DEFAULT NULL COMMENT 'MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode',
1543   `pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'the ability to act as a pickup location',
1544   `public` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether this library should show in the opac',
1545   PRIMARY KEY (`branchcode`)
1546 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1547 /*!40101 SET character_set_client = @saved_cs_client */;
1548
1549 --
1550 -- Table structure for table `branches_overdrive`
1551 --
1552
1553 DROP TABLE IF EXISTS `branches_overdrive`;
1554 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1555 /*!40101 SET character_set_client = utf8 */;
1556 CREATE TABLE `branches_overdrive` (
1557   `branchcode` varchar(10) NOT NULL,
1558   `authname` varchar(255) NOT NULL,
1559   PRIMARY KEY (`branchcode`),
1560   CONSTRAINT `branches_overdrive_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1561 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1562 /*!40101 SET character_set_client = @saved_cs_client */;
1563
1564 --
1565 -- Table structure for table `branchtransfers`
1566 --
1567
1568 DROP TABLE IF EXISTS `branchtransfers`;
1569 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1570 /*!40101 SET character_set_client = utf8 */;
1571 CREATE TABLE `branchtransfers` (
1572   `branchtransfer_id` int(12) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
1573   `itemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'the itemnumber that it is in transit (items.itemnumber)',
1574   `daterequested` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date the transfer was requested',
1575   `datesent` datetime DEFAULT NULL COMMENT 'the date the transfer was initialized',
1576   `frombranch` varchar(10) NOT NULL DEFAULT '' COMMENT 'the branch the transfer is coming from',
1577   `datearrived` datetime DEFAULT NULL COMMENT 'the date the transfer arrived at its destination',
1578   `datecancelled` datetime DEFAULT NULL COMMENT 'the date the transfer was cancelled',
1579   `tobranch` varchar(10) NOT NULL DEFAULT '' COMMENT 'the branch the transfer was going to',
1580   `comments` longtext DEFAULT NULL COMMENT 'any comments related to the transfer',
1581   `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer',
1582   `cancellation_reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','ItemLost','WrongTransfer','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer cancellation',
1583   PRIMARY KEY (`branchtransfer_id`),
1584   KEY `frombranch` (`frombranch`),
1585   KEY `tobranch` (`tobranch`),
1586   KEY `itemnumber` (`itemnumber`),
1587   CONSTRAINT `branchtransfers_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
1588   CONSTRAINT `branchtransfers_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
1589   CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1590 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1591 /*!40101 SET character_set_client = @saved_cs_client */;
1592
1593 --
1594 -- Table structure for table `browser`
1595 --
1596
1597 DROP TABLE IF EXISTS `browser`;
1598 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1599 /*!40101 SET character_set_client = utf8 */;
1600 CREATE TABLE `browser` (
1601   `level` int(11) NOT NULL,
1602   `classification` varchar(20) NOT NULL,
1603   `description` varchar(255) NOT NULL,
1604   `number` bigint(20) NOT NULL,
1605   `endnode` tinyint(4) NOT NULL
1606 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1607 /*!40101 SET character_set_client = @saved_cs_client */;
1608
1609 --
1610 -- Table structure for table `cash_register_actions`
1611 --
1612
1613 DROP TABLE IF EXISTS `cash_register_actions`;
1614 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1615 /*!40101 SET character_set_client = utf8 */;
1616 CREATE TABLE `cash_register_actions` (
1617   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for each account register action',
1618   `code` varchar(24) NOT NULL COMMENT 'action code denoting the type of action recorded (enum),',
1619   `register_id` int(11) NOT NULL COMMENT 'id of cash_register this action belongs to,',
1620   `manager_id` int(11) NOT NULL COMMENT 'staff member performing the action',
1621   `amount` decimal(28,6) DEFAULT NULL COMMENT 'amount recorded in action (signed)',
1622   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
1623   PRIMARY KEY (`id`),
1624   KEY `cash_register_actions_manager` (`manager_id`),
1625   KEY `cash_register_actions_register` (`register_id`),
1626   CONSTRAINT `cash_register_actions_manager` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1627   CONSTRAINT `cash_register_actions_register` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1628 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1629 /*!40101 SET character_set_client = @saved_cs_client */;
1630
1631 --
1632 -- Table structure for table `cash_registers`
1633 --
1634
1635 DROP TABLE IF EXISTS `cash_registers`;
1636 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1637 /*!40101 SET character_set_client = utf8 */;
1638 CREATE TABLE `cash_registers` (
1639   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for each account register',
1640   `name` varchar(24) NOT NULL COMMENT 'the user friendly identifier for each account register',
1641   `description` longtext NOT NULL COMMENT 'the user friendly description for each account register',
1642   `branch` varchar(10) NOT NULL COMMENT 'the foreign key the library this account register belongs',
1643   `branch_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote that this till is the branch default',
1644   `starting_float` decimal(28,6) DEFAULT NULL COMMENT 'the starting float this account register should be assigned',
1645   `archived` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote if this till is archived or not',
1646   PRIMARY KEY (`id`),
1647   UNIQUE KEY `name` (`name`,`branch`),
1648   KEY `cash_registers_branch` (`branch`),
1649   CONSTRAINT `cash_registers_branch` FOREIGN KEY (`branch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1650 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1651 /*!40101 SET character_set_client = @saved_cs_client */;
1652
1653 --
1654 -- Table structure for table `categories`
1655 --
1656
1657 DROP TABLE IF EXISTS `categories`;
1658 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1659 /*!40101 SET character_set_client = utf8 */;
1660 CREATE TABLE `categories` (
1661   `categorycode` varchar(10) NOT NULL DEFAULT '' COMMENT 'unique primary key used to idenfity the patron category',
1662   `description` longtext DEFAULT NULL COMMENT 'description of the patron category',
1663   `enrolmentperiod` smallint(6) DEFAULT NULL COMMENT 'number of months the patron is enrolled for (will be NULL if enrolmentperioddate is set)',
1664   `enrolmentperioddate` date DEFAULT NULL COMMENT 'date the patron is enrolled until (will be NULL if enrolmentperiod is set)',
1665   `password_expiry_days` smallint(6) DEFAULT NULL COMMENT 'number of days after which the patron must reset their password',
1666   `upperagelimit` smallint(6) DEFAULT NULL COMMENT 'age limit for the patron',
1667   `dateofbirthrequired` tinyint(1) DEFAULT NULL COMMENT 'the minimum age required for the patron category',
1668   `finetype` varchar(30) DEFAULT NULL COMMENT 'unused in Koha',
1669   `bulk` tinyint(1) DEFAULT NULL,
1670   `enrolmentfee` decimal(28,6) DEFAULT NULL COMMENT 'enrollment fee for the patron',
1671   `overduenoticerequired` tinyint(1) DEFAULT NULL COMMENT 'are overdue notices sent to this patron category (1 for yes, 0 for no)',
1672   `issuelimit` smallint(6) DEFAULT NULL COMMENT 'unused in Koha',
1673   `reservefee` decimal(28,6) DEFAULT NULL COMMENT 'cost to place holds',
1674   `hidelostitems` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'are lost items shown to this category (1 for yes, 0 for no)',
1675   `category_type` varchar(1) NOT NULL DEFAULT 'A' COMMENT 'type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)',
1676   `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL DEFAULT -1 COMMENT 'wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions',
1677   `default_privacy` enum('default','never','forever') NOT NULL DEFAULT 'default' COMMENT 'Default privacy setting for this patron category',
1678   `checkprevcheckout` varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.',
1679   `can_be_guarantee` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'if patrons of this category can be guarantees',
1680   `reset_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can do the password reset flow,',
1681   `change_password` tinyint(1) DEFAULT NULL COMMENT 'if patrons of this category can change their passwords in the OAPC',
1682   `min_password_length` smallint(6) DEFAULT NULL COMMENT 'set minimum password length for patrons in this category',
1683   `require_strong_password` tinyint(1) DEFAULT NULL COMMENT 'set required password strength for patrons in this category',
1684   `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude patrons of this category from local holds priority',
1685   PRIMARY KEY (`categorycode`),
1686   UNIQUE KEY `categorycode` (`categorycode`)
1687 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1688 /*!40101 SET character_set_client = @saved_cs_client */;
1689
1690 --
1691 -- Table structure for table `categories_branches`
1692 --
1693
1694 DROP TABLE IF EXISTS `categories_branches`;
1695 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1696 /*!40101 SET character_set_client = utf8 */;
1697 CREATE TABLE `categories_branches` (
1698   `categorycode` varchar(10) DEFAULT NULL,
1699   `branchcode` varchar(10) DEFAULT NULL,
1700   KEY `categorycode` (`categorycode`),
1701   KEY `branchcode` (`branchcode`),
1702   CONSTRAINT `categories_branches_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE,
1703   CONSTRAINT `categories_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
1704 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1705 /*!40101 SET character_set_client = @saved_cs_client */;
1706
1707 --
1708 -- Table structure for table `checkout_renewals`
1709 --
1710
1711 DROP TABLE IF EXISTS `checkout_renewals`;
1712 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1713 /*!40101 SET character_set_client = utf8 */;
1714 CREATE TABLE `checkout_renewals` (
1715   `renewal_id` int(11) NOT NULL AUTO_INCREMENT,
1716   `checkout_id` int(11) DEFAULT NULL COMMENT 'the id of the checkout this renewal pertains to',
1717   `renewer_id` int(11) DEFAULT NULL COMMENT 'the id of the user who processed the renewal',
1718   `seen` tinyint(1) DEFAULT 0 COMMENT 'boolean denoting whether the item was present or not',
1719   `interface` varchar(16) NOT NULL COMMENT 'the interface this renewal took place on',
1720   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the renewal took place',
1721   `renewal_type` enum('Automatic', 'Manual') NOT NULL DEFAULT 'Manual' COMMENT 'whether the renewal was an automatic or manual renewal',
1722   PRIMARY KEY (`renewal_id`),
1723   KEY `renewer_id` (`renewer_id`),
1724   CONSTRAINT `renewals_renewer_id` FOREIGN KEY (`renewer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
1725 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1726 /*!40101 SET character_set_client = @saved_cs_client */;
1727
1728 --
1729 -- Table structure for table `circulation_rules`
1730 --
1731
1732 DROP TABLE IF EXISTS `circulation_rules`;
1733 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1734 /*!40101 SET character_set_client = utf8 */;
1735 CREATE TABLE `circulation_rules` (
1736   `id` int(11) NOT NULL AUTO_INCREMENT,
1737   `branchcode` varchar(10) DEFAULT NULL,
1738   `categorycode` varchar(10) DEFAULT NULL,
1739   `itemtype` varchar(10) DEFAULT NULL,
1740   `rule_name` varchar(32) NOT NULL,
1741   `rule_value` varchar(32) NOT NULL,
1742   PRIMARY KEY (`id`),
1743   UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1744   KEY `circ_rules_ibfk_2` (`categorycode`),
1745   KEY `circ_rules_ibfk_3` (`itemtype`),
1746   KEY `rule_name` (`rule_name`),
1747   CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
1748   CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
1749   CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
1750 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1751 /*!40101 SET character_set_client = @saved_cs_client */;
1752
1753 --
1754 -- Table structure for table `cities`
1755 --
1756
1757 DROP TABLE IF EXISTS `cities`;
1758 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1759 /*!40101 SET character_set_client = utf8 */;
1760 CREATE TABLE `cities` (
1761   `cityid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier added by Koha',
1762   `city_name` varchar(100) NOT NULL DEFAULT '' COMMENT 'name of the city',
1763   `city_state` varchar(100) DEFAULT NULL COMMENT 'name of the state/province',
1764   `city_country` varchar(100) DEFAULT NULL COMMENT 'name of the country',
1765   `city_zipcode` varchar(20) DEFAULT NULL COMMENT 'zip or postal code',
1766   PRIMARY KEY (`cityid`)
1767 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1768 /*!40101 SET character_set_client = @saved_cs_client */;
1769
1770 --
1771 -- Table structure for table `class_sort_rules`
1772 --
1773
1774 DROP TABLE IF EXISTS `class_sort_rules`;
1775 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1776 /*!40101 SET character_set_client = utf8 */;
1777 CREATE TABLE `class_sort_rules` (
1778   `class_sort_rule` varchar(10) NOT NULL DEFAULT '',
1779   `description` longtext DEFAULT NULL,
1780   `sort_routine` varchar(30) NOT NULL DEFAULT '',
1781   PRIMARY KEY (`class_sort_rule`),
1782   UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
1783 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1784 /*!40101 SET character_set_client = @saved_cs_client */;
1785
1786 --
1787 -- Table structure for table `class_sources`
1788 --
1789
1790 DROP TABLE IF EXISTS `class_sources`;
1791 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1792 /*!40101 SET character_set_client = utf8 */;
1793 CREATE TABLE `class_sources` (
1794   `cn_source` varchar(10) NOT NULL DEFAULT '',
1795   `description` longtext DEFAULT NULL,
1796   `used` tinyint(4) NOT NULL DEFAULT 0,
1797   `class_sort_rule` varchar(10) NOT NULL DEFAULT '',
1798   `class_split_rule` varchar(10) NOT NULL DEFAULT '',
1799   PRIMARY KEY (`cn_source`),
1800   UNIQUE KEY `cn_source_idx` (`cn_source`),
1801   KEY `used_idx` (`used`),
1802   KEY `class_source_ibfk_1` (`class_sort_rule`),
1803   KEY `class_source_ibfk_2` (`class_split_rule`),
1804   CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`),
1805   CONSTRAINT `class_source_ibfk_2` FOREIGN KEY (`class_split_rule`) REFERENCES `class_split_rules` (`class_split_rule`)
1806 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1807 /*!40101 SET character_set_client = @saved_cs_client */;
1808
1809 --
1810 -- Table structure for table `class_split_rules`
1811 --
1812
1813 DROP TABLE IF EXISTS `class_split_rules`;
1814 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1815 /*!40101 SET character_set_client = utf8 */;
1816 CREATE TABLE `class_split_rules` (
1817   `class_split_rule` varchar(10) NOT NULL DEFAULT '',
1818   `description` longtext DEFAULT NULL,
1819   `split_routine` varchar(30) NOT NULL DEFAULT '',
1820   `split_regex` varchar(255) NOT NULL DEFAULT '',
1821   PRIMARY KEY (`class_split_rule`),
1822   UNIQUE KEY `class_split_rule_idx` (`class_split_rule`)
1823 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1824 /*!40101 SET character_set_client = @saved_cs_client */;
1825
1826 --
1827 -- Table structure for table `club_enrollment_fields`
1828 --
1829
1830 DROP TABLE IF EXISTS `club_enrollment_fields`;
1831 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1832 /*!40101 SET character_set_client = utf8 */;
1833 CREATE TABLE `club_enrollment_fields` (
1834   `id` int(11) NOT NULL AUTO_INCREMENT,
1835   `club_enrollment_id` int(11) NOT NULL,
1836   `club_template_enrollment_field_id` int(11) NOT NULL,
1837   `value` mediumtext NOT NULL,
1838   PRIMARY KEY (`id`),
1839   KEY `club_enrollment_id` (`club_enrollment_id`),
1840   KEY `club_template_enrollment_field_id` (`club_template_enrollment_field_id`),
1841   CONSTRAINT `club_enrollment_fields_ibfk_1` FOREIGN KEY (`club_enrollment_id`) REFERENCES `club_enrollments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1842   CONSTRAINT `club_enrollment_fields_ibfk_2` FOREIGN KEY (`club_template_enrollment_field_id`) REFERENCES `club_template_enrollment_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1843 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1844 /*!40101 SET character_set_client = @saved_cs_client */;
1845
1846 --
1847 -- Table structure for table `club_enrollments`
1848 --
1849
1850 DROP TABLE IF EXISTS `club_enrollments`;
1851 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1852 /*!40101 SET character_set_client = utf8 */;
1853 CREATE TABLE `club_enrollments` (
1854   `id` int(11) NOT NULL AUTO_INCREMENT,
1855   `club_id` int(11) NOT NULL,
1856   `borrowernumber` int(11) NOT NULL,
1857   `date_enrolled` timestamp NOT NULL DEFAULT current_timestamp(),
1858   `date_canceled` timestamp NULL DEFAULT NULL,
1859   `date_created` timestamp NULL DEFAULT NULL,
1860   `date_updated` timestamp NULL DEFAULT NULL,
1861   `branchcode` varchar(10) DEFAULT NULL,
1862   PRIMARY KEY (`id`),
1863   KEY `club_id` (`club_id`),
1864   KEY `borrowernumber` (`borrowernumber`),
1865   KEY `branchcode` (`branchcode`),
1866   CONSTRAINT `club_enrollments_ibfk_1` FOREIGN KEY (`club_id`) REFERENCES `clubs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1867   CONSTRAINT `club_enrollments_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1868   CONSTRAINT `club_enrollments_ibfk_3` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
1869 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1870 /*!40101 SET character_set_client = @saved_cs_client */;
1871
1872 --
1873 -- Table structure for table `club_fields`
1874 --
1875
1876 DROP TABLE IF EXISTS `club_fields`;
1877 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1878 /*!40101 SET character_set_client = utf8 */;
1879 CREATE TABLE `club_fields` (
1880   `id` int(11) NOT NULL AUTO_INCREMENT,
1881   `club_template_field_id` int(11) NOT NULL,
1882   `club_id` int(11) NOT NULL,
1883   `value` mediumtext DEFAULT NULL,
1884   PRIMARY KEY (`id`),
1885   KEY `club_template_field_id` (`club_template_field_id`),
1886   KEY `club_id` (`club_id`),
1887   CONSTRAINT `club_fields_ibfk_3` FOREIGN KEY (`club_template_field_id`) REFERENCES `club_template_fields` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1888   CONSTRAINT `club_fields_ibfk_4` FOREIGN KEY (`club_id`) REFERENCES `clubs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1889 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1890 /*!40101 SET character_set_client = @saved_cs_client */;
1891
1892 --
1893 -- Table structure for table `club_holds`
1894 --
1895
1896 DROP TABLE IF EXISTS `club_holds`;
1897 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1898 /*!40101 SET character_set_client = utf8 */;
1899 CREATE TABLE `club_holds` (
1900   `id` int(11) NOT NULL AUTO_INCREMENT,
1901   `club_id` int(11) NOT NULL COMMENT 'id for the club the hold was generated for',
1902   `biblio_id` int(11) NOT NULL COMMENT 'id for the bibliographic record the hold has been placed against',
1903   `item_id` int(11) DEFAULT NULL COMMENT 'If item-level, the id for the item the hold has been placed agains',
1904   `date_created` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Timestamp for the placed hold',
1905   PRIMARY KEY (`id`),
1906   KEY `clubs_holds_ibfk_1` (`club_id`),
1907   KEY `clubs_holds_ibfk_2` (`biblio_id`),
1908   KEY `clubs_holds_ibfk_3` (`item_id`),
1909   CONSTRAINT `clubs_holds_ibfk_1` FOREIGN KEY (`club_id`) REFERENCES `clubs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1910   CONSTRAINT `clubs_holds_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1911   CONSTRAINT `clubs_holds_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1912 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1913 /*!40101 SET character_set_client = @saved_cs_client */;
1914
1915 --
1916 -- Table structure for table `club_holds_to_patron_holds`
1917 --
1918
1919 DROP TABLE IF EXISTS `club_holds_to_patron_holds`;
1920 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1921 /*!40101 SET character_set_client = utf8 */;
1922 CREATE TABLE `club_holds_to_patron_holds` (
1923   `id` int(11) NOT NULL AUTO_INCREMENT,
1924   `club_hold_id` int(11) NOT NULL,
1925   `patron_id` int(11) NOT NULL,
1926   `hold_id` int(11) DEFAULT NULL,
1927   `error_code` enum('damaged','ageRestricted','itemAlreadyOnHold','tooManyHoldsForThisRecord','tooManyReservesToday','tooManyReserves','notReservable','cannotReserveFromOtherBranches','libraryNotFound','libraryNotPickupLocation','cannotBeTransferred','noReservesAllowed') DEFAULT NULL,
1928   `error_message` varchar(100) DEFAULT NULL,
1929   PRIMARY KEY (`id`),
1930   KEY `clubs_holds_paton_holds_ibfk_1` (`club_hold_id`),
1931   KEY `clubs_holds_paton_holds_ibfk_2` (`patron_id`),
1932   KEY `clubs_holds_paton_holds_ibfk_3` (`hold_id`),
1933   CONSTRAINT `clubs_holds_paton_holds_ibfk_1` FOREIGN KEY (`club_hold_id`) REFERENCES `club_holds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
1934   CONSTRAINT `clubs_holds_paton_holds_ibfk_2` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1935   CONSTRAINT `clubs_holds_paton_holds_ibfk_3` FOREIGN KEY (`hold_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE ON UPDATE CASCADE
1936 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1937 /*!40101 SET character_set_client = @saved_cs_client */;
1938
1939 --
1940 -- Table structure for table `club_template_enrollment_fields`
1941 --
1942
1943 DROP TABLE IF EXISTS `club_template_enrollment_fields`;
1944 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1945 /*!40101 SET character_set_client = utf8 */;
1946 CREATE TABLE `club_template_enrollment_fields` (
1947   `id` int(11) NOT NULL AUTO_INCREMENT,
1948   `club_template_id` int(11) NOT NULL,
1949   `name` text NOT NULL,
1950   `description` mediumtext DEFAULT NULL,
1951   `authorised_value_category` varchar(32) DEFAULT NULL,
1952   PRIMARY KEY (`id`),
1953   KEY `club_template_id` (`club_template_id`),
1954   CONSTRAINT `club_template_enrollment_fields_ibfk_1` FOREIGN KEY (`club_template_id`) REFERENCES `club_templates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1955 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1956 /*!40101 SET character_set_client = @saved_cs_client */;
1957
1958 --
1959 -- Table structure for table `club_template_fields`
1960 --
1961
1962 DROP TABLE IF EXISTS `club_template_fields`;
1963 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1964 /*!40101 SET character_set_client = utf8 */;
1965 CREATE TABLE `club_template_fields` (
1966   `id` int(11) NOT NULL AUTO_INCREMENT,
1967   `club_template_id` int(11) NOT NULL,
1968   `name` text NOT NULL,
1969   `description` mediumtext DEFAULT NULL,
1970   `authorised_value_category` varchar(32) DEFAULT NULL,
1971   PRIMARY KEY (`id`),
1972   KEY `club_template_id` (`club_template_id`),
1973   CONSTRAINT `club_template_fields_ibfk_1` FOREIGN KEY (`club_template_id`) REFERENCES `club_templates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
1974 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1975 /*!40101 SET character_set_client = @saved_cs_client */;
1976
1977 --
1978 -- Table structure for table `club_templates`
1979 --
1980
1981 DROP TABLE IF EXISTS `club_templates`;
1982 /*!40101 SET @saved_cs_client     = @@character_set_client */;
1983 /*!40101 SET character_set_client = utf8 */;
1984 CREATE TABLE `club_templates` (
1985   `id` int(11) NOT NULL AUTO_INCREMENT,
1986   `name` text NOT NULL,
1987   `description` mediumtext DEFAULT NULL,
1988   `is_enrollable_from_opac` tinyint(1) NOT NULL DEFAULT 0,
1989   `is_email_required` tinyint(1) NOT NULL DEFAULT 0,
1990   `branchcode` varchar(10) DEFAULT NULL,
1991   `date_created` timestamp NOT NULL DEFAULT current_timestamp(),
1992   `date_updated` timestamp NULL DEFAULT NULL,
1993   `is_deletable` tinyint(1) NOT NULL DEFAULT 1,
1994   PRIMARY KEY (`id`),
1995   KEY `ct_branchcode` (`branchcode`),
1996   CONSTRAINT `club_templates_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
1997 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1998 /*!40101 SET character_set_client = @saved_cs_client */;
1999
2000 --
2001 -- Table structure for table `clubs`
2002 --
2003
2004 DROP TABLE IF EXISTS `clubs`;
2005 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2006 /*!40101 SET character_set_client = utf8 */;
2007 CREATE TABLE `clubs` (
2008   `id` int(11) NOT NULL AUTO_INCREMENT,
2009   `club_template_id` int(11) NOT NULL,
2010   `name` text NOT NULL,
2011   `description` mediumtext DEFAULT NULL,
2012   `date_start` date DEFAULT NULL,
2013   `date_end` date DEFAULT NULL,
2014   `branchcode` varchar(10) DEFAULT NULL,
2015   `date_created` timestamp NOT NULL DEFAULT current_timestamp(),
2016   `date_updated` timestamp NULL DEFAULT NULL,
2017   PRIMARY KEY (`id`),
2018   KEY `club_template_id` (`club_template_id`),
2019   KEY `branchcode` (`branchcode`),
2020   CONSTRAINT `clubs_ibfk_1` FOREIGN KEY (`club_template_id`) REFERENCES `club_templates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
2021   CONSTRAINT `clubs_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
2022 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2023 /*!40101 SET character_set_client = @saved_cs_client */;
2024
2025 --
2026 -- Table structure for table `collections`
2027 --
2028
2029 DROP TABLE IF EXISTS `collections`;
2030 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2031 /*!40101 SET character_set_client = utf8 */;
2032 CREATE TABLE `collections` (
2033   `colId` int(11) NOT NULL AUTO_INCREMENT,
2034   `colTitle` varchar(100) NOT NULL DEFAULT '',
2035   `colDesc` mediumtext NOT NULL,
2036   `colBranchcode` varchar(10) DEFAULT NULL COMMENT '''branchcode for branch where item should be held.''',
2037   PRIMARY KEY (`colId`),
2038   KEY `collections_ibfk_1` (`colBranchcode`),
2039   CONSTRAINT `collections_ibfk_1` FOREIGN KEY (`colBranchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2040 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2041 /*!40101 SET character_set_client = @saved_cs_client */;
2042
2043 --
2044 -- Table structure for table `collections_tracking`
2045 --
2046
2047 DROP TABLE IF EXISTS `collections_tracking`;
2048 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2049 /*!40101 SET character_set_client = utf8 */;
2050 CREATE TABLE `collections_tracking` (
2051   `collections_tracking_id` int(11) NOT NULL AUTO_INCREMENT,
2052   `colId` int(11) NOT NULL DEFAULT 0 COMMENT 'collections.colId',
2053   `itemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'items.itemnumber',
2054   PRIMARY KEY (`collections_tracking_id`),
2055   KEY `collectionst_ibfk_1` (`colId`),
2056   CONSTRAINT `collectionst_ibfk_1` FOREIGN KEY (`colId`) REFERENCES `collections` (`colId`) ON DELETE CASCADE ON UPDATE CASCADE
2057 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2058 /*!40101 SET character_set_client = @saved_cs_client */;
2059
2060 --
2061 -- Table structure for table `columns_settings`
2062 --
2063
2064 DROP TABLE IF EXISTS `columns_settings`;
2065 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2066 /*!40101 SET character_set_client = utf8 */;
2067 CREATE TABLE `columns_settings` (
2068   `module` varchar(255) NOT NULL,
2069   `page` varchar(255) NOT NULL,
2070   `tablename` varchar(255) NOT NULL,
2071   `columnname` varchar(255) NOT NULL,
2072   `cannot_be_toggled` int(1) NOT NULL DEFAULT 0,
2073   `is_hidden` int(1) NOT NULL DEFAULT 0,
2074   PRIMARY KEY (`module`(191),`page`(191),`tablename`(191),`columnname`(191))
2075 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2076 /*!40101 SET character_set_client = @saved_cs_client */;
2077
2078 --
2079 -- Table structure for table `course_instructors`
2080 --
2081
2082 DROP TABLE IF EXISTS `course_instructors`;
2083 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2084 /*!40101 SET character_set_client = utf8 */;
2085 CREATE TABLE `course_instructors` (
2086   `course_id` int(11) NOT NULL COMMENT 'foreign key to link to courses.course_id',
2087   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key to link to borrowers.borrowernumber for instructor information',
2088   PRIMARY KEY (`course_id`,`borrowernumber`),
2089   KEY `borrowernumber` (`borrowernumber`),
2090   CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2091   CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`)
2092 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2093 /*!40101 SET character_set_client = @saved_cs_client */;
2094
2095 --
2096 -- Table structure for table `course_items`
2097 --
2098
2099 DROP TABLE IF EXISTS `course_items`;
2100 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2101 /*!40101 SET character_set_client = utf8 */;
2102 CREATE TABLE `course_items` (
2103   `ci_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'course item id',
2104   `itemnumber` int(11) DEFAULT NULL COMMENT 'items.itemnumber for the item on reserve',
2105   `biblionumber` int(11) NOT NULL COMMENT 'biblio.biblionumber for the bibliographic record on reserve',
2106   `itype` varchar(10) DEFAULT NULL COMMENT 'new itemtype for the item to have while on reserve (optional)',
2107   `itype_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates if itype should be changed while on course reserve',
2108   `itype_storage` varchar(10) DEFAULT NULL COMMENT 'a place to store the itype when item is on course reserve',
2109   `ccode` varchar(80) DEFAULT NULL COMMENT 'new category code for the item to have while on reserve (optional)',
2110   `ccode_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates if ccode should be changed while on course reserve',
2111   `ccode_storage` varchar(80) DEFAULT NULL COMMENT 'a place to store the ccode when item is on course reserve',
2112   `homebranch` varchar(10) DEFAULT NULL COMMENT 'new home branch for the item to have while on reserve (optional)',
2113   `homebranch_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates if homebranch should be changed while on course reserve',
2114   `homebranch_storage` varchar(10) DEFAULT NULL COMMENT 'a place to store the homebranch when item is on course reserve',
2115   `holdingbranch` varchar(10) DEFAULT NULL COMMENT 'new holding branch for the item to have while on reserve (optional)',
2116   `holdingbranch_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates if itype should be changed while on course reserve',
2117   `holdingbranch_storage` varchar(10) DEFAULT NULL COMMENT 'a place to store the holdingbranch when item is on course reserve',
2118   `location` varchar(80) DEFAULT NULL COMMENT 'new shelving location for the item to have while on reseve (optional)',
2119   `location_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates if itype should be changed while on course reserve',
2120   `location_storage` varchar(80) DEFAULT NULL COMMENT 'a place to store the location when the item is on course reserve',
2121   `enabled` enum('yes','no') NOT NULL DEFAULT 'no' COMMENT 'if at least one enabled course has this item on reseve, this field will be ''yes'', otherwise it will be ''no''',
2122   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2123   PRIMARY KEY (`ci_id`),
2124   UNIQUE KEY `itemnumber` (`itemnumber`),
2125   KEY `holdingbranch` (`holdingbranch`),
2126   KEY `fk_course_items_homebranch` (`homebranch`),
2127   KEY `fk_course_items_homebranch_storage` (`homebranch_storage`),
2128   KEY `fk_course_items_biblionumber` (`biblionumber`),
2129   CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2130   CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
2131   CONSTRAINT `fk_course_items_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2132   CONSTRAINT `fk_course_items_homebranch` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
2133   CONSTRAINT `fk_course_items_homebranch_storage` FOREIGN KEY (`homebranch_storage`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2134 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2135 /*!40101 SET character_set_client = @saved_cs_client */;
2136
2137 --
2138 -- Table structure for table `course_reserves`
2139 --
2140
2141 DROP TABLE IF EXISTS `course_reserves`;
2142 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2143 /*!40101 SET character_set_client = utf8 */;
2144 CREATE TABLE `course_reserves` (
2145   `cr_id` int(11) NOT NULL AUTO_INCREMENT,
2146   `course_id` int(11) NOT NULL COMMENT 'foreign key to link to courses.course_id',
2147   `ci_id` int(11) NOT NULL COMMENT 'foreign key to link to courses_items.ci_id',
2148   `staff_note` longtext DEFAULT NULL COMMENT 'staff only note',
2149   `public_note` longtext DEFAULT NULL COMMENT 'public, OPAC visible note',
2150   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2151   PRIMARY KEY (`cr_id`),
2152   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
2153   KEY `course_id` (`course_id`),
2154   KEY `course_reserves_ibfk_2` (`ci_id`),
2155   CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
2156   CONSTRAINT `course_reserves_ibfk_2` FOREIGN KEY (`ci_id`) REFERENCES `course_items` (`ci_id`) ON DELETE CASCADE ON UPDATE CASCADE
2157 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2158 /*!40101 SET character_set_client = @saved_cs_client */;
2159
2160 --
2161 -- Table structure for table `courses`
2162 --
2163
2164 DROP TABLE IF EXISTS `courses`;
2165 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2166 /*!40101 SET character_set_client = utf8 */;
2167 CREATE TABLE `courses` (
2168   `course_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the course',
2169   `department` varchar(80) DEFAULT NULL COMMENT 'the authorised value for the DEPARTMENT',
2170   `course_number` varchar(255) DEFAULT NULL COMMENT 'the ''course number'' assigned to a course',
2171   `section` varchar(255) DEFAULT NULL COMMENT 'the ''section'' of a course',
2172   `course_name` varchar(255) DEFAULT NULL COMMENT 'the name of the course',
2173   `term` varchar(80) DEFAULT NULL COMMENT 'the authorised value for the TERM',
2174   `staff_note` longtext DEFAULT NULL COMMENT 'the text of the staff only note',
2175   `public_note` longtext DEFAULT NULL COMMENT 'the text of the public / opac note',
2176   `students_count` varchar(20) DEFAULT NULL COMMENT 'how many students will be taking this course/section',
2177   `enabled` enum('yes','no') NOT NULL DEFAULT 'yes' COMMENT 'determines whether the course is active',
2178   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2179   PRIMARY KEY (`course_id`)
2180 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2181 /*!40101 SET character_set_client = @saved_cs_client */;
2182
2183 --
2184 -- Table structure for table `cover_images`
2185 --
2186
2187 DROP TABLE IF EXISTS `cover_images`;
2188 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2189 /*!40101 SET character_set_client = utf8 */;
2190 CREATE TABLE `cover_images` (
2191   `imagenumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the image',
2192   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key from biblio table to link to biblionumber',
2193   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key from item table to link to itemnumber',
2194   `mimetype` varchar(15) NOT NULL COMMENT 'image type',
2195   `imagefile` mediumblob NOT NULL COMMENT 'image file contents',
2196   `thumbnail` mediumblob NOT NULL COMMENT 'thumbnail file contents',
2197   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'image creation/update time',
2198   PRIMARY KEY (`imagenumber`),
2199   KEY `bibliocoverimage_fk1` (`biblionumber`),
2200   KEY `bibliocoverimage_fk2` (`itemnumber`),
2201   CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2202   CONSTRAINT `bibliocoverimage_fk2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
2203 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2204 /*!40101 SET character_set_client = @saved_cs_client */;
2205
2206 --
2207 -- Table structure for table `creator_batches`
2208 --
2209
2210 DROP TABLE IF EXISTS `creator_batches`;
2211 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2212 /*!40101 SET character_set_client = utf8 */;
2213 CREATE TABLE `creator_batches` (
2214   `label_id` int(11) NOT NULL AUTO_INCREMENT,
2215   `batch_id` int(10) NOT NULL DEFAULT 1,
2216   `description` mediumtext DEFAULT NULL,
2217   `item_number` int(11) DEFAULT NULL,
2218   `borrower_number` int(11) DEFAULT NULL,
2219   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2220   `branch_code` varchar(10) NOT NULL DEFAULT 'NB',
2221   `creator` char(15) NOT NULL DEFAULT 'Labels',
2222   PRIMARY KEY (`label_id`),
2223   KEY `branch_fk_constraint` (`branch_code`),
2224   KEY `item_fk_constraint` (`item_number`),
2225   KEY `borrower_fk_constraint` (`borrower_number`),
2226   CONSTRAINT `creator_batches_ibfk_1` FOREIGN KEY (`borrower_number`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2227   CONSTRAINT `creator_batches_ibfk_2` FOREIGN KEY (`branch_code`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
2228   CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE
2229 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2230 /*!40101 SET character_set_client = @saved_cs_client */;
2231
2232 --
2233 -- Table structure for table `creator_images`
2234 --
2235
2236 DROP TABLE IF EXISTS `creator_images`;
2237 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2238 /*!40101 SET character_set_client = utf8 */;
2239 CREATE TABLE `creator_images` (
2240   `image_id` int(4) NOT NULL AUTO_INCREMENT,
2241   `imagefile` mediumblob DEFAULT NULL,
2242   `image_name` char(20) NOT NULL DEFAULT 'DEFAULT',
2243   PRIMARY KEY (`image_id`),
2244   UNIQUE KEY `image_name_index` (`image_name`)
2245 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2246 /*!40101 SET character_set_client = @saved_cs_client */;
2247
2248 --
2249 -- Table structure for table `creator_layouts`
2250 --
2251
2252 DROP TABLE IF EXISTS `creator_layouts`;
2253 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2254 /*!40101 SET character_set_client = utf8 */;
2255 CREATE TABLE `creator_layouts` (
2256   `layout_id` int(4) NOT NULL AUTO_INCREMENT,
2257   `barcode_type` char(100) NOT NULL DEFAULT 'CODE39',
2258   `start_label` int(2) NOT NULL DEFAULT 1,
2259   `printing_type` char(32) NOT NULL DEFAULT 'BAR',
2260   `layout_name` char(25) NOT NULL DEFAULT 'DEFAULT',
2261   `guidebox` int(1) DEFAULT 0,
2262   `oblique_title` int(1) DEFAULT 1,
2263   `font` char(10) NOT NULL DEFAULT 'TR',
2264   `font_size` int(4) NOT NULL DEFAULT 10,
2265   `units` char(20) NOT NULL DEFAULT 'POINT',
2266   `callnum_split` int(1) DEFAULT 0,
2267   `text_justify` char(1) NOT NULL DEFAULT 'L',
2268   `format_string` varchar(210) NOT NULL DEFAULT 'barcode',
2269   `layout_xml` mediumtext NOT NULL,
2270   `creator` char(15) NOT NULL DEFAULT 'Labels',
2271   PRIMARY KEY (`layout_id`)
2272 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2273 /*!40101 SET character_set_client = @saved_cs_client */;
2274
2275 --
2276 -- Table structure for table `creator_templates`
2277 --
2278
2279 DROP TABLE IF EXISTS `creator_templates`;
2280 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2281 /*!40101 SET character_set_client = utf8 */;
2282 CREATE TABLE `creator_templates` (
2283   `template_id` int(4) NOT NULL AUTO_INCREMENT,
2284   `profile_id` int(4) DEFAULT NULL,
2285   `template_code` char(100) NOT NULL DEFAULT 'DEFAULT TEMPLATE',
2286   `template_desc` char(100) NOT NULL DEFAULT 'Default description',
2287   `page_width` float NOT NULL DEFAULT 0,
2288   `page_height` float NOT NULL DEFAULT 0,
2289   `label_width` float NOT NULL DEFAULT 0,
2290   `label_height` float NOT NULL DEFAULT 0,
2291   `top_text_margin` float NOT NULL DEFAULT 0,
2292   `left_text_margin` float NOT NULL DEFAULT 0,
2293   `top_margin` float NOT NULL DEFAULT 0,
2294   `left_margin` float NOT NULL DEFAULT 0,
2295   `cols` int(2) NOT NULL DEFAULT 0,
2296   `rows` int(2) NOT NULL DEFAULT 0,
2297   `col_gap` float NOT NULL DEFAULT 0,
2298   `row_gap` float NOT NULL DEFAULT 0,
2299   `units` char(20) NOT NULL DEFAULT 'POINT',
2300   `creator` char(15) NOT NULL DEFAULT 'Labels',
2301   PRIMARY KEY (`template_id`),
2302   KEY `template_profile_fk_constraint` (`profile_id`)
2303 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2304 /*!40101 SET character_set_client = @saved_cs_client */;
2305
2306 --
2307 -- Table structure for table `curbside_pickup_issues`
2308 --
2309
2310 DROP TABLE IF EXISTS `curbside_pickup_issues`;
2311 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2312 /*!40101 SET character_set_client = utf8 */;
2313 CREATE TABLE `curbside_pickup_issues` (
2314   `id` int(11) NOT NULL AUTO_INCREMENT,
2315   `curbside_pickup_id` int(11) NOT NULL,
2316   `issue_id` int(11) NOT NULL,
2317   `reserve_id` int(11) NOT NULL,
2318   PRIMARY KEY (`id`),
2319   KEY `curbside_pickup_id` (`curbside_pickup_id`),
2320   CONSTRAINT `curbside_pickup_issues_ibfk_1` FOREIGN KEY (`curbside_pickup_id`) REFERENCES `curbside_pickups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2321 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2322 /*!40101 SET character_set_client = @saved_cs_client */;
2323
2324 --
2325 -- Table structure for table `curbside_pickup_opening_slots`
2326 --
2327
2328 DROP TABLE IF EXISTS `curbside_pickup_opening_slots`;
2329 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2330 /*!40101 SET character_set_client = utf8 */;
2331 CREATE TABLE `curbside_pickup_opening_slots` (
2332   `id` int(11) NOT NULL AUTO_INCREMENT,
2333   `curbside_pickup_policy_id` int(11) NOT NULL,
2334   `day` tinyint(1) NOT NULL,
2335   `start_hour` int(2) NOT NULL,
2336   `start_minute` int(2) NOT NULL,
2337   `end_hour` int(2) NOT NULL,
2338   `end_minute` int(2) NOT NULL,
2339   PRIMARY KEY (`id`),
2340   KEY `curbside_pickup_policy_id` (`curbside_pickup_policy_id`),
2341   CONSTRAINT `curbside_pickup_opening_slots_ibfk_1` FOREIGN KEY (`curbside_pickup_policy_id`) REFERENCES `curbside_pickup_policy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2342 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2343 /*!40101 SET character_set_client = @saved_cs_client */;
2344
2345 --
2346 -- Table structure for table `curbside_pickup_policy`
2347 --
2348
2349 DROP TABLE IF EXISTS `curbside_pickup_policy`;
2350 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2351 /*!40101 SET character_set_client = utf8 */;
2352 CREATE TABLE `curbside_pickup_policy` (
2353   `id` int(11) NOT NULL AUTO_INCREMENT,
2354   `branchcode` varchar(10) NOT NULL,
2355   `enabled` tinyint(1) NOT NULL DEFAULT 0,
2356   `enable_waiting_holds_only` tinyint(1) NOT NULL DEFAULT 0,
2357   `pickup_interval` int(2) NOT NULL DEFAULT 0,
2358   `patrons_per_interval` int(2) NOT NULL DEFAULT 0,
2359   `patron_scheduled_pickup` tinyint(1) NOT NULL DEFAULT 0,
2360   PRIMARY KEY (`id`),
2361   UNIQUE KEY `branchcode` (`branchcode`),
2362   CONSTRAINT `curbside_pickup_policy_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2363 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2364 /*!40101 SET character_set_client = @saved_cs_client */;
2365
2366 --
2367 -- Table structure for table `curbside_pickups`
2368 --
2369
2370 DROP TABLE IF EXISTS `curbside_pickups`;
2371 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2372 /*!40101 SET character_set_client = utf8 */;
2373 CREATE TABLE `curbside_pickups` (
2374   `id` int(11) NOT NULL AUTO_INCREMENT,
2375   `borrowernumber` int(11) NOT NULL,
2376   `branchcode` varchar(10) NOT NULL,
2377   `scheduled_pickup_datetime` datetime NOT NULL,
2378   `staged_datetime` datetime DEFAULT NULL,
2379   `staged_by` int(11) DEFAULT NULL,
2380   `arrival_datetime` datetime DEFAULT NULL,
2381   `delivered_datetime` datetime DEFAULT NULL,
2382   `delivered_by` int(11) DEFAULT NULL,
2383   `notes` text DEFAULT NULL,
2384   PRIMARY KEY (`id`),
2385   KEY `branchcode` (`branchcode`),
2386   KEY `borrowernumber` (`borrowernumber`),
2387   KEY `staged_by` (`staged_by`),
2388   CONSTRAINT `curbside_pickups_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
2389   CONSTRAINT `curbside_pickups_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2390   CONSTRAINT `curbside_pickups_ibfk_3` FOREIGN KEY (`staged_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
2391 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2392 /*!40101 SET character_set_client = @saved_cs_client */;
2393
2394 --
2395 -- Table structure for table `currency`
2396 --
2397
2398 DROP TABLE IF EXISTS `currency`;
2399 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2400 /*!40101 SET character_set_client = utf8 */;
2401 CREATE TABLE `currency` (
2402   `currency` varchar(10) NOT NULL DEFAULT '',
2403   `symbol` varchar(5) DEFAULT NULL,
2404   `isocode` varchar(5) DEFAULT NULL,
2405   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2406   `rate` float(15,5) DEFAULT NULL,
2407   `active` tinyint(1) DEFAULT NULL,
2408   `archived` tinyint(1) DEFAULT 0,
2409   `p_sep_by_space` tinyint(1) DEFAULT 0,
2410   PRIMARY KEY (`currency`)
2411 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2412 /*!40101 SET character_set_client = @saved_cs_client */;
2413
2414 --
2415 -- Table structure for table `deletedbiblio`
2416 --
2417
2418 DROP TABLE IF EXISTS `deletedbiblio`;
2419 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2420 /*!40101 SET character_set_client = utf8 */;
2421 CREATE TABLE `deletedbiblio` (
2422   `biblionumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned to each bibliographic record',
2423   `frameworkcode` varchar(4) NOT NULL DEFAULT '' COMMENT 'foriegn key from the biblio_framework table to identify which framework was used in cataloging this record',
2424   `author` longtext DEFAULT NULL COMMENT 'statement of responsibility from MARC record (100$a in MARC21)',
2425   `title` longtext DEFAULT NULL COMMENT 'title (without the subtitle) from the MARC record (245$a in MARC21)',
2426   `medium` longtext DEFAULT NULL COMMENT 'medium from the MARC record (245$h in MARC21)',
2427   `subtitle` longtext DEFAULT NULL COMMENT 'remainder of the title from the MARC record (245$b in MARC21)',
2428   `part_number` longtext DEFAULT NULL COMMENT 'part number from the MARC record (245$n in MARC21)',
2429   `part_name` longtext DEFAULT NULL COMMENT 'part name from the MARC record (245$p in MARC21)',
2430   `unititle` longtext DEFAULT NULL COMMENT 'uniform title (without the subtitle) from the MARC record (240$a in MARC21)',
2431   `notes` longtext DEFAULT NULL COMMENT 'values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)',
2432   `serial` tinyint(1) DEFAULT NULL COMMENT 'Boolean indicating whether biblio is for a serial',
2433   `seriestitle` longtext DEFAULT NULL,
2434   `copyrightdate` smallint(6) DEFAULT NULL COMMENT 'publication or copyright date from the MARC record',
2435   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this record was last touched',
2436   `datecreated` date NOT NULL COMMENT 'the date this record was added to Koha',
2437   `abstract` longtext DEFAULT NULL COMMENT 'summary from the MARC record (520$a in MARC21)',
2438   PRIMARY KEY (`biblionumber`),
2439   KEY `blbnoidx` (`biblionumber`)
2440 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2441 /*!40101 SET character_set_client = @saved_cs_client */;
2442
2443 --
2444 -- Table structure for table `deletedbiblio_metadata`
2445 --
2446
2447 DROP TABLE IF EXISTS `deletedbiblio_metadata`;
2448 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2449 /*!40101 SET character_set_client = utf8 */;
2450 CREATE TABLE `deletedbiblio_metadata` (
2451   `id` int(11) NOT NULL AUTO_INCREMENT,
2452   `biblionumber` int(11) NOT NULL,
2453   `format` varchar(16) NOT NULL,
2454   `schema` varchar(16) NOT NULL,
2455   `metadata` longtext NOT NULL,
2456   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2457   PRIMARY KEY (`id`),
2458   UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`schema`),
2459   KEY `timestamp` (`timestamp`),
2460   CONSTRAINT `deletedrecord_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `deletedbiblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
2461 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2462 /*!40101 SET character_set_client = @saved_cs_client */;
2463
2464 --
2465 -- Table structure for table `deletedbiblioitems`
2466 --
2467
2468 DROP TABLE IF EXISTS `deletedbiblioitems`;
2469 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2470 /*!40101 SET character_set_client = utf8 */;
2471 CREATE TABLE `deletedbiblioitems` (
2472   `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'primary key, unique identifier assigned by Koha',
2473   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key linking this table to the biblio table',
2474   `volume` longtext DEFAULT NULL,
2475   `number` longtext DEFAULT NULL,
2476   `itemtype` varchar(10) DEFAULT NULL COMMENT 'biblio level item type (MARC21 942$c)',
2477   `isbn` longtext DEFAULT NULL COMMENT 'ISBN (MARC21 020$a)',
2478   `issn` longtext DEFAULT NULL COMMENT 'ISSN (MARC21 022$a)',
2479   `ean` longtext DEFAULT NULL,
2480   `publicationyear` mediumtext DEFAULT NULL,
2481   `publishercode` varchar(255) DEFAULT NULL COMMENT 'publisher (MARC21 260$b)',
2482   `volumedate` date DEFAULT NULL,
2483   `volumedesc` mediumtext DEFAULT NULL COMMENT 'volume information (MARC21 362$a)',
2484   `collectiontitle` longtext DEFAULT NULL,
2485   `collectionissn` mediumtext DEFAULT NULL,
2486   `collectionvolume` longtext DEFAULT NULL,
2487   `editionstatement` mediumtext DEFAULT NULL,
2488   `editionresponsibility` mediumtext DEFAULT NULL,
2489   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
2490   `illus` varchar(255) DEFAULT NULL COMMENT 'illustrations (MARC21 300$b)',
2491   `pages` varchar(255) DEFAULT NULL COMMENT 'number of pages (MARC21 300$c)',
2492   `notes` longtext DEFAULT NULL,
2493   `size` varchar(255) DEFAULT NULL COMMENT 'material size (MARC21 300$c)',
2494   `place` varchar(255) DEFAULT NULL COMMENT 'publication place (MARC21 260$a)',
2495   `lccn` varchar(25) DEFAULT NULL COMMENT 'library of congress control number (MARC21 010$a)',
2496   `url` mediumtext DEFAULT NULL COMMENT 'url (MARC21 856$u)',
2497   `cn_source` varchar(10) DEFAULT NULL COMMENT 'classification source (MARC21 942$2)',
2498   `cn_class` varchar(30) DEFAULT NULL,
2499   `cn_item` varchar(10) DEFAULT NULL,
2500   `cn_suffix` varchar(10) DEFAULT NULL,
2501   `cn_sort` varchar(255) DEFAULT NULL COMMENT 'normalized version of the call number used for sorting',
2502   `agerestriction` varchar(255) DEFAULT NULL COMMENT 'target audience/age restriction from the bib record (MARC21 521$a)',
2503   `totalissues` int(10) DEFAULT NULL,
2504   PRIMARY KEY (`biblioitemnumber`),
2505   KEY `bibinoidx` (`biblioitemnumber`),
2506   KEY `bibnoidx` (`biblionumber`),
2507   KEY `itemtype_idx` (`itemtype`),
2508   KEY `isbn` (`isbn`(191)),
2509   KEY `ean` (`ean`(191)),
2510   KEY `publishercode` (`publishercode`(191)),
2511   KEY `timestamp` (`timestamp`)
2512 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2513 /*!40101 SET character_set_client = @saved_cs_client */;
2514
2515 --
2516 -- Table structure for table `deletedborrowers`
2517 --
2518
2519 DROP TABLE IF EXISTS `deletedborrowers`;
2520 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2521 /*!40101 SET character_set_client = utf8 */;
2522 CREATE TABLE `deletedborrowers` (
2523   `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'primary key, Koha assigned ID number for patrons/borrowers',
2524   `cardnumber` varchar(32) DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2525   `surname` longtext DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2526   `firstname` mediumtext DEFAULT NULL COMMENT 'patron/borrower''s first name',
2527   `middle_name` longtext DEFAULT NULL COMMENT 'patron/borrower''s middle name',
2528   `title` longtext DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2529   `othernames` longtext DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2530   `initials` mediumtext DEFAULT NULL COMMENT 'initials for your patron/borrower',
2531   `pronouns` longtext DEFAULT NULL COMMENT 'patron/borrower pronouns',
2532   `streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your patron/borrower''s primary address',
2533   `streettype` tinytext DEFAULT NULL COMMENT 'the street type (Rd., Blvd, etc) for your patron/borrower''s primary address',
2534   `address` longtext DEFAULT NULL COMMENT 'the first address line for your patron/borrower''s primary address',
2535   `address2` mediumtext DEFAULT NULL COMMENT 'the second address line for your patron/borrower''s primary address',
2536   `city` longtext DEFAULT NULL COMMENT 'the city or town for your patron/borrower''s primary address',
2537   `state` mediumtext DEFAULT NULL COMMENT 'the state or province for your patron/borrower''s primary address',
2538   `zipcode` tinytext DEFAULT NULL COMMENT 'the zip or postal code for your patron/borrower''s primary address',
2539   `country` mediumtext DEFAULT NULL COMMENT 'the country for your patron/borrower''s primary address',
2540   `email` longtext DEFAULT NULL COMMENT 'the primary email address for your patron/borrower''s primary address',
2541   `phone` mediumtext DEFAULT NULL COMMENT 'the primary phone number for your patron/borrower''s primary address',
2542   `mobile` tinytext DEFAULT NULL COMMENT 'the other phone number for your patron/borrower''s primary address',
2543   `fax` longtext DEFAULT NULL COMMENT 'the fax number for your patron/borrower''s primary address',
2544   `emailpro` mediumtext DEFAULT NULL COMMENT 'the secondary email addres for your patron/borrower''s primary address',
2545   `phonepro` mediumtext DEFAULT NULL COMMENT 'the secondary phone number for your patron/borrower''s primary address',
2546   `B_streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your patron/borrower''s alternate address',
2547   `B_streettype` tinytext DEFAULT NULL COMMENT 'the street type (Rd., Blvd, etc) for your patron/borrower''s alternate address',
2548   `B_address` mediumtext DEFAULT NULL COMMENT 'the first address line for your patron/borrower''s alternate address',
2549   `B_address2` mediumtext DEFAULT NULL COMMENT 'the second address line for your patron/borrower''s alternate address',
2550   `B_city` longtext DEFAULT NULL COMMENT 'the city or town for your patron/borrower''s alternate address',
2551   `B_state` mediumtext DEFAULT NULL COMMENT 'the state for your patron/borrower''s alternate address',
2552   `B_zipcode` tinytext DEFAULT NULL COMMENT 'the zip or postal code for your patron/borrower''s alternate address',
2553   `B_country` mediumtext DEFAULT NULL COMMENT 'the country for your patron/borrower''s alternate address',
2554   `B_email` mediumtext DEFAULT NULL COMMENT 'the patron/borrower''s alternate email address',
2555   `B_phone` longtext DEFAULT NULL COMMENT 'the patron/borrower''s alternate phone number',
2556   `dateofbirth` date DEFAULT NULL COMMENT 'the patron/borrower''s date of birth (YYYY-MM-DD)',
2557   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the branches table, includes the code of the patron/borrower''s home branch',
2558   `categorycode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the categories table, includes the code of the patron category',
2559   `dateenrolled` date DEFAULT NULL COMMENT 'date the patron was added to Koha (YYYY-MM-DD)',
2560   `dateexpiry` date DEFAULT NULL COMMENT 'date the patron/borrower''s card is set to expire (YYYY-MM-DD)',
2561   `password_expiration_date` date DEFAULT NULL COMMENT 'date the patron/borrower''s password is set to expire (YYYY-MM-DD)',
2562   `date_renewed` date DEFAULT NULL COMMENT 'date the patron/borrower''s card was last renewed',
2563   `gonenoaddress` tinyint(1) DEFAULT NULL COMMENT 'set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address',
2564   `lost` tinyint(1) DEFAULT NULL COMMENT 'set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card',
2565   `debarred` date DEFAULT NULL COMMENT 'until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD)',
2566   `debarredcomment` varchar(255) DEFAULT NULL COMMENT 'comment on the stop of patron',
2567   `contactname` longtext DEFAULT NULL COMMENT 'used for children and profesionals to include surname or last name of guarantor or organization name',
2568   `contactfirstname` mediumtext DEFAULT NULL COMMENT 'used for children to include first name of guarantor',
2569   `contacttitle` mediumtext DEFAULT NULL COMMENT 'used for children to include title (Mr., Mrs., etc) of guarantor',
2570   `borrowernotes` longtext DEFAULT NULL COMMENT 'a note on the patron/borrower''s account that is only visible in the staff interface',
2571   `relationship` varchar(100) DEFAULT NULL COMMENT 'used for children to include the relationship to their guarantor',
2572   `sex` varchar(1) DEFAULT NULL COMMENT 'patron/borrower''s gender',
2573   `password` varchar(60) DEFAULT NULL COMMENT 'patron/borrower''s encrypted password',
2574   `secret` mediumtext DEFAULT NULL COMMENT 'Secret for 2FA',
2575   `auth_method` enum('password','two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method',
2576   `flags` int(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions',
2577   `userid` varchar(75) DEFAULT NULL COMMENT 'patron/borrower''s opac and/or staff interface log in',
2578   `opacnote` longtext DEFAULT NULL COMMENT 'a note on the patron/borrower''s account that is visible in the OPAC and staff interface',
2579   `contactnote` varchar(255) DEFAULT NULL COMMENT 'a note related to the patron/borrower''s alternate address',
2580   `sort1` varchar(80) DEFAULT NULL COMMENT 'a field that can be used for any information unique to the library',
2581   `sort2` varchar(80) DEFAULT NULL COMMENT 'a field that can be used for any information unique to the library',
2582   `altcontactfirstname` mediumtext DEFAULT NULL COMMENT 'first name of alternate contact for the patron/borrower',
2583   `altcontactsurname` mediumtext DEFAULT NULL COMMENT 'surname or last name of the alternate contact for the patron/borrower',
2584   `altcontactaddress1` mediumtext DEFAULT NULL COMMENT 'the first address line for the alternate contact for the patron/borrower',
2585   `altcontactaddress2` mediumtext DEFAULT NULL COMMENT 'the second address line for the alternate contact for the patron/borrower',
2586   `altcontactaddress3` mediumtext DEFAULT NULL COMMENT 'the city for the alternate contact for the patron/borrower',
2587   `altcontactstate` mediumtext DEFAULT NULL COMMENT 'the state for the alternate contact for the patron/borrower',
2588   `altcontactzipcode` mediumtext DEFAULT NULL COMMENT 'the zipcode for the alternate contact for the patron/borrower',
2589   `altcontactcountry` mediumtext DEFAULT NULL COMMENT 'the country for the alternate contact for the patron/borrower',
2590   `altcontactphone` mediumtext DEFAULT NULL COMMENT 'the phone number for the alternate contact for the patron/borrower',
2591   `smsalertnumber` varchar(50) DEFAULT NULL COMMENT 'the mobile phone number where the patron/borrower would like to receive notices (if SMS turned on)',
2592   `sms_provider_id` int(11) DEFAULT NULL COMMENT 'the provider of the mobile phone number defined in smsalertnumber',
2593   `privacy` int(11) NOT NULL DEFAULT 1 COMMENT 'patron/borrower''s privacy settings related to their checkout history  KEY `borrowernumber` (`borrowernumber`),',
2594   `privacy_guarantor_fines` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'controls if relatives can see this patron''s fines',
2595   `privacy_guarantor_checkouts` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'controls if relatives can see this patron''s checkouts',
2596   `checkprevcheckout` varchar(7) NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.',
2597   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'time of last change could be useful for synchronization with external systems (among others)',
2598   `lastseen` datetime DEFAULT NULL COMMENT 'last time a patron has been seen (connected at the OPAC or staff interface)',
2599   `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang to use to send notices to this patron',
2600   `login_attempts` int(4) NOT NULL DEFAULT 0 COMMENT 'number of failed login attemps',
2601   `overdrive_auth_token` mediumtext DEFAULT NULL COMMENT 'persist OverDrive auth token',
2602   `anonymized` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'flag for data anonymization',
2603   `autorenew_checkouts` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'flag for allowing auto-renewal',
2604   `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes',
2605   KEY `borrowernumber` (`borrowernumber`),
2606   KEY `cardnumber` (`cardnumber`),
2607   KEY `sms_provider_id` (`sms_provider_id`)
2608 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2609 /*!40101 SET character_set_client = @saved_cs_client */;
2610
2611 --
2612 -- Table structure for table `deleteditems`
2613 --
2614
2615 DROP TABLE IF EXISTS `deleteditems`;
2616 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2617 /*!40101 SET character_set_client = utf8 */;
2618 CREATE TABLE `deleteditems` (
2619   `itemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'primary key and unique identifier added by Koha',
2620   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
2621   `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
2622   `barcode` varchar(20) DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
2623   `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
2624   `booksellerid` longtext DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
2625   `homebranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that owns this item (MARC21 952$a)',
2626   `price` decimal(8,2) DEFAULT NULL COMMENT 'purchase price (MARC21 952$g)',
2627   `replacementprice` decimal(8,2) DEFAULT NULL COMMENT 'cost the library charges to replace the item if it has been marked lost (MARC21 952$v)',
2628   `replacementpricedate` date DEFAULT NULL COMMENT 'the date the price is effective from (MARC21 952$w)',
2629   `datelastborrowed` date DEFAULT NULL COMMENT 'the date the item was last checked out',
2630   `datelastseen` date DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)',
2631   `stack` tinyint(1) DEFAULT NULL,
2632   `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining why this item is not for loan (MARC21 952$7)',
2633   `damaged` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as damaged (MARC21 952$4)',
2634   `damaged_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as damaged, NULL if not damaged',
2635   `itemlost` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as lost (MARC21 952$1)',
2636   `itemlost_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as lost, NULL if not lost',
2637   `withdrawn` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as withdrawn (MARC21 952$0)',
2638   `withdrawn_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as withdrawn, NULL if not withdrawn',
2639   `itemcallnumber` varchar(255) DEFAULT NULL COMMENT 'call number for this item (MARC21 952$o)',
2640   `coded_location_qualifier` varchar(10) DEFAULT NULL COMMENT 'coded location qualifier(MARC21 952$f)',
2641   `issues` smallint(6) DEFAULT 0 COMMENT 'number of times this item has been checked out',
2642   `renewals` smallint(6) DEFAULT NULL COMMENT 'number of times this item has been renewed',
2643   `reserves` smallint(6) DEFAULT NULL COMMENT 'number of times this item has been placed on hold/reserved',
2644   `restricted` tinyint(1) DEFAULT NULL COMMENT 'authorized value defining use restrictions for this item (MARC21 952$5)',
2645   `itemnotes` longtext DEFAULT NULL COMMENT 'public notes on this item (MARC21 952$z)',
2646   `itemnotes_nonpublic` longtext DEFAULT NULL COMMENT 'non-public notes on this item (MARC21 952$x)',
2647   `holdingbranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)',
2648   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this item was last altered',
2649   `deleted_on` datetime DEFAULT NULL COMMENT 'date/time of deletion',
2650   `location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)',
2651   `permanent_location` varchar(80) DEFAULT NULL COMMENT 'linked to the CART and PROC temporary locations feature, stores the permanent shelving location',
2652   `onloan` date DEFAULT NULL COMMENT 'defines if item is checked out (NULL for not checked out, and due date for checked out)',
2653   `cn_source` varchar(10) DEFAULT NULL COMMENT 'classification source used on this item (MARC21 952$2)',
2654   `cn_sort` varchar(255) DEFAULT NULL COMMENT 'normalized form of the call number (MARC21 952$o) used for sorting',
2655   `ccode` varchar(80) DEFAULT NULL COMMENT 'authorized value for the collection code associated with this item (MARC21 952$8)',
2656   `materials` mediumtext DEFAULT NULL COMMENT 'materials specified (MARC21 952$3)',
2657   `uri` mediumtext DEFAULT NULL COMMENT 'URL for the item (MARC21 952$u)',
2658   `itype` varchar(10) DEFAULT NULL COMMENT 'foreign key from the itemtypes table defining the type for this item (MARC21 952$y)',
2659   `more_subfields_xml` longtext DEFAULT NULL COMMENT 'additional 952 subfields in XML format',
2660   `enumchron` mediumtext DEFAULT NULL COMMENT 'serial enumeration/chronology for the item (MARC21 952$h)',
2661   `copynumber` varchar(32) DEFAULT NULL COMMENT 'copy number (MARC21 952$t)',
2662   `stocknumber` varchar(32) DEFAULT NULL COMMENT 'inventory number (MARC21 952$i)',
2663   `new_status` varchar(32) DEFAULT NULL COMMENT '''new'' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob.',
2664   `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude this item from local holds priority',
2665   PRIMARY KEY (`itemnumber`),
2666   KEY `delitembarcodeidx` (`barcode`),
2667   KEY `delitemstocknumberidx` (`stocknumber`),
2668   KEY `delitembinoidx` (`biblioitemnumber`),
2669   KEY `delitembibnoidx` (`biblionumber`),
2670   KEY `delhomebranch` (`homebranch`),
2671   KEY `delholdingbranch` (`holdingbranch`),
2672   KEY `itype_idx` (`itype`),
2673   KEY `timestamp` (`timestamp`)
2674 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2675 /*!40101 SET character_set_client = @saved_cs_client */;
2676
2677 --
2678 -- Table structure for table `desks`
2679 --
2680
2681 DROP TABLE IF EXISTS `desks`;
2682 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2683 /*!40101 SET character_set_client = utf8 */;
2684 CREATE TABLE `desks` (
2685   `desk_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
2686   `desk_name` varchar(100) NOT NULL DEFAULT '' COMMENT 'name of the desk',
2687   `branchcode` varchar(10) NOT NULL COMMENT 'library the desk is located at',
2688   PRIMARY KEY (`desk_id`),
2689   KEY `fk_desks_branchcode` (`branchcode`),
2690   CONSTRAINT `fk_desks_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2691 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2692 /*!40101 SET character_set_client = @saved_cs_client */;
2693
2694 --
2695 -- Table structure for table `discharges`
2696 --
2697
2698 DROP TABLE IF EXISTS `discharges`;
2699 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2700 /*!40101 SET character_set_client = utf8 */;
2701 CREATE TABLE `discharges` (
2702   `discharge_id` int(11) NOT NULL AUTO_INCREMENT,
2703   `borrower` int(11) DEFAULT NULL,
2704   `needed` timestamp NULL DEFAULT NULL,
2705   `validated` timestamp NULL DEFAULT NULL,
2706   PRIMARY KEY (`discharge_id`),
2707   KEY `borrower_discharges_ibfk1` (`borrower`),
2708   CONSTRAINT `borrower_discharges_ibfk1` FOREIGN KEY (`borrower`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2709 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2710 /*!40101 SET character_set_client = @saved_cs_client */;
2711
2712 --
2713 -- Table structure for table `edifact_ean`
2714 --
2715
2716 DROP TABLE IF EXISTS `edifact_ean`;
2717 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2718 /*!40101 SET character_set_client = utf8 */;
2719 CREATE TABLE `edifact_ean` (
2720   `ee_id` int(11) NOT NULL AUTO_INCREMENT,
2721   `description` varchar(128) DEFAULT NULL,
2722   `branchcode` varchar(10) DEFAULT NULL,
2723   `ean` varchar(15) NOT NULL,
2724   `id_code_qualifier` varchar(3) NOT NULL DEFAULT '14',
2725   PRIMARY KEY (`ee_id`),
2726   KEY `efk_branchcode` (`branchcode`),
2727   CONSTRAINT `efk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
2728 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2729 /*!40101 SET character_set_client = @saved_cs_client */;
2730
2731 --
2732 -- Table structure for table `edifact_messages`
2733 --
2734
2735 DROP TABLE IF EXISTS `edifact_messages`;
2736 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2737 /*!40101 SET character_set_client = utf8 */;
2738 CREATE TABLE `edifact_messages` (
2739   `id` int(11) NOT NULL AUTO_INCREMENT,
2740   `message_type` varchar(10) NOT NULL,
2741   `transfer_date` date DEFAULT NULL,
2742   `vendor_id` int(11) DEFAULT NULL,
2743   `edi_acct` int(11) DEFAULT NULL,
2744   `status` mediumtext DEFAULT NULL,
2745   `basketno` int(11) DEFAULT NULL,
2746   `raw_msg` longtext DEFAULT NULL,
2747   `filename` mediumtext DEFAULT NULL,
2748   `deleted` tinyint(1) NOT NULL DEFAULT 0,
2749   PRIMARY KEY (`id`),
2750   KEY `vendorid` (`vendor_id`),
2751   KEY `ediacct` (`edi_acct`),
2752   KEY `basketno` (`basketno`),
2753   CONSTRAINT `emfk_basketno` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2754   CONSTRAINT `emfk_edi_acct` FOREIGN KEY (`edi_acct`) REFERENCES `vendor_edi_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
2755   CONSTRAINT `emfk_vendor` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2756 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2757 /*!40101 SET character_set_client = @saved_cs_client */;
2758
2759 --
2760 -- Table structure for table `erm_agreement_licenses`
2761 --
2762
2763 DROP TABLE IF EXISTS `erm_agreement_licenses`;
2764 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2765 /*!40101 SET character_set_client = utf8 */;
2766 CREATE TABLE `erm_agreement_licenses` (
2767   `agreement_license_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2768   `agreement_id` int(11) NOT NULL COMMENT 'link to the agreement',
2769   `license_id` int(11) NOT NULL COMMENT 'link to the license',
2770   `status` varchar(80) NOT NULL COMMENT 'current status of the license',
2771   `physical_location` varchar(80) DEFAULT NULL COMMENT 'physical location of the license',
2772   `notes` mediumtext DEFAULT NULL COMMENT 'notes about this license',
2773   `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the license',
2774   PRIMARY KEY (`agreement_license_id`),
2775   UNIQUE KEY `erm_agreement_licenses_uniq` (`agreement_id`,`license_id`),
2776   KEY `erm_agreement_licenses_ibfk_2` (`license_id`),
2777   CONSTRAINT `erm_agreement_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2778   CONSTRAINT `erm_agreement_licenses_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE
2779 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2780 /*!40101 SET character_set_client = @saved_cs_client */;
2781
2782 --
2783 -- Table structure for table `erm_agreement_periods`
2784 --
2785
2786 DROP TABLE IF EXISTS `erm_agreement_periods`;
2787 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2788 /*!40101 SET character_set_client = utf8 */;
2789 CREATE TABLE `erm_agreement_periods` (
2790   `agreement_period_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2791   `agreement_id` int(11) NOT NULL COMMENT 'link to the agreement',
2792   `started_on` date NOT NULL COMMENT 'start of the agreement period',
2793   `ended_on` date DEFAULT NULL COMMENT 'end of the agreement period',
2794   `cancellation_deadline` date DEFAULT NULL COMMENT 'Deadline for the cancellation',
2795   `notes` mediumtext DEFAULT NULL COMMENT 'notes about this period',
2796   PRIMARY KEY (`agreement_period_id`),
2797   KEY `erm_agreement_periods_ibfk_1` (`agreement_id`),
2798   CONSTRAINT `erm_agreement_periods_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE
2799 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2800 /*!40101 SET character_set_client = @saved_cs_client */;
2801
2802 --
2803 -- Table structure for table `erm_agreement_relationships`
2804 --
2805
2806 DROP TABLE IF EXISTS `erm_agreement_relationships`;
2807 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2808 /*!40101 SET character_set_client = utf8 */;
2809 CREATE TABLE `erm_agreement_relationships` (
2810   `agreement_id` int(11) NOT NULL COMMENT 'link to the agreement',
2811   `related_agreement_id` int(11) NOT NULL COMMENT 'link to the related agreement',
2812   `relationship` enum('supersedes','is-superseded-by','provides_post-cancellation_access_for','has-post-cancellation-access-in','tracks_demand-driven_acquisitions_for','has-demand-driven-acquisitions-in','has_backfile_in','has_frontfile_in','related_to') NOT NULL COMMENT 'relationship between the two agreements',
2813   `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship',
2814   PRIMARY KEY (`agreement_id`,`related_agreement_id`),
2815   KEY `erm_agreement_relationships_ibfk_2` (`related_agreement_id`),
2816   CONSTRAINT `erm_agreement_relationships_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2817   CONSTRAINT `erm_agreement_relationships_ibfk_2` FOREIGN KEY (`related_agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE
2818 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2819 /*!40101 SET character_set_client = @saved_cs_client */;
2820
2821 --
2822 -- Table structure for table `erm_agreements`
2823 --
2824
2825 DROP TABLE IF EXISTS `erm_agreements`;
2826 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2827 /*!40101 SET character_set_client = utf8 */;
2828 CREATE TABLE `erm_agreements` (
2829   `agreement_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2830   `vendor_id` int(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
2831   `name` varchar(255) NOT NULL COMMENT 'name of the agreement',
2832   `description` longtext DEFAULT NULL COMMENT 'description of the agreement',
2833   `status` varchar(80) NOT NULL COMMENT 'current status of the agreement',
2834   `closure_reason` varchar(80) DEFAULT NULL COMMENT 'reason of the closure',
2835   `is_perpetual` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the agreement perpetual',
2836   `renewal_priority` varchar(80) DEFAULT NULL COMMENT 'priority of the renewal',
2837   `license_info` varchar(80) DEFAULT NULL COMMENT 'info about the license',
2838   PRIMARY KEY (`agreement_id`),
2839   KEY `erm_agreements_ibfk_1` (`vendor_id`),
2840   CONSTRAINT `erm_agreements_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2841 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2842 /*!40101 SET character_set_client = @saved_cs_client */;
2843
2844 --
2845 -- Table structure for table `erm_documents`
2846 --
2847
2848 DROP TABLE IF EXISTS `erm_documents`;
2849 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2850 /*!40101 SET character_set_client = utf8 */;
2851 CREATE TABLE `erm_documents` (
2852   `document_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2853   `agreement_id` int(11) DEFAULT NULL COMMENT 'link to the agreement',
2854   `license_id` int(11) DEFAULT NULL COMMENT 'link to the license',
2855   `file_name` varchar(255) DEFAULT NULL COMMENT 'name of the file',
2856   `file_type` varchar(255) DEFAULT NULL COMMENT 'type of the file',
2857   `file_description` varchar(255) DEFAULT NULL COMMENT 'description of the file',
2858   `file_content` longblob DEFAULT NULL COMMENT 'the content of the file',
2859   `uploaded_on` datetime DEFAULT NULL COMMENT 'datetime when the file as attached',
2860   `physical_location` varchar(255) DEFAULT NULL COMMENT 'physical location of the document',
2861   `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the document',
2862   `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship',
2863   PRIMARY KEY (`document_id`),
2864   KEY `erm_documents_ibfk_1` (`agreement_id`),
2865   KEY `erm_documents_ibfk_2` (`license_id`),
2866   CONSTRAINT `erm_documents_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2867   CONSTRAINT `erm_documents_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE
2868 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2869 /*!40101 SET character_set_client = @saved_cs_client */;
2870
2871 --
2872 -- Table structure for table `erm_eholdings_packages`
2873 --
2874
2875 DROP TABLE IF EXISTS `erm_eholdings_packages`;
2876 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2877 /*!40101 SET character_set_client = utf8 */;
2878 CREATE TABLE `erm_eholdings_packages` (
2879   `package_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2880   `vendor_id` int(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
2881   `name` varchar(255) NOT NULL COMMENT 'name of the package',
2882   `external_id` varchar(255) DEFAULT NULL COMMENT 'External key',
2883   `provider` enum('ebsco') DEFAULT NULL COMMENT 'External provider',
2884   `package_type` varchar(80) DEFAULT NULL COMMENT 'type of the package',
2885   `content_type` varchar(80) DEFAULT NULL COMMENT 'type of the package',
2886   `notes` mediumtext DEFAULT NULL COMMENT 'notes about this package',
2887   `created_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date of creation of the package',
2888   PRIMARY KEY (`package_id`),
2889   KEY `erm_eholdings_packages_ibfk_1` (`vendor_id`),
2890   CONSTRAINT `erm_eholdings_packages_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2891 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2892 /*!40101 SET character_set_client = @saved_cs_client */;
2893
2894 --
2895 -- Table structure for table `erm_eholdings_packages_agreements`
2896 --
2897
2898 DROP TABLE IF EXISTS `erm_eholdings_packages_agreements`;
2899 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2900 /*!40101 SET character_set_client = utf8 */;
2901 CREATE TABLE `erm_eholdings_packages_agreements` (
2902   `package_id` int(11) NOT NULL COMMENT 'link to the package',
2903   `agreement_id` int(11) NOT NULL COMMENT 'link to the agreement',
2904   PRIMARY KEY (`package_id`,`agreement_id`),
2905   KEY `erm_eholdings_packages_agreements_ibfk_2` (`agreement_id`),
2906   CONSTRAINT `erm_eholdings_packages_agreements_ibfk_1` FOREIGN KEY (`package_id`) REFERENCES `erm_eholdings_packages` (`package_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2907   CONSTRAINT `erm_eholdings_packages_agreements_ibfk_2` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE
2908 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2909 /*!40101 SET character_set_client = @saved_cs_client */;
2910
2911 --
2912 -- Table structure for table `erm_eholdings_resources`
2913 --
2914
2915 DROP TABLE IF EXISTS `erm_eholdings_resources`;
2916 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2917 /*!40101 SET character_set_client = utf8 */;
2918 CREATE TABLE `erm_eholdings_resources` (
2919   `resource_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2920   `title_id` int(11) NOT NULL,
2921   `package_id` int(11) NOT NULL,
2922   `vendor_id` int(11) DEFAULT NULL,
2923   `started_on` date DEFAULT NULL,
2924   `ended_on` date DEFAULT NULL,
2925   `proxy` varchar(80) DEFAULT NULL,
2926   PRIMARY KEY (`resource_id`),
2927   UNIQUE KEY `erm_eholdings_resources_uniq` (`title_id`,`package_id`),
2928   KEY `erm_eholdings_resources_ibfk_2` (`package_id`),
2929   KEY `erm_eholdings_resources_ibfk_3` (`vendor_id`),
2930   CONSTRAINT `erm_eholdings_resources_ibfk_1` FOREIGN KEY (`title_id`) REFERENCES `erm_eholdings_titles` (`title_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2931   CONSTRAINT `erm_eholdings_resources_ibfk_2` FOREIGN KEY (`package_id`) REFERENCES `erm_eholdings_packages` (`package_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2932   CONSTRAINT `erm_eholdings_resources_ibfk_3` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2933 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2934 /*!40101 SET character_set_client = @saved_cs_client */;
2935
2936 --
2937 -- Table structure for table `erm_eholdings_titles`
2938 --
2939
2940 DROP TABLE IF EXISTS `erm_eholdings_titles`;
2941 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2942 /*!40101 SET character_set_client = utf8 */;
2943 CREATE TABLE `erm_eholdings_titles` (
2944   `title_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2945   `biblio_id` int(11) DEFAULT NULL,
2946   `publication_title` varchar(255) DEFAULT NULL,
2947   `external_id` varchar(255) DEFAULT NULL,
2948   `print_identifier` varchar(255) DEFAULT NULL,
2949   `online_identifier` varchar(255) DEFAULT NULL,
2950   `date_first_issue_online` varchar(255) DEFAULT NULL,
2951   `num_first_vol_online` varchar(255) DEFAULT NULL,
2952   `num_first_issue_online` varchar(255) DEFAULT NULL,
2953   `date_last_issue_online` varchar(255) DEFAULT NULL,
2954   `num_last_vol_online` varchar(255) DEFAULT NULL,
2955   `num_last_issue_online` varchar(255) DEFAULT NULL,
2956   `title_url` varchar(255) DEFAULT NULL,
2957   `first_author` varchar(255) DEFAULT NULL,
2958   `embargo_info` varchar(255) DEFAULT NULL,
2959   `coverage_depth` varchar(255) DEFAULT NULL,
2960   `notes` varchar(255) DEFAULT NULL,
2961   `publisher_name` varchar(255) DEFAULT NULL,
2962   `publication_type` varchar(80) DEFAULT NULL,
2963   `date_monograph_published_print` varchar(255) DEFAULT NULL,
2964   `date_monograph_published_online` varchar(255) DEFAULT NULL,
2965   `monograph_volume` varchar(255) DEFAULT NULL,
2966   `monograph_edition` varchar(255) DEFAULT NULL,
2967   `first_editor` varchar(255) DEFAULT NULL,
2968   `parent_publication_title_id` varchar(255) DEFAULT NULL,
2969   `preceeding_publication_title_id` varchar(255) DEFAULT NULL,
2970   `access_type` varchar(255) DEFAULT NULL,
2971   PRIMARY KEY (`title_id`),
2972   KEY `erm_eholdings_titles_ibfk_2` (`biblio_id`),
2973   CONSTRAINT `erm_eholdings_titles_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2974 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2975 /*!40101 SET character_set_client = @saved_cs_client */;
2976
2977 --
2978 -- Table structure for table `erm_licenses`
2979 --
2980
2981 DROP TABLE IF EXISTS `erm_licenses`;
2982 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2983 /*!40101 SET character_set_client = utf8 */;
2984 CREATE TABLE `erm_licenses` (
2985   `license_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2986   `vendor_id` int(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
2987   `name` varchar(255) NOT NULL COMMENT 'name of the license',
2988   `description` longtext DEFAULT NULL COMMENT 'description of the license',
2989   `type` varchar(80) NOT NULL COMMENT 'type of the license',
2990   `status` varchar(80) NOT NULL COMMENT 'current status of the license',
2991   `started_on` date DEFAULT NULL COMMENT 'start of the license',
2992   `ended_on` date DEFAULT NULL COMMENT 'end of the license',
2993   PRIMARY KEY (`license_id`),
2994   KEY `erm_licenses_ibfk_1` (`vendor_id`),
2995   CONSTRAINT `erm_licenses_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2996 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2997 /*!40101 SET character_set_client = @saved_cs_client */;
2998
2999 --
3000 -- Table structure for table `erm_user_roles`
3001 --
3002
3003 DROP TABLE IF EXISTS `erm_user_roles`;
3004 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3005 /*!40101 SET character_set_client = utf8 */;
3006 CREATE TABLE `erm_user_roles` (
3007   `user_role_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
3008   `agreement_id` int(11) DEFAULT NULL COMMENT 'link to the agreement',
3009   `license_id` int(11) DEFAULT NULL COMMENT 'link to the license',
3010   `user_id` int(11) NOT NULL COMMENT 'link to the user',
3011   `role` varchar(80) NOT NULL COMMENT 'role of the user',
3012   PRIMARY KEY (`user_role_id`),
3013   KEY `erm_user_roles_ibfk_1` (`agreement_id`),
3014   KEY `erm_user_roles_ibfk_2` (`license_id`),
3015   KEY `erm_user_roles_ibfk_3` (`user_id`),
3016   CONSTRAINT `erm_user_roles_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3017   CONSTRAINT `erm_user_roles_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3018   CONSTRAINT `erm_user_roles_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3019 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3020 /*!40101 SET character_set_client = @saved_cs_client */;
3021
3022 --
3023 -- Table structure for table `export_format`
3024 --
3025
3026 DROP TABLE IF EXISTS `export_format`;
3027 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3028 /*!40101 SET character_set_client = utf8 */;
3029 CREATE TABLE `export_format` (
3030   `export_format_id` int(11) NOT NULL AUTO_INCREMENT,
3031   `profile` varchar(255) NOT NULL,
3032   `description` longtext NOT NULL,
3033   `content` longtext NOT NULL,
3034   `csv_separator` varchar(2) NOT NULL DEFAULT ',',
3035   `field_separator` varchar(2) DEFAULT NULL,
3036   `subfield_separator` varchar(2) DEFAULT NULL,
3037   `encoding` varchar(255) NOT NULL DEFAULT 'utf8',
3038   `type` varchar(255) DEFAULT 'marc',
3039   `used_for` varchar(255) DEFAULT 'export_records',
3040   `staff_only` tinyint(1) NOT NULL DEFAULT 0,
3041   PRIMARY KEY (`export_format_id`),
3042   KEY `used_for_idx` (`used_for`(191)),
3043   KEY `staff_only_idx` (`staff_only`)
3044 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Used for CSV export';
3045 /*!40101 SET character_set_client = @saved_cs_client */;
3046
3047 --
3048 -- Table structure for table `hold_cancellation_requests`
3049 --
3050
3051 DROP TABLE IF EXISTS `hold_cancellation_requests`;
3052 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3053 /*!40101 SET character_set_client = utf8 */;
3054 CREATE TABLE `hold_cancellation_requests` (
3055   `hold_cancellation_request_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the cancellation request',
3056   `hold_id` int(11) NOT NULL COMMENT 'ID of the hold',
3057   `creation_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Time and date the cancellation request was created',
3058   PRIMARY KEY (`hold_cancellation_request_id`)
3059 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3060 /*!40101 SET character_set_client = @saved_cs_client */;
3061
3062 --
3063 -- Table structure for table `hold_fill_targets`
3064 --
3065
3066 DROP TABLE IF EXISTS `hold_fill_targets`;
3067 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3068 /*!40101 SET character_set_client = utf8 */;
3069 CREATE TABLE `hold_fill_targets` (
3070   `borrowernumber` int(11) NOT NULL,
3071   `biblionumber` int(11) NOT NULL,
3072   `itemnumber` int(11) NOT NULL,
3073   `source_branchcode` varchar(10) DEFAULT NULL,
3074   `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
3075   `reserve_id` int(11) DEFAULT NULL,
3076   PRIMARY KEY (`itemnumber`),
3077   KEY `bib_branch` (`biblionumber`,`source_branchcode`),
3078   KEY `hold_fill_targets_ibfk_1` (`borrowernumber`),
3079   KEY `hold_fill_targets_ibfk_4` (`source_branchcode`),
3080   CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3081   CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3082   CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3083   CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3084 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3085 /*!40101 SET character_set_client = @saved_cs_client */;
3086
3087 --
3088 -- Table structure for table `housebound_profile`
3089 --
3090
3091 DROP TABLE IF EXISTS `housebound_profile`;
3092 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3093 /*!40101 SET character_set_client = utf8 */;
3094 CREATE TABLE `housebound_profile` (
3095   `borrowernumber` int(11) NOT NULL COMMENT 'Number of the borrower associated with this profile.',
3096   `day` mediumtext NOT NULL COMMENT 'The preferred day of the week for delivery.',
3097   `frequency` mediumtext NOT NULL COMMENT 'The Authorised_Value definining the pattern for delivery.',
3098   `fav_itemtypes` mediumtext DEFAULT NULL COMMENT 'Free text describing preferred itemtypes.',
3099   `fav_subjects` mediumtext DEFAULT NULL COMMENT 'Free text describing preferred subjects.',
3100   `fav_authors` mediumtext DEFAULT NULL COMMENT 'Free text describing preferred authors.',
3101   `referral` mediumtext DEFAULT NULL COMMENT 'Free text indicating how the borrower was added to the service.',
3102   `notes` mediumtext DEFAULT NULL COMMENT 'Free text for additional notes.',
3103   PRIMARY KEY (`borrowernumber`),
3104   CONSTRAINT `housebound_profile_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3105 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3106 /*!40101 SET character_set_client = @saved_cs_client */;
3107
3108 --
3109 -- Table structure for table `housebound_role`
3110 --
3111
3112 DROP TABLE IF EXISTS `housebound_role`;
3113 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3114 /*!40101 SET character_set_client = utf8 */;
3115 CREATE TABLE `housebound_role` (
3116   `borrowernumber_id` int(11) NOT NULL COMMENT 'borrowernumber link',
3117   `housebound_chooser` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'set to 1 to indicate this patron is a housebound chooser volunteer',
3118   `housebound_deliverer` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'set to 1 to indicate this patron is a housebound deliverer volunteer',
3119   PRIMARY KEY (`borrowernumber_id`),
3120   CONSTRAINT `houseboundrole_bnfk` FOREIGN KEY (`borrowernumber_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3121 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3122 /*!40101 SET character_set_client = @saved_cs_client */;
3123
3124 --
3125 -- Table structure for table `housebound_visit`
3126 --
3127
3128 DROP TABLE IF EXISTS `housebound_visit`;
3129 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3130 /*!40101 SET character_set_client = utf8 */;
3131 CREATE TABLE `housebound_visit` (
3132   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID of the visit.',
3133   `borrowernumber` int(11) NOT NULL COMMENT 'Number of the borrower, & the profile, linked to this visit.',
3134   `appointment_date` date DEFAULT NULL COMMENT 'Date of visit.',
3135   `day_segment` varchar(10) DEFAULT NULL COMMENT 'Rough time frame: ''morning'', ''afternoon'' ''evening''',
3136   `chooser_brwnumber` int(11) DEFAULT NULL COMMENT 'Number of the borrower to choose items  for delivery.',
3137   `deliverer_brwnumber` int(11) DEFAULT NULL COMMENT 'Number of the borrower to deliver items.',
3138   PRIMARY KEY (`id`),
3139   KEY `houseboundvisit_bnfk` (`borrowernumber`),
3140   KEY `houseboundvisit_bnfk_1` (`chooser_brwnumber`),
3141   KEY `houseboundvisit_bnfk_2` (`deliverer_brwnumber`),
3142   CONSTRAINT `houseboundvisit_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `housebound_profile` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3143   CONSTRAINT `houseboundvisit_bnfk_1` FOREIGN KEY (`chooser_brwnumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3144   CONSTRAINT `houseboundvisit_bnfk_2` FOREIGN KEY (`deliverer_brwnumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3145 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3146 /*!40101 SET character_set_client = @saved_cs_client */;
3147
3148 --
3149 -- Table structure for table `identity_provider_domains`
3150 --
3151
3152 DROP TABLE IF EXISTS `identity_provider_domains`;
3153 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3154 /*!40101 SET character_set_client = utf8 */;
3155 CREATE TABLE `identity_provider_domains` (
3156   `identity_provider_domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify providers domain',
3157   `identity_provider_id` int(11) NOT NULL COMMENT 'Reference to provider',
3158   `domain` varchar(100) DEFAULT NULL COMMENT 'Domain name. If null means all domains',
3159   `auto_register` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register',
3160   `update_on_auth` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Update user data on auth login',
3161   `default_library_id` varchar(10) DEFAULT NULL COMMENT 'Default library to create user if auto register is enabled',
3162   `default_category_id` varchar(10) DEFAULT NULL COMMENT 'Default category to create user if auto register is enabled',
3163   `allow_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Allow provider from opac interface',
3164   `allow_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow provider from staff interface',
3165   PRIMARY KEY (`identity_provider_domain_id`),
3166   UNIQUE KEY `identity_provider_id` (`identity_provider_id`,`domain`),
3167   KEY `domain` (`domain`),
3168   KEY `allow_opac` (`allow_opac`),
3169   KEY `allow_staff` (`allow_staff`),
3170   KEY `identity_provider_domain_ibfk_2` (`default_library_id`),
3171   KEY `identity_provider_domain_ibfk_3` (`default_category_id`),
3172   CONSTRAINT `identity_provider_domain_ibfk_1` FOREIGN KEY (`identity_provider_id`) REFERENCES `identity_providers` (`identity_provider_id`) ON DELETE CASCADE,
3173   CONSTRAINT `identity_provider_domain_ibfk_2` FOREIGN KEY (`default_library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE,
3174   CONSTRAINT `identity_provider_domain_ibfk_3` FOREIGN KEY (`default_category_id`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE
3175 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3176 /*!40101 SET character_set_client = @saved_cs_client */;
3177
3178 --
3179 -- Table structure for table `identity_providers`
3180 --
3181
3182 DROP TABLE IF EXISTS `identity_providers`;
3183 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3184 /*!40101 SET character_set_client = utf8 */;
3185 CREATE TABLE `identity_providers` (
3186   `identity_provider_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify the provider',
3187   `code` varchar(20) NOT NULL COMMENT 'Provider code',
3188   `description` varchar(255) NOT NULL COMMENT 'Description for the provider',
3189   `protocol` enum('OAuth','OIDC','LDAP','CAS') NOT NULL COMMENT 'Protocol provider speaks',
3190   `config` longtext NOT NULL COMMENT 'Configuration of the provider in JSON format',
3191   `mapping` longtext NOT NULL COMMENT 'Configuration to map provider data to Koha user',
3192   `matchpoint` enum('email','userid','cardnumber') NOT NULL COMMENT 'The patron attribute to be used as matchpoint',
3193   `icon_url` varchar(255) DEFAULT NULL COMMENT 'Provider icon URL',
3194   PRIMARY KEY (`identity_provider_id`),
3195   UNIQUE KEY `code` (`code`),
3196   KEY `protocol` (`protocol`)
3197 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3198 /*!40101 SET character_set_client = @saved_cs_client */;
3199
3200 --
3201 -- Table structure for table `illcomments`
3202 --
3203
3204 DROP TABLE IF EXISTS `illcomments`;
3205 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3206 /*!40101 SET character_set_client = utf8 */;
3207 CREATE TABLE `illcomments` (
3208   `illcomment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the comment',
3209   `illrequest_id` bigint(20) unsigned NOT NULL COMMENT 'ILL request number',
3210   `borrowernumber` int(11) DEFAULT NULL COMMENT 'Link to the user who made the comment (could be librarian, patron or ILL partner library)',
3211   `comment` text DEFAULT NULL COMMENT 'The text of the comment',
3212   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date and time when the comment was made',
3213   PRIMARY KEY (`illcomment_id`),
3214   KEY `illcomments_bnfk` (`borrowernumber`),
3215   KEY `illcomments_ifk` (`illrequest_id`),
3216   CONSTRAINT `illcomments_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3217   CONSTRAINT `illcomments_ifk` FOREIGN KEY (`illrequest_id`) REFERENCES `illrequests` (`illrequest_id`) ON DELETE CASCADE ON UPDATE CASCADE
3218 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3219 /*!40101 SET character_set_client = @saved_cs_client */;
3220
3221 --
3222 -- Table structure for table `illrequestattributes`
3223 --
3224
3225 DROP TABLE IF EXISTS `illrequestattributes`;
3226 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3227 /*!40101 SET character_set_client = utf8 */;
3228 CREATE TABLE `illrequestattributes` (
3229   `illrequest_id` bigint(20) unsigned NOT NULL COMMENT 'ILL request number',
3230   `type` varchar(200) NOT NULL COMMENT 'API ILL property name',
3231   `value` mediumtext NOT NULL COMMENT 'API ILL property value',
3232   `readonly` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Is this attribute read only',
3233   PRIMARY KEY (`illrequest_id`,`type`(191)),
3234   CONSTRAINT `illrequestattributes_ifk` FOREIGN KEY (`illrequest_id`) REFERENCES `illrequests` (`illrequest_id`) ON DELETE CASCADE ON UPDATE CASCADE
3235 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3236 /*!40101 SET character_set_client = @saved_cs_client */;
3237
3238 --
3239 -- Table structure for table `illrequests`
3240 --
3241
3242 DROP TABLE IF EXISTS `illrequests`;
3243 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3244 /*!40101 SET character_set_client = utf8 */;
3245 CREATE TABLE `illrequests` (
3246   `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number',
3247   `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request',
3248   `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request',
3249   `due_date` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation',
3250   `branchcode` varchar(50) NOT NULL COMMENT 'The branch associated with the request',
3251   `status` varchar(50) DEFAULT NULL COMMENT 'Current Koha status of request',
3252   `status_alias` varchar(80) DEFAULT NULL COMMENT 'Foreign key to relevant authorised_values.authorised_value',
3253   `placed` date DEFAULT NULL COMMENT 'Date the request was placed',
3254   `replied` date DEFAULT NULL COMMENT 'Last API response',
3255   `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
3256   `completed` date DEFAULT NULL COMMENT 'Date the request was completed',
3257   `medium` varchar(30) DEFAULT NULL COMMENT 'The Koha request type',
3258   `accessurl` varchar(500) DEFAULT NULL COMMENT 'Potential URL for accessing item',
3259   `cost` varchar(20) DEFAULT NULL COMMENT 'Quotes cost of request',
3260   `price_paid` varchar(20) DEFAULT NULL COMMENT 'Final cost of request',
3261   `notesopac` mediumtext DEFAULT NULL COMMENT 'Patron notes attached to request',
3262   `notesstaff` mediumtext DEFAULT NULL COMMENT 'Staff notes attached to request',
3263   `orderid` varchar(50) DEFAULT NULL COMMENT 'Backend id attached to request',
3264   `backend` varchar(20) DEFAULT NULL COMMENT 'The backend used to create request',
3265   PRIMARY KEY (`illrequest_id`),
3266   KEY `illrequests_bnfk` (`borrowernumber`),
3267   KEY `illrequests_bcfk_2` (`branchcode`),
3268   KEY `illrequests_safk` (`status_alias`),
3269   CONSTRAINT `illrequests_bcfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3270   CONSTRAINT `illrequests_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3271   CONSTRAINT `illrequests_safk` FOREIGN KEY (`status_alias`) REFERENCES `authorised_values` (`authorised_value`) ON DELETE SET NULL ON UPDATE CASCADE
3272 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3273 /*!40101 SET character_set_client = @saved_cs_client */;
3274
3275 --
3276 -- Table structure for table `import_auths`
3277 --
3278
3279 DROP TABLE IF EXISTS `import_auths`;
3280 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3281 /*!40101 SET character_set_client = utf8 */;
3282 CREATE TABLE `import_auths` (
3283   `import_record_id` int(11) NOT NULL,
3284   `matched_authid` int(11) DEFAULT NULL,
3285   `control_number` varchar(25) DEFAULT NULL,
3286   `authorized_heading` varchar(128) DEFAULT NULL,
3287   `original_source` varchar(25) DEFAULT NULL,
3288   PRIMARY KEY (`import_record_id`),
3289   KEY `import_auths_ibfk_1` (`import_record_id`),
3290   KEY `matched_authid` (`matched_authid`),
3291   CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3292 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3293 /*!40101 SET character_set_client = @saved_cs_client */;
3294
3295 --
3296 -- Table structure for table `import_batch_profiles`
3297 --
3298
3299 DROP TABLE IF EXISTS `import_batch_profiles`;
3300 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3301 /*!40101 SET character_set_client = utf8 */;
3302 CREATE TABLE `import_batch_profiles` (
3303   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier and primary key',
3304   `name` varchar(100) NOT NULL COMMENT 'name of this profile',
3305   `matcher_id` int(11) DEFAULT NULL COMMENT 'the id of the match rule used (matchpoints.matcher_id)',
3306   `template_id` int(11) DEFAULT NULL COMMENT 'the id of the marc modification template',
3307   `overlay_action` varchar(50) DEFAULT NULL COMMENT 'how to handle duplicate records',
3308   `nomatch_action` varchar(50) DEFAULT NULL COMMENT 'how to handle records where no match is found',
3309   `item_action` varchar(50) DEFAULT NULL COMMENT 'what to do with item records',
3310   `parse_items` tinyint(1) DEFAULT NULL COMMENT 'should items be parsed',
3311   `record_type` varchar(50) DEFAULT NULL COMMENT 'type of record in the batch',
3312   `encoding` varchar(50) DEFAULT NULL COMMENT 'file encoding',
3313   `format` varchar(50) DEFAULT NULL COMMENT 'marc format',
3314   `comments` longtext DEFAULT NULL COMMENT 'any comments added when the file was uploaded',
3315   PRIMARY KEY (`id`),
3316   UNIQUE KEY `u_import_batch_profiles__name` (`name`)
3317 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3318 /*!40101 SET character_set_client = @saved_cs_client */;
3319
3320 --
3321 -- Table structure for table `import_batches`
3322 --
3323
3324 DROP TABLE IF EXISTS `import_batches`;
3325 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3326 /*!40101 SET character_set_client = utf8 */;
3327 CREATE TABLE `import_batches` (
3328   `import_batch_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier and primary key',
3329   `matcher_id` int(11) DEFAULT NULL COMMENT 'the id of the match rule used (matchpoints.matcher_id)',
3330   `template_id` int(11) DEFAULT NULL,
3331   `branchcode` varchar(10) DEFAULT NULL,
3332   `num_records` int(11) NOT NULL DEFAULT 0 COMMENT 'number of records in the file',
3333   `num_items` int(11) NOT NULL DEFAULT 0 COMMENT 'number of items in the file',
3334   `upload_timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the file was uploaded',
3335   `overlay_action` enum('replace','create_new','use_template','ignore') NOT NULL DEFAULT 'create_new' COMMENT 'how to handle duplicate records',
3336   `nomatch_action` enum('create_new','ignore') NOT NULL DEFAULT 'create_new' COMMENT 'how to handle records where no match is found',
3337   `item_action` enum('always_add','add_only_for_matches','add_only_for_new','ignore','replace') NOT NULL DEFAULT 'always_add' COMMENT 'what to do with item records',
3338   `import_status` enum('staging','staged','importing','imported','reverting','reverted','cleaned') NOT NULL DEFAULT 'staging' COMMENT 'the status of the imported file',
3339   `batch_type` enum('batch','z3950','webservice') NOT NULL DEFAULT 'batch' COMMENT 'where this batch has come from',
3340   `record_type` enum('biblio','auth','holdings') NOT NULL DEFAULT 'biblio' COMMENT 'type of record in the batch',
3341   `file_name` varchar(100) DEFAULT NULL COMMENT 'the name of the file uploaded',
3342   `comments` longtext DEFAULT NULL COMMENT 'any comments added when the file was uploaded',
3343   `profile_id` int(11) DEFAULT NULL,
3344   PRIMARY KEY (`import_batch_id`),
3345   KEY `branchcode` (`branchcode`),
3346   KEY `import_batches_ibfk_1` (`profile_id`),
3347   CONSTRAINT `import_batches_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `import_batch_profiles` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
3348 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3349 /*!40101 SET character_set_client = @saved_cs_client */;
3350
3351 --
3352 -- Table structure for table `import_biblios`
3353 --
3354
3355 DROP TABLE IF EXISTS `import_biblios`;
3356 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3357 /*!40101 SET character_set_client = utf8 */;
3358 CREATE TABLE `import_biblios` (
3359   `import_record_id` int(11) NOT NULL,
3360   `matched_biblionumber` int(11) DEFAULT NULL,
3361   `control_number` varchar(25) DEFAULT NULL,
3362   `original_source` varchar(25) DEFAULT NULL,
3363   `title` longtext DEFAULT NULL,
3364   `author` longtext DEFAULT NULL,
3365   `isbn` longtext DEFAULT NULL,
3366   `issn` longtext DEFAULT NULL,
3367   `has_items` tinyint(1) NOT NULL DEFAULT 0,
3368   PRIMARY KEY (`import_record_id`),
3369   KEY `import_biblios_ibfk_1` (`import_record_id`),
3370   KEY `matched_biblionumber` (`matched_biblionumber`),
3371   KEY `title` (`title`(191)),
3372   KEY `isbn` (`isbn`(191)),
3373   CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3374 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3375 /*!40101 SET character_set_client = @saved_cs_client */;
3376
3377 --
3378 -- Table structure for table `import_items`
3379 --
3380
3381 DROP TABLE IF EXISTS `import_items`;
3382 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3383 /*!40101 SET character_set_client = utf8 */;
3384 CREATE TABLE `import_items` (
3385   `import_items_id` int(11) NOT NULL AUTO_INCREMENT,
3386   `import_record_id` int(11) NOT NULL,
3387   `itemnumber` int(11) DEFAULT NULL,
3388   `branchcode` varchar(10) DEFAULT NULL,
3389   `status` enum('error','staged','imported','reverted','ignored') NOT NULL DEFAULT 'staged',
3390   `marcxml` longtext NOT NULL,
3391   `import_error` longtext DEFAULT NULL,
3392   PRIMARY KEY (`import_items_id`),
3393   KEY `import_items_ibfk_1` (`import_record_id`),
3394   KEY `itemnumber` (`itemnumber`),
3395   KEY `branchcode` (`branchcode`),
3396   CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3397 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3398 /*!40101 SET character_set_client = @saved_cs_client */;
3399
3400 --
3401 -- Table structure for table `import_record_matches`
3402 --
3403
3404 DROP TABLE IF EXISTS `import_record_matches`;
3405 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3406 /*!40101 SET character_set_client = utf8 */;
3407 CREATE TABLE `import_record_matches` (
3408   `import_record_id` int(11) NOT NULL COMMENT 'the id given to the imported bib record (import_records.import_record_id)',
3409   `candidate_match_id` int(11) NOT NULL COMMENT 'the biblio the imported record matches (biblio.biblionumber)',
3410   `score` int(11) NOT NULL DEFAULT 0 COMMENT 'the match score',
3411   `chosen` tinyint(1) DEFAULT NULL COMMENT 'whether this match has been allowed or denied',
3412   PRIMARY KEY (`import_record_id`,`candidate_match_id`),
3413   KEY `record_score` (`import_record_id`,`score`),
3414   CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3415 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3416 /*!40101 SET character_set_client = @saved_cs_client */;
3417
3418 --
3419 -- Table structure for table `import_records`
3420 --
3421
3422 DROP TABLE IF EXISTS `import_records`;
3423 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3424 /*!40101 SET character_set_client = utf8 */;
3425 CREATE TABLE `import_records` (
3426   `import_record_id` int(11) NOT NULL AUTO_INCREMENT,
3427   `import_batch_id` int(11) NOT NULL,
3428   `branchcode` varchar(10) DEFAULT NULL,
3429   `record_sequence` int(11) NOT NULL DEFAULT 0,
3430   `upload_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
3431   `import_date` date DEFAULT NULL,
3432   `marc` longblob NOT NULL,
3433   `marcxml` longtext NOT NULL,
3434   `marcxml_old` longtext NOT NULL,
3435   `record_type` enum('biblio','auth','holdings') NOT NULL DEFAULT 'biblio',
3436   `overlay_status` enum('no_match','auto_match','manual_match','match_applied') NOT NULL DEFAULT 'no_match',
3437   `status` enum('error','staged','imported','reverted','items_reverted','ignored') NOT NULL DEFAULT 'staged',
3438   `import_error` longtext DEFAULT NULL,
3439   `encoding` varchar(40) NOT NULL DEFAULT '',
3440   PRIMARY KEY (`import_record_id`),
3441   KEY `branchcode` (`branchcode`),
3442   KEY `batch_sequence` (`import_batch_id`,`record_sequence`),
3443   KEY `batch_id_record_type` (`import_batch_id`,`record_type`),
3444   CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`) REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE
3445 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3446 /*!40101 SET character_set_client = @saved_cs_client */;
3447
3448 --
3449 -- Table structure for table `issues`
3450 --
3451
3452 DROP TABLE IF EXISTS `issues`;
3453 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3454 /*!40101 SET character_set_client = utf8 */;
3455 CREATE TABLE `issues` (
3456   `issue_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key for issues table',
3457   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
3458   `issuer_id` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the user who checked out this item',
3459   `itemnumber` int(11) NOT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out',
3460   `date_due` datetime DEFAULT NULL COMMENT 'datetime the item is due (yyyy-mm-dd hh:mm::ss)',
3461   `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
3462   `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned, will be NULL until moved to old_issues',
3463   `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
3464   `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
3465   `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
3466   `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
3467   `auto_renew_error` varchar(32) DEFAULT NULL COMMENT 'automatic renewal error',
3468   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this record was last touched',
3469   `issuedate` datetime DEFAULT NULL COMMENT 'date the item was checked out or issued',
3470   `onsite_checkout` int(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag',
3471   `note` longtext DEFAULT NULL COMMENT 'issue note text',
3472   `notedate` datetime DEFAULT NULL COMMENT 'datetime of issue note (yyyy-mm-dd hh:mm::ss)',
3473   `noteseen` int(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null',
3474   PRIMARY KEY (`issue_id`),
3475   UNIQUE KEY `itemnumber` (`itemnumber`),
3476   KEY `issuesborridx` (`borrowernumber`),
3477   KEY `itemnumber_idx` (`itemnumber`),
3478   KEY `branchcode_idx` (`branchcode`),
3479   KEY `bordate` (`borrowernumber`,`timestamp`),
3480   KEY `issues_ibfk_borrowers_borrowernumber` (`issuer_id`),
3481   CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE,
3482   CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON UPDATE CASCADE,
3483   CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
3484 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3485 /*!40101 SET character_set_client = @saved_cs_client */;
3486
3487 --
3488 -- Table structure for table `item_bundles`
3489 --
3490
3491 DROP TABLE IF EXISTS `item_bundles`;
3492 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3493 /*!40101 SET character_set_client = utf8 */;
3494 CREATE TABLE `item_bundles` (
3495   `item` int(11) NOT NULL,
3496   `host` int(11) NOT NULL,
3497   PRIMARY KEY (`host`,`item`),
3498   UNIQUE KEY `item_bundles_uniq_1` (`item`),
3499   CONSTRAINT `item_bundles_ibfk_1` FOREIGN KEY (`item`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3500   CONSTRAINT `item_bundles_ibfk_2` FOREIGN KEY (`host`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
3501 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3502 /*!40101 SET character_set_client = @saved_cs_client */;
3503
3504 --
3505 -- Table structure for table `item_circulation_alert_preferences`
3506 --
3507
3508 DROP TABLE IF EXISTS `item_circulation_alert_preferences`;
3509 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3510 /*!40101 SET character_set_client = utf8 */;
3511 CREATE TABLE `item_circulation_alert_preferences` (
3512   `id` int(11) NOT NULL AUTO_INCREMENT,
3513   `branchcode` varchar(10) NOT NULL,
3514   `categorycode` varchar(10) NOT NULL,
3515   `item_type` varchar(10) NOT NULL,
3516   `notification` varchar(16) NOT NULL,
3517   PRIMARY KEY (`id`),
3518   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`,`notification`)
3519 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3520 /*!40101 SET character_set_client = @saved_cs_client */;
3521
3522 --
3523 -- Table structure for table `item_editor_templates`
3524 --
3525
3526 DROP TABLE IF EXISTS `item_editor_templates`;
3527 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3528 /*!40101 SET character_set_client = utf8 */;
3529 CREATE TABLE `item_editor_templates` (
3530   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id for the template',
3531   `patron_id` int(11) DEFAULT NULL COMMENT 'creator of this template',
3532   `name` mediumtext NOT NULL COMMENT 'template name',
3533   `is_shared` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'controls if template is shared',
3534   `contents` longtext NOT NULL COMMENT 'json encoded template data',
3535   PRIMARY KEY (`id`),
3536   KEY `bn` (`patron_id`),
3537   CONSTRAINT `bn` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
3538 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3539 /*!40101 SET character_set_client = @saved_cs_client */;
3540
3541 --
3542 -- Table structure for table `item_group_items`
3543 --
3544
3545 DROP TABLE IF EXISTS `item_group_items`;
3546 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3547 /*!40101 SET character_set_client = utf8 */;
3548 CREATE TABLE `item_group_items` (
3549   `item_group_items_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id for the group/item link',
3550   `item_group_id` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key making this table a 1 to 1 join from items to item groups',
3551   `item_id` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key linking this table to the items table',
3552   PRIMARY KEY (`item_group_items_id`),
3553   UNIQUE KEY `item_id` (`item_id`),
3554   KEY `item_group_items_gifk_1` (`item_group_id`),
3555   CONSTRAINT `item_group_items_gifk_1` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3556   CONSTRAINT `item_group_items_iifk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
3557 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3558 /*!40101 SET character_set_client = @saved_cs_client */;
3559
3560 --
3561 -- Table structure for table `item_groups`
3562 --
3563
3564 DROP TABLE IF EXISTS `item_groups`;
3565 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3566 /*!40101 SET character_set_client = utf8 */;
3567 CREATE TABLE `item_groups` (
3568   `item_group_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id for the items group',
3569   `biblio_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id for the bibliographic record the group belongs to',
3570   `display_order` int(4) NOT NULL DEFAULT 0 COMMENT 'The ''sort order'' for item_groups',
3571   `description` mediumtext DEFAULT NULL COMMENT 'A group description',
3572   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Time and date the group was created',
3573   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Time and date of the latest change on the group',
3574   PRIMARY KEY (`item_group_id`),
3575   KEY `item_groups_ibfk_1` (`biblio_id`),
3576   CONSTRAINT `item_groups_ibfk_1` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
3577 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3578 /*!40101 SET character_set_client = @saved_cs_client */;
3579
3580 --
3581 -- Table structure for table `items`
3582 --
3583
3584 DROP TABLE IF EXISTS `items`;
3585 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3586 /*!40101 SET character_set_client = utf8 */;
3587 CREATE TABLE `items` (
3588   `itemnumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique identifier added by Koha',
3589   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
3590   `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
3591   `barcode` varchar(20) DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
3592   `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
3593   `booksellerid` longtext DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
3594   `homebranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that owns this item (MARC21 952$a)',
3595   `price` decimal(8,2) DEFAULT NULL COMMENT 'purchase price (MARC21 952$g)',
3596   `replacementprice` decimal(8,2) DEFAULT NULL COMMENT 'cost the library charges to replace the item if it has been marked lost (MARC21 952$v)',
3597   `replacementpricedate` date DEFAULT NULL COMMENT 'the date the price is effective from (MARC21 952$w)',
3598   `datelastborrowed` date DEFAULT NULL COMMENT 'the date the item was last checked out/issued',
3599   `datelastseen` date DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)',
3600   `stack` tinyint(1) DEFAULT NULL,
3601   `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining why this item is not for loan (MARC21 952$7)',
3602   `damaged` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as damaged (MARC21 952$4)',
3603   `damaged_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as damaged, NULL if not damaged',
3604   `itemlost` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as lost (MARC21 952$1)',
3605   `itemlost_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as lost, NULL if not lost',
3606   `withdrawn` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as withdrawn (MARC21 952$0)',
3607   `withdrawn_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as withdrawn, NULL if not withdrawn',
3608   `itemcallnumber` varchar(255) DEFAULT NULL COMMENT 'call number for this item (MARC21 952$o)',
3609   `coded_location_qualifier` varchar(10) DEFAULT NULL COMMENT 'coded location qualifier(MARC21 952$f)',
3610   `issues` smallint(6) DEFAULT 0 COMMENT 'number of times this item has been checked out/issued',
3611   `renewals` smallint(6) DEFAULT NULL COMMENT 'number of times this item has been renewed',
3612   `reserves` smallint(6) DEFAULT NULL COMMENT 'number of times this item has been placed on hold/reserved',
3613   `restricted` tinyint(1) DEFAULT NULL COMMENT 'authorized value defining use restrictions for this item (MARC21 952$5)',
3614   `itemnotes` longtext DEFAULT NULL COMMENT 'public notes on this item (MARC21 952$z)',
3615   `itemnotes_nonpublic` longtext DEFAULT NULL COMMENT 'non-public notes on this item (MARC21 952$x)',
3616   `holdingbranch` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)',
3617   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this item was last altered',
3618   `deleted_on` datetime DEFAULT NULL COMMENT 'date/time of deletion',
3619   `location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)',
3620   `permanent_location` varchar(80) DEFAULT NULL COMMENT 'linked to the CART and PROC temporary locations feature, stores the permanent shelving location',
3621   `onloan` date DEFAULT NULL COMMENT 'defines if item is checked out (NULL for not checked out, and due date for checked out)',
3622   `cn_source` varchar(10) DEFAULT NULL COMMENT 'classification source used on this item (MARC21 952$2)',
3623   `cn_sort` varchar(255) DEFAULT NULL COMMENT 'normalized form of the call number (MARC21 952$o) used for sorting',
3624   `ccode` varchar(80) DEFAULT NULL COMMENT 'authorized value for the collection code associated with this item (MARC21 952$8)',
3625   `materials` mediumtext DEFAULT NULL COMMENT 'materials specified (MARC21 952$3)',
3626   `uri` mediumtext DEFAULT NULL COMMENT 'URL for the item (MARC21 952$u)',
3627   `itype` varchar(10) DEFAULT NULL COMMENT 'foreign key from the itemtypes table defining the type for this item (MARC21 952$y)',
3628   `more_subfields_xml` longtext DEFAULT NULL COMMENT 'additional 952 subfields in XML format',
3629   `enumchron` mediumtext DEFAULT NULL COMMENT 'serial enumeration/chronology for the item (MARC21 952$h)',
3630   `copynumber` varchar(32) DEFAULT NULL COMMENT 'copy number (MARC21 952$t)',
3631   `stocknumber` varchar(32) DEFAULT NULL COMMENT 'inventory number (MARC21 952$i)',
3632   `new_status` varchar(32) DEFAULT NULL COMMENT '''new'' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob.',
3633   `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude this item from local holds priority',
3634   PRIMARY KEY (`itemnumber`),
3635   UNIQUE KEY `itembarcodeidx` (`barcode`),
3636   KEY `itemstocknumberidx` (`stocknumber`),
3637   KEY `itembinoidx` (`biblioitemnumber`),
3638   KEY `itembibnoidx` (`biblionumber`),
3639   KEY `homebranch` (`homebranch`),
3640   KEY `holdingbranch` (`holdingbranch`),
3641   KEY `itemcallnumber` (`itemcallnumber`(191)),
3642   KEY `items_location` (`location`),
3643   KEY `items_ccode` (`ccode`),
3644   KEY `itype_idx` (`itype`),
3645   KEY `timestamp` (`timestamp`),
3646   CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3647   CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
3648   CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
3649   CONSTRAINT `items_ibfk_4` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
3650 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3651 /*!40101 SET character_set_client = @saved_cs_client */;
3652
3653 --
3654 -- Table structure for table `items_last_borrower`
3655 --
3656
3657 DROP TABLE IF EXISTS `items_last_borrower`;
3658 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3659 /*!40101 SET character_set_client = utf8 */;
3660 CREATE TABLE `items_last_borrower` (
3661   `id` int(11) NOT NULL AUTO_INCREMENT,
3662   `itemnumber` int(11) NOT NULL,
3663   `borrowernumber` int(11) NOT NULL,
3664   `created_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
3665   PRIMARY KEY (`id`),
3666   UNIQUE KEY `itemnumber` (`itemnumber`),
3667   KEY `borrowernumber` (`borrowernumber`),
3668   CONSTRAINT `items_last_borrower_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3669   CONSTRAINT `items_last_borrower_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3670 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3671 /*!40101 SET character_set_client = @saved_cs_client */;
3672
3673 --
3674 -- Table structure for table `items_search_fields`
3675 --
3676
3677 DROP TABLE IF EXISTS `items_search_fields`;
3678 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3679 /*!40101 SET character_set_client = utf8 */;
3680 CREATE TABLE `items_search_fields` (
3681   `name` varchar(255) NOT NULL,
3682   `label` varchar(255) NOT NULL,
3683   `tagfield` char(3) NOT NULL,
3684   `tagsubfield` char(1) DEFAULT NULL,
3685   `authorised_values_category` varchar(32) DEFAULT NULL,
3686   PRIMARY KEY (`name`(191)),
3687   KEY `items_search_fields_authorised_values_category` (`authorised_values_category`),
3688   CONSTRAINT `items_search_fields_authorised_values_category` FOREIGN KEY (`authorised_values_category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE
3689 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3690 /*!40101 SET character_set_client = @saved_cs_client */;
3691
3692 --
3693 -- Table structure for table `itemtypes`
3694 --
3695
3696 DROP TABLE IF EXISTS `itemtypes`;
3697 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3698 /*!40101 SET character_set_client = utf8 */;
3699 CREATE TABLE `itemtypes` (
3700   `itemtype` varchar(10) NOT NULL DEFAULT '' COMMENT 'unique key, a code associated with the item type',
3701   `parent_type` varchar(10) DEFAULT NULL COMMENT 'unique key, a code associated with the item type',
3702   `description` longtext DEFAULT NULL COMMENT 'a plain text explanation of the item type',
3703   `rentalcharge` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged when this item is checked out/issued',
3704   `rentalcharge_daily` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each day between checkout date and due date',
3705   `rentalcharge_daily_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the daily rental fee is calculated directly or using finesCalendar',
3706   `rentalcharge_hourly` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each hour between checkout date and due date',
3707   `rentalcharge_hourly_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the hourly rental fee is calculated directly or using finesCalendar',
3708   `defaultreplacecost` decimal(28,6) DEFAULT NULL COMMENT 'default replacement cost',
3709   `processfee` decimal(28,6) DEFAULT NULL COMMENT 'default text be recorded in the column note when the processing fee is applied',
3710   `notforloan` smallint(6) DEFAULT NULL COMMENT '1 if the item is not for loan, 0 if the item is available for loan',
3711   `imageurl` varchar(200) DEFAULT NULL COMMENT 'URL for the item type icon',
3712   `summary` mediumtext DEFAULT NULL COMMENT 'information from the summary field, may include HTML',
3713   `checkinmsg` varchar(255) DEFAULT NULL COMMENT 'message that is displayed when an item with the given item type is checked in',
3714   `checkinmsgtype` char(16) NOT NULL DEFAULT 'message' COMMENT 'type (CSS class) for the checkinmsg, can be ''alert'' or ''message''',
3715   `sip_media_type` varchar(3) DEFAULT NULL COMMENT 'SIP2 protocol media type for this itemtype',
3716   `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
3717   `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
3718   `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
3719   PRIMARY KEY (`itemtype`),
3720   UNIQUE KEY `itemtype` (`itemtype`),
3721   KEY `itemtypes_ibfk_1` (`parent_type`),
3722   CONSTRAINT `itemtypes_ibfk_1` FOREIGN KEY (`parent_type`) REFERENCES `itemtypes` (`itemtype`)
3723 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3724 /*!40101 SET character_set_client = @saved_cs_client */;
3725
3726 --
3727 -- Table structure for table `itemtypes_branches`
3728 --
3729
3730 DROP TABLE IF EXISTS `itemtypes_branches`;
3731 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3732 /*!40101 SET character_set_client = utf8 */;
3733 CREATE TABLE `itemtypes_branches` (
3734   `itemtype` varchar(10) NOT NULL,
3735   `branchcode` varchar(10) NOT NULL,
3736   KEY `itemtype` (`itemtype`),
3737   KEY `branchcode` (`branchcode`),
3738   CONSTRAINT `itemtypes_branches_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE,
3739   CONSTRAINT `itemtypes_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
3740 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3741 /*!40101 SET character_set_client = @saved_cs_client */;
3742
3743 --
3744 -- Table structure for table `keyboard_shortcuts`
3745 --
3746
3747 DROP TABLE IF EXISTS `keyboard_shortcuts`;
3748 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3749 /*!40101 SET character_set_client = utf8 */;
3750 CREATE TABLE `keyboard_shortcuts` (
3751   `shortcut_name` varchar(80) NOT NULL,
3752   `shortcut_keys` varchar(80) NOT NULL,
3753   PRIMARY KEY (`shortcut_name`)
3754 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3755 /*!40101 SET character_set_client = @saved_cs_client */;
3756
3757 --
3758 -- Table structure for table `language_descriptions`
3759 --
3760
3761 DROP TABLE IF EXISTS `language_descriptions`;
3762 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3763 /*!40101 SET character_set_client = utf8 */;
3764 CREATE TABLE `language_descriptions` (
3765   `subtag` varchar(25) DEFAULT NULL,
3766   `type` varchar(25) DEFAULT NULL,
3767   `lang` varchar(25) DEFAULT NULL,
3768   `description` varchar(255) DEFAULT NULL,
3769   `id` int(11) NOT NULL AUTO_INCREMENT,
3770   PRIMARY KEY (`id`),
3771   UNIQUE KEY `uniq_desc` (`subtag`,`type`,`lang`),
3772   KEY `lang` (`lang`)
3773 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3774 /*!40101 SET character_set_client = @saved_cs_client */;
3775
3776 --
3777 -- Table structure for table `language_rfc4646_to_iso639`
3778 --
3779
3780 DROP TABLE IF EXISTS `language_rfc4646_to_iso639`;
3781 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3782 /*!40101 SET character_set_client = utf8 */;
3783 CREATE TABLE `language_rfc4646_to_iso639` (
3784   `rfc4646_subtag` varchar(25) DEFAULT NULL,
3785   `iso639_2_code` varchar(25) DEFAULT NULL,
3786   `id` int(11) NOT NULL AUTO_INCREMENT,
3787   PRIMARY KEY (`id`),
3788   UNIQUE KEY `uniq_code` (`rfc4646_subtag`,`iso639_2_code`),
3789   KEY `rfc4646_subtag` (`rfc4646_subtag`)
3790 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3791 /*!40101 SET character_set_client = @saved_cs_client */;
3792
3793 --
3794 -- Table structure for table `language_script_bidi`
3795 --
3796
3797 DROP TABLE IF EXISTS `language_script_bidi`;
3798 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3799 /*!40101 SET character_set_client = utf8 */;
3800 CREATE TABLE `language_script_bidi` (
3801   `rfc4646_subtag` varchar(25) DEFAULT NULL COMMENT 'script subtag, Arab, Hebr, etc.',
3802   `bidi` varchar(3) DEFAULT NULL COMMENT 'rtl ltr',
3803   KEY `rfc4646_subtag` (`rfc4646_subtag`)
3804 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3805 /*!40101 SET character_set_client = @saved_cs_client */;
3806
3807 --
3808 -- Table structure for table `language_script_mapping`
3809 --
3810
3811 DROP TABLE IF EXISTS `language_script_mapping`;
3812 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3813 /*!40101 SET character_set_client = utf8 */;
3814 CREATE TABLE `language_script_mapping` (
3815   `language_subtag` varchar(25) NOT NULL,
3816   `script_subtag` varchar(25) DEFAULT NULL,
3817   PRIMARY KEY (`language_subtag`)
3818 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3819 /*!40101 SET character_set_client = @saved_cs_client */;
3820
3821 --
3822 -- Table structure for table `language_subtag_registry`
3823 --
3824
3825 DROP TABLE IF EXISTS `language_subtag_registry`;
3826 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3827 /*!40101 SET character_set_client = utf8 */;
3828 CREATE TABLE `language_subtag_registry` (
3829   `subtag` varchar(25) DEFAULT NULL,
3830   `type` varchar(25) DEFAULT NULL COMMENT 'language-script-region-variant-extension-privateuse',
3831   `description` varchar(255) DEFAULT NULL COMMENT 'only one of the possible descriptions for ease of reference, see language_descriptions for the complete list',
3832   `added` date DEFAULT NULL,
3833   `id` int(11) NOT NULL AUTO_INCREMENT,
3834   PRIMARY KEY (`id`),
3835   UNIQUE KEY `uniq_lang` (`subtag`,`type`),
3836   KEY `subtag` (`subtag`)
3837 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3838 /*!40101 SET character_set_client = @saved_cs_client */;
3839
3840 --
3841 -- Table structure for table `letter`
3842 --
3843
3844 DROP TABLE IF EXISTS `letter`;
3845 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3846 /*!40101 SET character_set_client = utf8 */;
3847 CREATE TABLE `letter` (
3848   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
3849   `module` varchar(20) NOT NULL DEFAULT '' COMMENT 'Koha module that triggers this notice or slip',
3850   `code` varchar(20) NOT NULL DEFAULT '' COMMENT 'unique identifier for this notice or slip',
3851   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'the branch this notice or slip is used at (branches.branchcode)',
3852   `name` varchar(100) NOT NULL DEFAULT '' COMMENT 'plain text name for this notice or slip',
3853   `is_html` tinyint(1) DEFAULT 0 COMMENT 'does this notice or slip use HTML (1 for yes, 0 for no)',
3854   `title` varchar(200) NOT NULL DEFAULT '' COMMENT 'subject line of the notice',
3855   `content` mediumtext DEFAULT NULL COMMENT 'body text for the notice or slip',
3856   `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice',
3857   `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice',
3858   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
3859   PRIMARY KEY (`id`),
3860   UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`),
3861   KEY `message_transport_type_fk` (`message_transport_type`),
3862   CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
3863 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3864 /*!40101 SET character_set_client = @saved_cs_client */;
3865
3866 --
3867 -- Table structure for table `library_groups`
3868 --
3869
3870 DROP TABLE IF EXISTS `library_groups`;
3871 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3872 /*!40101 SET character_set_client = utf8 */;
3873 CREATE TABLE `library_groups` (
3874   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for each group',
3875   `parent_id` int(11) DEFAULT NULL COMMENT 'if this is a child group, the id of the parent group',
3876   `branchcode` varchar(10) DEFAULT NULL COMMENT 'The branchcode of a branch belonging to the parent group',
3877   `title` varchar(100) DEFAULT NULL COMMENT 'Short description of the goup',
3878   `description` mediumtext DEFAULT NULL COMMENT 'Longer explanation of the group, if necessary',
3879   `ft_hide_patron_info` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Turn on the feature ''Hide patron''s info'' for this group',
3880   `ft_limit_item_editing` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Turn on the feature "Limit item editing by group" for this group',
3881   `ft_search_groups_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group for staff side search groups',
3882   `ft_search_groups_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group for opac side search groups',
3883   `ft_local_hold_group` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group to identify libraries as pick up location for holds',
3884   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Date and time of creation',
3885   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Date and time of last',
3886   PRIMARY KEY (`id`),
3887   UNIQUE KEY `title` (`title`),
3888   UNIQUE KEY `library_groups_uniq_2` (`parent_id`,`branchcode`),
3889   KEY `branchcode` (`branchcode`),
3890   CONSTRAINT `library_groups_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `library_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
3891   CONSTRAINT `library_groups_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3892 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3893 /*!40101 SET character_set_client = @saved_cs_client */;
3894
3895 --
3896 -- Table structure for table `library_smtp_servers`
3897 --
3898
3899 DROP TABLE IF EXISTS `library_smtp_servers`;
3900 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3901 /*!40101 SET character_set_client = utf8 */;
3902 CREATE TABLE `library_smtp_servers` (
3903   `id` int(11) NOT NULL AUTO_INCREMENT,
3904   `library_id` varchar(10) NOT NULL,
3905   `smtp_server_id` int(11) NOT NULL,
3906   PRIMARY KEY (`id`),
3907   UNIQUE KEY `library_id_idx` (`library_id`),
3908   KEY `smtp_server_id_idx` (`smtp_server_id`),
3909   CONSTRAINT `library_smtp_servers_library_fk` FOREIGN KEY (`library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3910   CONSTRAINT `library_smtp_servers_smtp_servers_fk` FOREIGN KEY (`smtp_server_id`) REFERENCES `smtp_servers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3911 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3912 /*!40101 SET character_set_client = @saved_cs_client */;
3913
3914 --
3915 -- Table structure for table `linktracker`
3916 --
3917
3918 DROP TABLE IF EXISTS `linktracker`;
3919 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3920 /*!40101 SET character_set_client = utf8 */;
3921 CREATE TABLE `linktracker` (
3922   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
3923   `biblionumber` int(11) DEFAULT NULL COMMENT 'biblionumber of the record the link is from',
3924   `itemnumber` int(11) DEFAULT NULL COMMENT 'itemnumber if applicable that the link was from',
3925   `borrowernumber` int(11) DEFAULT NULL COMMENT 'borrowernumber who clicked the link',
3926   `url` mediumtext DEFAULT NULL COMMENT 'the link itself',
3927   `timeclicked` datetime DEFAULT NULL COMMENT 'the date and time the link was clicked',
3928   PRIMARY KEY (`id`),
3929   KEY `bibidx` (`biblionumber`),
3930   KEY `itemidx` (`itemnumber`),
3931   KEY `borridx` (`borrowernumber`),
3932   KEY `dateidx` (`timeclicked`),
3933   CONSTRAINT `linktracker_biblio_ibfk` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL,
3934   CONSTRAINT `linktracker_borrower_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
3935   CONSTRAINT `linktracker_item_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
3936 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3937 /*!40101 SET character_set_client = @saved_cs_client */;
3938
3939 --
3940 -- Table structure for table `localization`
3941 --
3942
3943 DROP TABLE IF EXISTS `localization`;
3944 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3945 /*!40101 SET character_set_client = utf8 */;
3946 CREATE TABLE `localization` (
3947   `localization_id` int(11) NOT NULL AUTO_INCREMENT,
3948   `entity` varchar(16) NOT NULL,
3949   `code` varchar(64) NOT NULL,
3950   `lang` varchar(25) NOT NULL COMMENT 'could be a foreign key',
3951   `translation` mediumtext DEFAULT NULL,
3952   PRIMARY KEY (`localization_id`),
3953   UNIQUE KEY `entity_code_lang` (`entity`,`code`,`lang`)
3954 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3955 /*!40101 SET character_set_client = @saved_cs_client */;
3956
3957 --
3958 -- Table structure for table `marc_matchers`
3959 --
3960
3961 DROP TABLE IF EXISTS `marc_matchers`;
3962 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3963 /*!40101 SET character_set_client = utf8 */;
3964 CREATE TABLE `marc_matchers` (
3965   `matcher_id` int(11) NOT NULL AUTO_INCREMENT,
3966   `code` varchar(10) NOT NULL DEFAULT '',
3967   `description` varchar(255) NOT NULL DEFAULT '',
3968   `record_type` varchar(10) NOT NULL DEFAULT 'biblio',
3969   `threshold` int(11) NOT NULL DEFAULT 0,
3970   PRIMARY KEY (`matcher_id`),
3971   KEY `code` (`code`),
3972   KEY `record_type` (`record_type`)
3973 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3974 /*!40101 SET character_set_client = @saved_cs_client */;
3975
3976 --
3977 -- Table structure for table `marc_modification_template_actions`
3978 --
3979
3980 DROP TABLE IF EXISTS `marc_modification_template_actions`;
3981 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3982 /*!40101 SET character_set_client = utf8 */;
3983 CREATE TABLE `marc_modification_template_actions` (
3984   `mmta_id` int(11) NOT NULL AUTO_INCREMENT,
3985   `template_id` int(11) NOT NULL,
3986   `ordering` int(3) NOT NULL,
3987   `action` enum('delete_field','add_field','update_field','move_field','copy_field','copy_and_replace_field') NOT NULL,
3988   `field_number` smallint(6) NOT NULL DEFAULT 0,
3989   `from_field` varchar(3) NOT NULL,
3990   `from_subfield` varchar(1) DEFAULT NULL,
3991   `field_value`  text DEFAULT NULL,
3992   `to_field` varchar(3) DEFAULT NULL,
3993   `to_subfield` varchar(1) DEFAULT NULL,
3994   `to_regex_search` mediumtext DEFAULT NULL,
3995   `to_regex_replace` mediumtext DEFAULT NULL,
3996   `to_regex_modifiers` varchar(8) DEFAULT '',
3997   `conditional` enum('if','unless') DEFAULT NULL,
3998   `conditional_field` varchar(3) DEFAULT NULL,
3999   `conditional_subfield` varchar(1) DEFAULT NULL,
4000   `conditional_comparison` enum('exists','not_exists','equals','not_equals') DEFAULT NULL,
4001   `conditional_value` mediumtext DEFAULT NULL,
4002   `conditional_regex` tinyint(1) NOT NULL DEFAULT 0,
4003   `description` mediumtext DEFAULT NULL,
4004   PRIMARY KEY (`mmta_id`),
4005   KEY `mmta_ibfk_1` (`template_id`),
4006   CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
4007 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4008 /*!40101 SET character_set_client = @saved_cs_client */;
4009
4010 --
4011 -- Table structure for table `marc_modification_templates`
4012 --
4013
4014 DROP TABLE IF EXISTS `marc_modification_templates`;
4015 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4016 /*!40101 SET character_set_client = utf8 */;
4017 CREATE TABLE `marc_modification_templates` (
4018   `template_id` int(11) NOT NULL AUTO_INCREMENT,
4019   `name` mediumtext NOT NULL,
4020   PRIMARY KEY (`template_id`)
4021 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4022 /*!40101 SET character_set_client = @saved_cs_client */;
4023
4024 --
4025 -- Table structure for table `marc_overlay_rules`
4026 --
4027
4028 DROP TABLE IF EXISTS `marc_overlay_rules`;
4029 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4030 /*!40101 SET character_set_client = utf8 */;
4031 CREATE TABLE `marc_overlay_rules` (
4032   `id` int(11) NOT NULL AUTO_INCREMENT,
4033   `tag` varchar(255) NOT NULL,
4034   `module` varchar(127) NOT NULL,
4035   `filter` varchar(255) NOT NULL,
4036   `add` tinyint(1) NOT NULL DEFAULT 0,
4037   `append` tinyint(1) NOT NULL DEFAULT 0,
4038   `remove` tinyint(1) NOT NULL DEFAULT 0,
4039   `delete` tinyint(1) NOT NULL DEFAULT 0,
4040   PRIMARY KEY (`id`)
4041 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4042 /*!40101 SET character_set_client = @saved_cs_client */;
4043
4044 --
4045 -- Table structure for table `marc_subfield_structure`
4046 --
4047
4048 DROP TABLE IF EXISTS `marc_subfield_structure`;
4049 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4050 /*!40101 SET character_set_client = utf8 */;
4051 CREATE TABLE `marc_subfield_structure` (
4052   `tagfield` varchar(3) NOT NULL DEFAULT '',
4053   `tagsubfield` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
4054   `liblibrarian` varchar(255) NOT NULL DEFAULT '',
4055   `libopac` varchar(255) NOT NULL DEFAULT '',
4056   `repeatable` tinyint(4) NOT NULL DEFAULT 0,
4057   `mandatory` tinyint(4) NOT NULL DEFAULT 0,
4058   `important` tinyint(4) NOT NULL DEFAULT 0,
4059   `kohafield` varchar(40) DEFAULT NULL,
4060   `tab` tinyint(1) DEFAULT NULL,
4061   `authorised_value` varchar(32) DEFAULT NULL,
4062   `authtypecode` varchar(20) DEFAULT NULL,
4063   `value_builder` varchar(80) DEFAULT NULL,
4064   `isurl` tinyint(1) DEFAULT NULL,
4065   `hidden` tinyint(1) NOT NULL DEFAULT 8,
4066   `frameworkcode` varchar(4) NOT NULL DEFAULT '',
4067   `seealso` varchar(1100) DEFAULT NULL,
4068   `link` varchar(80) DEFAULT NULL,
4069   `defaultvalue` mediumtext DEFAULT NULL,
4070   `maxlength` int(4) NOT NULL DEFAULT 9999,
4071   `display_order` int(2) NOT NULL DEFAULT 0,
4072   PRIMARY KEY (`frameworkcode`,`tagfield`,`tagsubfield`),
4073   KEY `kohafield_2` (`kohafield`),
4074   KEY `tab` (`frameworkcode`,`tab`),
4075   KEY `kohafield` (`frameworkcode`,`kohafield`),
4076   KEY `marc_subfield_structure_ibfk_1` (`authorised_value`),
4077   CONSTRAINT `marc_subfield_structure_ibfk_1` FOREIGN KEY (`authorised_value`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE
4078 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4079 /*!40101 SET character_set_client = @saved_cs_client */;
4080
4081 --
4082 -- Table structure for table `marc_tag_structure`
4083 --
4084
4085 DROP TABLE IF EXISTS `marc_tag_structure`;
4086 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4087 /*!40101 SET character_set_client = utf8 */;
4088 CREATE TABLE `marc_tag_structure` (
4089   `tagfield` varchar(3) NOT NULL DEFAULT '',
4090   `liblibrarian` varchar(255) NOT NULL DEFAULT '',
4091   `libopac` varchar(255) NOT NULL DEFAULT '',
4092   `repeatable` tinyint(4) NOT NULL DEFAULT 0,
4093   `mandatory` tinyint(4) NOT NULL DEFAULT 0,
4094   `important` tinyint(4) NOT NULL DEFAULT 0,
4095   `authorised_value` varchar(32) DEFAULT NULL,
4096   `ind1_defaultvalue` varchar(1) NOT NULL DEFAULT '',
4097   `ind2_defaultvalue` varchar(1) NOT NULL DEFAULT '',
4098   `frameworkcode` varchar(4) NOT NULL DEFAULT '',
4099   PRIMARY KEY (`frameworkcode`,`tagfield`)
4100 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4101 /*!40101 SET character_set_client = @saved_cs_client */;
4102
4103 --
4104 -- Table structure for table `matchchecks`
4105 --
4106
4107 DROP TABLE IF EXISTS `matchchecks`;
4108 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4109 /*!40101 SET character_set_client = utf8 */;
4110 CREATE TABLE `matchchecks` (
4111   `matcher_id` int(11) NOT NULL,
4112   `matchcheck_id` int(11) NOT NULL AUTO_INCREMENT,
4113   `source_matchpoint_id` int(11) NOT NULL,
4114   `target_matchpoint_id` int(11) NOT NULL,
4115   PRIMARY KEY (`matchcheck_id`),
4116   KEY `matcher_matchchecks_ifbk_1` (`matcher_id`),
4117   KEY `matcher_matchchecks_ifbk_2` (`source_matchpoint_id`),
4118   KEY `matcher_matchchecks_ifbk_3` (`target_matchpoint_id`),
4119   CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`) REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4120   CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4121   CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
4122 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4123 /*!40101 SET character_set_client = @saved_cs_client */;
4124
4125 --
4126 -- Table structure for table `matcher_matchpoints`
4127 --
4128
4129 DROP TABLE IF EXISTS `matcher_matchpoints`;
4130 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4131 /*!40101 SET character_set_client = utf8 */;
4132 CREATE TABLE `matcher_matchpoints` (
4133   `matcher_id` int(11) NOT NULL,
4134   `matchpoint_id` int(11) NOT NULL,
4135   KEY `matcher_matchpoints_ifbk_1` (`matcher_id`),
4136   KEY `matcher_matchpoints_ifbk_2` (`matchpoint_id`),
4137   CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`) REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4138   CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
4139 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4140 /*!40101 SET character_set_client = @saved_cs_client */;
4141
4142 --
4143 -- Table structure for table `matchpoint_component_norms`
4144 --
4145
4146 DROP TABLE IF EXISTS `matchpoint_component_norms`;
4147 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4148 /*!40101 SET character_set_client = utf8 */;
4149 CREATE TABLE `matchpoint_component_norms` (
4150   `matchpoint_component_id` int(11) NOT NULL,
4151   `sequence` int(11) NOT NULL DEFAULT 0,
4152   `norm_routine` varchar(50) NOT NULL DEFAULT '',
4153   KEY `matchpoint_component_norms` (`matchpoint_component_id`,`sequence`),
4154   CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`) REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
4155 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4156 /*!40101 SET character_set_client = @saved_cs_client */;
4157
4158 --
4159 -- Table structure for table `matchpoint_components`
4160 --
4161
4162 DROP TABLE IF EXISTS `matchpoint_components`;
4163 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4164 /*!40101 SET character_set_client = utf8 */;
4165 CREATE TABLE `matchpoint_components` (
4166   `matchpoint_id` int(11) NOT NULL,
4167   `matchpoint_component_id` int(11) NOT NULL AUTO_INCREMENT,
4168   `sequence` int(11) NOT NULL DEFAULT 0,
4169   `tag` varchar(3) NOT NULL DEFAULT '',
4170   `subfields` varchar(40) NOT NULL DEFAULT '',
4171   `offset` int(4) NOT NULL DEFAULT 0,
4172   `length` int(4) NOT NULL DEFAULT 0,
4173   PRIMARY KEY (`matchpoint_component_id`),
4174   KEY `by_sequence` (`matchpoint_id`,`sequence`),
4175   CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
4176 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4177 /*!40101 SET character_set_client = @saved_cs_client */;
4178
4179 --
4180 -- Table structure for table `matchpoints`
4181 --
4182
4183 DROP TABLE IF EXISTS `matchpoints`;
4184 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4185 /*!40101 SET character_set_client = utf8 */;
4186 CREATE TABLE `matchpoints` (
4187   `matcher_id` int(11) NOT NULL,
4188   `matchpoint_id` int(11) NOT NULL AUTO_INCREMENT,
4189   `search_index` varchar(30) NOT NULL DEFAULT '',
4190   `score` int(11) NOT NULL DEFAULT 0,
4191   PRIMARY KEY (`matchpoint_id`),
4192   KEY `matchpoints_ifbk_1` (`matcher_id`),
4193   CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`) REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
4194 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4195 /*!40101 SET character_set_client = @saved_cs_client */;
4196
4197 --
4198 -- Table structure for table `message_attributes`
4199 --
4200
4201 DROP TABLE IF EXISTS `message_attributes`;
4202 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4203 /*!40101 SET character_set_client = utf8 */;
4204 CREATE TABLE `message_attributes` (
4205   `message_attribute_id` int(11) NOT NULL AUTO_INCREMENT,
4206   `message_name` varchar(40) NOT NULL DEFAULT '',
4207   `takes_days` tinyint(1) NOT NULL DEFAULT 0,
4208   PRIMARY KEY (`message_attribute_id`),
4209   UNIQUE KEY `message_name` (`message_name`)
4210 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4211 /*!40101 SET character_set_client = @saved_cs_client */;
4212
4213 --
4214 -- Table structure for table `message_queue`
4215 --
4216
4217 DROP TABLE IF EXISTS `message_queue`;
4218 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4219 /*!40101 SET character_set_client = utf8 */;
4220 CREATE TABLE `message_queue` (
4221   `message_id` int(11) NOT NULL AUTO_INCREMENT,
4222   `letter_id` int(11) DEFAULT NULL COMMENT 'Foreign key to the letters table',
4223   `borrowernumber` int(11) DEFAULT NULL,
4224   `subject` mediumtext DEFAULT NULL,
4225   `content` mediumtext DEFAULT NULL,
4226   `metadata` mediumtext DEFAULT NULL,
4227   `letter_code` varchar(64) DEFAULT NULL,
4228   `message_transport_type` varchar(20) NOT NULL,
4229   `status` enum('sent','pending','failed','deleted') NOT NULL DEFAULT 'pending',
4230   `time_queued` timestamp NULL DEFAULT NULL,
4231   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
4232   `to_address` longtext DEFAULT NULL,
4233   `from_address` longtext DEFAULT NULL,
4234   `reply_address` longtext DEFAULT NULL,
4235   `content_type` mediumtext DEFAULT NULL,
4236   `failure_code` mediumtext DEFAULT NULL,
4237   PRIMARY KEY (`message_id`),
4238   KEY `borrowernumber` (`borrowernumber`),
4239   KEY `message_transport_type` (`message_transport_type`),
4240   KEY `letter_fk` (`letter_id`),
4241   CONSTRAINT `letter_fk` FOREIGN KEY (`letter_id`) REFERENCES `letter` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
4242   CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4243   CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON UPDATE CASCADE
4244 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4245 /*!40101 SET character_set_client = @saved_cs_client */;
4246
4247 --
4248 -- Table structure for table `message_transport_types`
4249 --
4250
4251 DROP TABLE IF EXISTS `message_transport_types`;
4252 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4253 /*!40101 SET character_set_client = utf8 */;
4254 CREATE TABLE `message_transport_types` (
4255   `message_transport_type` varchar(20) NOT NULL,
4256   PRIMARY KEY (`message_transport_type`)
4257 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4258 /*!40101 SET character_set_client = @saved_cs_client */;
4259
4260 --
4261 -- Table structure for table `message_transports`
4262 --
4263
4264 DROP TABLE IF EXISTS `message_transports`;
4265 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4266 /*!40101 SET character_set_client = utf8 */;
4267 CREATE TABLE `message_transports` (
4268   `message_attribute_id` int(11) NOT NULL,
4269   `message_transport_type` varchar(20) NOT NULL,
4270   `is_digest` tinyint(1) NOT NULL DEFAULT 0,
4271   `letter_module` varchar(20) NOT NULL DEFAULT '',
4272   `letter_code` varchar(20) NOT NULL DEFAULT '',
4273   `branchcode` varchar(10) NOT NULL DEFAULT '',
4274   PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
4275   KEY `message_transport_type` (`message_transport_type`),
4276   KEY `letter_module` (`letter_module`,`letter_code`),
4277   CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4278   CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
4279 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4280 /*!40101 SET character_set_client = @saved_cs_client */;
4281
4282 --
4283 -- Table structure for table `messages`
4284 --
4285
4286 DROP TABLE IF EXISTS `messages`;
4287 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4288 /*!40101 SET character_set_client = utf8 */;
4289 CREATE TABLE `messages` (
4290   `message_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4291   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key linking this message to the borrowers table',
4292   `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key linking the message to the branches table',
4293   `message_type` varchar(1) NOT NULL COMMENT 'whether the message is for the librarians (L) or the patron (B)',
4294   `message` mediumtext NOT NULL COMMENT 'the text of the message',
4295   `message_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the message was written',
4296   `manager_id` int(11) DEFAULT NULL COMMENT 'creator of message',
4297   PRIMARY KEY (`message_id`),
4298   KEY `messages_ibfk_1` (`manager_id`),
4299   KEY `messages_borrowernumber` (`borrowernumber`),
4300   CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4301   CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL
4302 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4303 /*!40101 SET character_set_client = @saved_cs_client */;
4304
4305 --
4306 -- Table structure for table `misc_files`
4307 --
4308
4309 DROP TABLE IF EXISTS `misc_files`;
4310 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4311 /*!40101 SET character_set_client = utf8 */;
4312 CREATE TABLE `misc_files` (
4313   `file_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the file record',
4314   `table_tag` varchar(255) NOT NULL COMMENT 'usually table name, or arbitrary unique tag',
4315   `record_id` int(11) NOT NULL COMMENT 'record id from the table this file is associated to',
4316   `file_name` varchar(255) NOT NULL COMMENT 'file name',
4317   `file_type` varchar(255) NOT NULL COMMENT 'MIME type of the file',
4318   `file_description` varchar(255) DEFAULT NULL COMMENT 'description given to the file',
4319   `file_content` longblob NOT NULL COMMENT 'file content',
4320   `date_uploaded` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the file was added',
4321   PRIMARY KEY (`file_id`),
4322   KEY `table_tag` (`table_tag`(191)),
4323   KEY `record_id` (`record_id`)
4324 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4325 /*!40101 SET character_set_client = @saved_cs_client */;
4326
4327 --
4328 -- Table structure for table `need_merge_authorities`
4329 --
4330
4331 DROP TABLE IF EXISTS `need_merge_authorities`;
4332 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4333 /*!40101 SET character_set_client = utf8 */;
4334 CREATE TABLE `need_merge_authorities` (
4335   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id',
4336   `authid` bigint(20) NOT NULL COMMENT 'reference to original authority record',
4337   `authid_new` bigint(20) DEFAULT NULL COMMENT 'reference to optional new authority record',
4338   `reportxml` mediumtext DEFAULT NULL COMMENT 'xml showing original reporting tag',
4339   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time last modified',
4340   `done` tinyint(4) DEFAULT 0,
4341   PRIMARY KEY (`id`)
4342 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4343 /*!40101 SET character_set_client = @saved_cs_client */;
4344
4345 --
4346 -- Table structure for table `oai_sets`
4347 --
4348
4349 DROP TABLE IF EXISTS `oai_sets`;
4350 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4351 /*!40101 SET character_set_client = utf8 */;
4352 CREATE TABLE `oai_sets` (
4353   `id` int(11) NOT NULL AUTO_INCREMENT,
4354   `spec` varchar(80) NOT NULL,
4355   `name` varchar(80) NOT NULL,
4356   PRIMARY KEY (`id`),
4357   UNIQUE KEY `spec` (`spec`)
4358 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4359 /*!40101 SET character_set_client = @saved_cs_client */;
4360
4361 --
4362 -- Table structure for table `oai_sets_biblios`
4363 --
4364
4365 DROP TABLE IF EXISTS `oai_sets_biblios`;
4366 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4367 /*!40101 SET character_set_client = utf8 */;
4368 CREATE TABLE `oai_sets_biblios` (
4369   `biblionumber` int(11) NOT NULL,
4370   `set_id` int(11) NOT NULL,
4371   PRIMARY KEY (`biblionumber`,`set_id`),
4372   KEY `oai_sets_biblios_ibfk_2` (`set_id`),
4373   CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4374 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4375 /*!40101 SET character_set_client = @saved_cs_client */;
4376
4377 --
4378 -- Table structure for table `oai_sets_descriptions`
4379 --
4380
4381 DROP TABLE IF EXISTS `oai_sets_descriptions`;
4382 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4383 /*!40101 SET character_set_client = utf8 */;
4384 CREATE TABLE `oai_sets_descriptions` (
4385   `set_id` int(11) NOT NULL,
4386   `description` varchar(255) NOT NULL,
4387   KEY `oai_sets_descriptions_ibfk_1` (`set_id`),
4388   CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4389 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4390 /*!40101 SET character_set_client = @saved_cs_client */;
4391
4392 --
4393 -- Table structure for table `oai_sets_mappings`
4394 --
4395
4396 DROP TABLE IF EXISTS `oai_sets_mappings`;
4397 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4398 /*!40101 SET character_set_client = utf8 */;
4399 CREATE TABLE `oai_sets_mappings` (
4400   `set_id` int(11) NOT NULL,
4401   `rule_order` int(11) DEFAULT NULL,
4402   `rule_operator` varchar(3) DEFAULT NULL,
4403   `marcfield` char(3) NOT NULL,
4404   `marcsubfield` char(1) NOT NULL,
4405   `operator` varchar(8) NOT NULL DEFAULT 'equal',
4406   `marcvalue` varchar(80) NOT NULL,
4407   KEY `oai_sets_mappings_ibfk_1` (`set_id`),
4408   CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4409 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4410 /*!40101 SET character_set_client = @saved_cs_client */;
4411
4412 --
4413 -- Table structure for table `oauth_access_tokens`
4414 --
4415
4416 DROP TABLE IF EXISTS `oauth_access_tokens`;
4417 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4418 /*!40101 SET character_set_client = utf8 */;
4419 CREATE TABLE `oauth_access_tokens` (
4420   `access_token` varchar(191) NOT NULL COMMENT 'generarated access token',
4421   `client_id` varchar(191) NOT NULL COMMENT 'the client id the access token belongs to',
4422   `expires` int(11) NOT NULL COMMENT 'expiration time in seconds',
4423   PRIMARY KEY (`access_token`)
4424 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4425 /*!40101 SET character_set_client = @saved_cs_client */;
4426
4427 --
4428 -- Table structure for table `old_issues`
4429 --
4430
4431 DROP TABLE IF EXISTS `old_issues`;
4432 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4433 /*!40101 SET character_set_client = utf8 */;
4434 CREATE TABLE `old_issues` (
4435   `issue_id` int(11) NOT NULL COMMENT 'primary key for issues table',
4436   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
4437   `issuer_id` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the user who checked out this item',
4438   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out',
4439   `date_due` datetime DEFAULT NULL COMMENT 'date the item is due (yyyy-mm-dd)',
4440   `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
4441   `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned',
4442   `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
4443   `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
4444   `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
4445   `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
4446   `auto_renew_error` varchar(32) DEFAULT NULL COMMENT 'automatic renewal error',
4447   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this record was last touched',
4448   `issuedate` datetime DEFAULT NULL COMMENT 'date the item was checked out or issued',
4449   `onsite_checkout` int(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag',
4450   `note` longtext DEFAULT NULL COMMENT 'issue note text',
4451   `notedate` datetime DEFAULT NULL COMMENT 'datetime of issue note (yyyy-mm-dd hh:mm::ss)',
4452   `noteseen` int(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null',
4453   PRIMARY KEY (`issue_id`),
4454   KEY `old_issuesborridx` (`borrowernumber`),
4455   KEY `old_issuesitemidx` (`itemnumber`),
4456   KEY `branchcode_idx` (`branchcode`),
4457   KEY `old_bordate` (`borrowernumber`,`timestamp`),
4458   KEY `old_issues_ibfk_borrowers_borrowernumber` (`issuer_id`),
4459   CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4460   CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4461   CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
4462 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4463 /*!40101 SET character_set_client = @saved_cs_client */;
4464
4465 --
4466 -- Table structure for table `old_reserves`
4467 --
4468
4469 DROP TABLE IF EXISTS `old_reserves`;
4470 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4471 /*!40101 SET character_set_client = utf8 */;
4472 CREATE TABLE `old_reserves` (
4473   `reserve_id` int(11) NOT NULL COMMENT 'primary key',
4474   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
4475   `reservedate` date DEFAULT NULL COMMENT 'the date the hold was places',
4476   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key from the biblio table defining which bib record this hold is on',
4477   `item_group_id` int(11) DEFAULT NULL COMMENT 'foreign key from the item_groups table defining if this is an item group level hold',
4478   `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at',
4479   `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
4480   `notificationdate` date DEFAULT NULL COMMENT 'currently unused',
4481   `reminderdate` date DEFAULT NULL COMMENT 'currently unused',
4482   `cancellationdate` date DEFAULT NULL COMMENT 'the date this hold was cancelled',
4483   `cancellation_reason` varchar(80) DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
4484   `reservenotes` longtext DEFAULT NULL COMMENT 'notes related to this hold',
4485   `priority` smallint(6) NOT NULL DEFAULT 1 COMMENT 'where in the queue the patron sits',
4486   `found` varchar(1) DEFAULT NULL COMMENT 'a one letter code defining what the status is of the hold is after it has been confirmed',
4487   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this hold was last updated',
4488   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with',
4489   `waitingdate` date DEFAULT NULL COMMENT 'the date the item was marked as waiting for the patron at the library',
4490   `expirationdate` date DEFAULT NULL COMMENT 'the date the hold expires (usually the date entered by the patron to say they don''t need the hold after a certain date)',
4491   `patron_expiration_date` date DEFAULT NULL COMMENT 'the date the hold expires - usually the date entered by the patron to say they don''t need the hold after a certain date',
4492   `lowestPriority` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no)',
4493   `suspend` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'in this hold suspended (1 for yes, 0 for no)',
4494   `suspend_until` datetime DEFAULT NULL COMMENT 'the date this hold is suspended until (NULL for infinitely)',
4495   `itemtype` varchar(10) DEFAULT NULL COMMENT 'If record level hold, the optional itemtype of the item the patron is requesting',
4496   `item_level_hold` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is the hold placed at item level',
4497   `non_priority` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is this a non priority hold',
4498   PRIMARY KEY (`reserve_id`),
4499   KEY `old_reserves_borrowernumber` (`borrowernumber`),
4500   KEY `old_reserves_biblionumber` (`biblionumber`),
4501   KEY `old_reserves_itemnumber` (`itemnumber`),
4502   KEY `old_reserves_branchcode` (`branchcode`),
4503   KEY `old_reserves_itemtype` (`itemtype`),
4504   KEY `old_reserves_ibfk_ig` (`item_group_id`),
4505   CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4506   CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4507   CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4508   CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE SET NULL ON UPDATE SET NULL,
4509   CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL
4510 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4511 /*!40101 SET character_set_client = @saved_cs_client */;
4512
4513 --
4514 -- Table structure for table `overduerules`
4515 --
4516
4517 DROP TABLE IF EXISTS `overduerules`;
4518 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4519 /*!40101 SET character_set_client = utf8 */;
4520 CREATE TABLE `overduerules` (
4521   `overduerules_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the overduerules',
4522   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the branches table to define which branch this rule is for (if blank it''s all libraries)',
4523   `categorycode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the categories table to define which patron category this rule is for',
4524   `delay1` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the first notice is sent',
4525   `letter1` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the first notice',
4526   `debarred1` varchar(1) DEFAULT '0' COMMENT 'is the patron restricted when the first notice is sent (1 for yes, 0 for no)',
4527   `delay2` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the second notice is sent',
4528   `debarred2` varchar(1) DEFAULT '0' COMMENT 'is the patron restricted when the second notice is sent (1 for yes, 0 for no)',
4529   `letter2` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the second notice',
4530   `delay3` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the third notice is sent',
4531   `letter3` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the third notice',
4532   `debarred3` int(1) DEFAULT 0 COMMENT 'is the patron restricted when the third notice is sent (1 for yes, 0 for no)',
4533   PRIMARY KEY (`overduerules_id`),
4534   UNIQUE KEY `overduerules_branch_cat` (`branchcode`,`categorycode`)
4535 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4536 /*!40101 SET character_set_client = @saved_cs_client */;
4537
4538 --
4539 -- Table structure for table `overduerules_transport_types`
4540 --
4541
4542 DROP TABLE IF EXISTS `overduerules_transport_types`;
4543 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4544 /*!40101 SET character_set_client = utf8 */;
4545 CREATE TABLE `overduerules_transport_types` (
4546   `id` int(11) NOT NULL AUTO_INCREMENT,
4547   `letternumber` int(1) NOT NULL DEFAULT 1,
4548   `message_transport_type` varchar(20) NOT NULL DEFAULT 'email',
4549   `overduerules_id` int(11) NOT NULL,
4550   PRIMARY KEY (`id`),
4551   KEY `overduerules_fk` (`overduerules_id`),
4552   KEY `mtt_fk` (`message_transport_type`),
4553   CONSTRAINT `mtt_fk` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
4554   CONSTRAINT `overduerules_fk` FOREIGN KEY (`overduerules_id`) REFERENCES `overduerules` (`overduerules_id`) ON DELETE CASCADE ON UPDATE CASCADE
4555 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4556 /*!40101 SET character_set_client = @saved_cs_client */;
4557
4558 --
4559 -- Table structure for table `patron_consent`
4560 --
4561
4562 DROP TABLE IF EXISTS `patron_consent`;
4563 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4564 /*!40101 SET character_set_client = utf8 */;
4565 CREATE TABLE `patron_consent` (
4566   `id` int(11) NOT NULL AUTO_INCREMENT,
4567   `borrowernumber` int(11) NOT NULL,
4568   `type` enum('GDPR_PROCESSING') DEFAULT NULL COMMENT 'allows for future extension',
4569   `given_on` datetime DEFAULT NULL,
4570   `refused_on` datetime DEFAULT NULL,
4571   PRIMARY KEY (`id`),
4572   KEY `borrowernumber` (`borrowernumber`),
4573   CONSTRAINT `patron_consent_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4574 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4575 /*!40101 SET character_set_client = @saved_cs_client */;
4576
4577 --
4578 -- Table structure for table `patron_list_patrons`
4579 --
4580
4581 DROP TABLE IF EXISTS `patron_list_patrons`;
4582 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4583 /*!40101 SET character_set_client = utf8 */;
4584 CREATE TABLE `patron_list_patrons` (
4585   `patron_list_patron_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
4586   `patron_list_id` int(11) NOT NULL COMMENT 'the list this entry is part of',
4587   `borrowernumber` int(11) NOT NULL COMMENT 'the borrower that is part of this list',
4588   PRIMARY KEY (`patron_list_patron_id`),
4589   KEY `patron_list_id` (`patron_list_id`),
4590   KEY `borrowernumber` (`borrowernumber`),
4591   CONSTRAINT `patron_list_patrons_ibfk_1` FOREIGN KEY (`patron_list_id`) REFERENCES `patron_lists` (`patron_list_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4592   CONSTRAINT `patron_list_patrons_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4593 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4594 /*!40101 SET character_set_client = @saved_cs_client */;
4595
4596 --
4597 -- Table structure for table `patron_lists`
4598 --
4599
4600 DROP TABLE IF EXISTS `patron_lists`;
4601 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4602 /*!40101 SET character_set_client = utf8 */;
4603 CREATE TABLE `patron_lists` (
4604   `patron_list_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
4605   `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'the list''s name',
4606   `owner` int(11) NOT NULL COMMENT 'borrowernumber of the list creator',
4607   `shared` tinyint(1) DEFAULT 0,
4608   PRIMARY KEY (`patron_list_id`),
4609   KEY `owner` (`owner`),
4610   CONSTRAINT `patron_lists_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4611 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4612 /*!40101 SET character_set_client = @saved_cs_client */;
4613
4614 --
4615 -- Table structure for table `patronimage`
4616 --
4617
4618 DROP TABLE IF EXISTS `patronimage`;
4619 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4620 /*!40101 SET character_set_client = utf8 */;
4621 CREATE TABLE `patronimage` (
4622   `borrowernumber` int(11) NOT NULL COMMENT 'the borrowernumber of the patron this image is attached to (borrowers.borrowernumber)',
4623   `mimetype` varchar(15) NOT NULL COMMENT 'the format of the image (png, jpg, etc)',
4624   `imagefile` mediumblob NOT NULL COMMENT 'the image',
4625   PRIMARY KEY (`borrowernumber`),
4626   CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4627 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4628 /*!40101 SET character_set_client = @saved_cs_client */;
4629
4630 --
4631 -- Table structure for table `pending_offline_operations`
4632 --
4633
4634 DROP TABLE IF EXISTS `pending_offline_operations`;
4635 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4636 /*!40101 SET character_set_client = utf8 */;
4637 CREATE TABLE `pending_offline_operations` (
4638   `operationid` int(11) NOT NULL AUTO_INCREMENT,
4639   `userid` varchar(30) NOT NULL,
4640   `branchcode` varchar(10) NOT NULL,
4641   `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
4642   `action` varchar(10) NOT NULL,
4643   `barcode` varchar(20) DEFAULT NULL,
4644   `cardnumber` varchar(32) DEFAULT NULL,
4645   `amount` decimal(28,6) DEFAULT NULL,
4646   PRIMARY KEY (`operationid`)
4647 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4648 /*!40101 SET character_set_client = @saved_cs_client */;
4649
4650 --
4651 -- Table structure for table `permissions`
4652 --
4653
4654 DROP TABLE IF EXISTS `permissions`;
4655 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4656 /*!40101 SET character_set_client = utf8 */;
4657 CREATE TABLE `permissions` (
4658   `module_bit` int(11) NOT NULL DEFAULT 0,
4659   `code` varchar(64) NOT NULL DEFAULT '',
4660   `description` varchar(255) DEFAULT NULL,
4661   PRIMARY KEY (`module_bit`,`code`),
4662   CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`) ON DELETE CASCADE ON UPDATE CASCADE
4663 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4664 /*!40101 SET character_set_client = @saved_cs_client */;
4665
4666 --
4667 -- Table structure for table `plugin_data`
4668 --
4669
4670 DROP TABLE IF EXISTS `plugin_data`;
4671 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4672 /*!40101 SET character_set_client = utf8 */;
4673 CREATE TABLE `plugin_data` (
4674   `plugin_class` varchar(255) NOT NULL,
4675   `plugin_key` varchar(255) NOT NULL,
4676   `plugin_value` mediumtext DEFAULT NULL,
4677   PRIMARY KEY (`plugin_class`(191),`plugin_key`(191))
4678 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4679 /*!40101 SET character_set_client = @saved_cs_client */;
4680
4681 --
4682 -- Table structure for table `plugin_methods`
4683 --
4684
4685 DROP TABLE IF EXISTS `plugin_methods`;
4686 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4687 /*!40101 SET character_set_client = utf8 */;
4688 CREATE TABLE `plugin_methods` (
4689   `plugin_class` varchar(255) NOT NULL,
4690   `plugin_method` varchar(255) NOT NULL,
4691   PRIMARY KEY (`plugin_class`(191),`plugin_method`(191))
4692 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4693 /*!40101 SET character_set_client = @saved_cs_client */;
4694
4695 --
4696 -- Table structure for table `printers_profile`
4697 --
4698
4699 DROP TABLE IF EXISTS `printers_profile`;
4700 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4701 /*!40101 SET character_set_client = utf8 */;
4702 CREATE TABLE `printers_profile` (
4703   `profile_id` int(4) NOT NULL AUTO_INCREMENT,
4704   `printer_name` varchar(40) NOT NULL DEFAULT 'Default Printer',
4705   `template_id` int(4) NOT NULL DEFAULT 0,
4706   `paper_bin` varchar(20) NOT NULL DEFAULT 'Bypass',
4707   `offset_horz` float NOT NULL DEFAULT 0,
4708   `offset_vert` float NOT NULL DEFAULT 0,
4709   `creep_horz` float NOT NULL DEFAULT 0,
4710   `creep_vert` float NOT NULL DEFAULT 0,
4711   `units` char(20) NOT NULL DEFAULT 'POINT',
4712   `creator` char(15) NOT NULL DEFAULT 'Labels',
4713   PRIMARY KEY (`profile_id`),
4714   UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`,`creator`)
4715 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4716 /*!40101 SET character_set_client = @saved_cs_client */;
4717
4718 --
4719 -- Table structure for table `problem_reports`
4720 --
4721
4722 DROP TABLE IF EXISTS `problem_reports`;
4723 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4724 /*!40101 SET character_set_client = utf8 */;
4725 CREATE TABLE `problem_reports` (
4726   `reportid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4727   `title` varchar(40) NOT NULL DEFAULT '' COMMENT 'report subject line',
4728   `content` text NOT NULL COMMENT 'report message content',
4729   `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'the user who created the problem report',
4730   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'borrower''s branch',
4731   `username` varchar(75) DEFAULT NULL COMMENT 'OPAC username',
4732   `problempage` text DEFAULT NULL COMMENT 'page the user triggered the problem report form from',
4733   `recipient` enum('admin','library') NOT NULL DEFAULT 'library' COMMENT 'the ''to-address'' of the problem report',
4734   `created_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'timestamp of report submission',
4735   `status` varchar(6) NOT NULL DEFAULT 'New' COMMENT 'status of the report. New, Viewed, Closed',
4736   PRIMARY KEY (`reportid`),
4737   KEY `problem_reports_ibfk1` (`borrowernumber`),
4738   KEY `problem_reports_ibfk2` (`branchcode`),
4739   CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4740   CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4741 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4742 /*!40101 SET character_set_client = @saved_cs_client */;
4743
4744 --
4745 -- Table structure for table `pseudonymized_borrower_attributes`
4746 --
4747
4748 DROP TABLE IF EXISTS `pseudonymized_borrower_attributes`;
4749 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4750 /*!40101 SET character_set_client = utf8 */;
4751 CREATE TABLE `pseudonymized_borrower_attributes` (
4752   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Row id field',
4753   `transaction_id` int(11) NOT NULL,
4754   `code` varchar(10) NOT NULL COMMENT 'foreign key from the borrower_attribute_types table, defines which custom field this value was entered for',
4755   `attribute` varchar(255) DEFAULT NULL COMMENT 'custom patron field value',
4756   PRIMARY KEY (`id`),
4757   KEY `pseudonymized_borrower_attributes_ibfk_1` (`transaction_id`),
4758   KEY `anonymized_borrower_attributes_ibfk_2` (`code`),
4759   CONSTRAINT `anonymized_borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
4760   CONSTRAINT `pseudonymized_borrower_attributes_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pseudonymized_transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4761 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4762 /*!40101 SET character_set_client = @saved_cs_client */;
4763
4764 --
4765 -- Table structure for table `pseudonymized_transactions`
4766 --
4767
4768 DROP TABLE IF EXISTS `pseudonymized_transactions`;
4769 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4770 /*!40101 SET character_set_client = utf8 */;
4771 CREATE TABLE `pseudonymized_transactions` (
4772   `id` int(11) NOT NULL AUTO_INCREMENT,
4773   `hashed_borrowernumber` varchar(60) NOT NULL,
4774   `has_cardnumber` tinyint(1) NOT NULL DEFAULT 0,
4775   `title` longtext DEFAULT NULL,
4776   `city` longtext DEFAULT NULL,
4777   `state` mediumtext DEFAULT NULL,
4778   `zipcode` varchar(25) DEFAULT NULL,
4779   `country` mediumtext DEFAULT NULL,
4780   `branchcode` varchar(10) NOT NULL DEFAULT '',
4781   `categorycode` varchar(10) NOT NULL DEFAULT '',
4782   `dateenrolled` date DEFAULT NULL,
4783   `sex` varchar(1) DEFAULT NULL,
4784   `sort1` varchar(80) DEFAULT NULL,
4785   `sort2` varchar(80) DEFAULT NULL,
4786   `datetime` datetime DEFAULT NULL,
4787   `transaction_branchcode` varchar(10) DEFAULT NULL,
4788   `transaction_type` varchar(16) DEFAULT NULL,
4789   `itemnumber` int(11) DEFAULT NULL,
4790   `itemtype` varchar(10) DEFAULT NULL,
4791   `holdingbranch` varchar(10) DEFAULT NULL,
4792   `homebranch` varchar(10) DEFAULT NULL,
4793   `location` varchar(80) DEFAULT NULL,
4794   `itemcallnumber` varchar(255) DEFAULT NULL,
4795   `ccode` varchar(80) DEFAULT NULL,
4796   PRIMARY KEY (`id`),
4797   KEY `pseudonymized_transactions_ibfk_1` (`categorycode`),
4798   KEY `pseudonymized_transactions_borrowers_ibfk_2` (`branchcode`),
4799   KEY `pseudonymized_transactions_borrowers_ibfk_3` (`transaction_branchcode`)
4800 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4801 /*!40101 SET character_set_client = @saved_cs_client */;
4802
4803 --
4804 -- Table structure for table `quotes`
4805 --
4806
4807 DROP TABLE IF EXISTS `quotes`;
4808 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4809 /*!40101 SET character_set_client = utf8 */;
4810 CREATE TABLE `quotes` (
4811   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the quote',
4812   `source` mediumtext DEFAULT NULL COMMENT 'source/credit for the quote',
4813   `text` longtext NOT NULL COMMENT 'text of the quote',
4814   `timestamp` datetime DEFAULT NULL COMMENT 'date and time that the quote last appeared in the opac',
4815   PRIMARY KEY (`id`)
4816 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4817 /*!40101 SET character_set_client = @saved_cs_client */;
4818
4819 --
4820 -- Table structure for table `ratings`
4821 --
4822
4823 DROP TABLE IF EXISTS `ratings`;
4824 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4825 /*!40101 SET character_set_client = utf8 */;
4826 CREATE TABLE `ratings` (
4827   `borrowernumber` int(11) NOT NULL COMMENT 'the borrowernumber of the patron who left this rating (borrowers.borrowernumber)',
4828   `biblionumber` int(11) NOT NULL COMMENT 'the biblio this rating is for (biblio.biblionumber)',
4829   `rating_value` tinyint(1) NOT NULL COMMENT 'the rating, from 1 to 5',
4830   `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
4831   PRIMARY KEY (`borrowernumber`,`biblionumber`),
4832   KEY `ratings_ibfk_2` (`biblionumber`),
4833   CONSTRAINT `ratings_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4834   CONSTRAINT `ratings_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4835 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4836 /*!40101 SET character_set_client = @saved_cs_client */;
4837
4838 --
4839 -- Table structure for table `recalls`
4840 --
4841
4842 DROP TABLE IF EXISTS `recalls`;
4843 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4844 /*!40101 SET character_set_client = utf8 */;
4845 CREATE TABLE `recalls` (
4846   `recall_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique identifier for this recall',
4847   `patron_id` int(11) NOT NULL DEFAULT 0 COMMENT 'Identifier for patron who requested recall',
4848   `created_date` datetime DEFAULT NULL COMMENT 'Date the recall was requested',
4849   `biblio_id` int(11) NOT NULL DEFAULT 0 COMMENT 'Identifier for bibliographic record that has been recalled',
4850   `pickup_library_id` varchar(10) DEFAULT NULL COMMENT 'Identifier for recall pickup library',
4851   `completed_date` datetime DEFAULT NULL COMMENT 'Date the recall is completed (fulfilled, cancelled or expired)',
4852   `notes` mediumtext DEFAULT NULL COMMENT 'Notes related to the recall',
4853   `priority` smallint(6) DEFAULT NULL COMMENT 'Where in the queue the patron sits',
4854   `status` enum('requested','overdue','waiting','in_transit','cancelled','expired','fulfilled') DEFAULT 'requested' COMMENT 'Status of recall',
4855   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Date and time the recall was last updated',
4856   `item_id` int(11) DEFAULT NULL COMMENT 'Identifier for item record that was recalled, if an item-level recall',
4857   `waiting_date` datetime DEFAULT NULL COMMENT 'Date an item was marked as waiting for the patron at the library',
4858   `expiration_date` datetime DEFAULT NULL COMMENT 'Date recall is no longer required, or date recall will expire after waiting on shelf for pickup',
4859   `completed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Flag if recall is old and no longer active, i.e. expired, cancelled or completed',
4860   `item_level` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Flag if recall is for a specific item',
4861   PRIMARY KEY (`recall_id`),
4862   KEY `recalls_ibfk_1` (`patron_id`),
4863   KEY `recalls_ibfk_2` (`biblio_id`),
4864   KEY `recalls_ibfk_3` (`item_id`),
4865   KEY `recalls_ibfk_4` (`pickup_library_id`),
4866   CONSTRAINT `recalls_ibfk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4867   CONSTRAINT `recalls_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4868   CONSTRAINT `recalls_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4869   CONSTRAINT `recalls_ibfk_4` FOREIGN KEY (`pickup_library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4870 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Information related to recalls in Koha';
4871 /*!40101 SET character_set_client = @saved_cs_client */;
4872
4873 --
4874 -- Table structure for table `repeatable_holidays`
4875 --
4876
4877 DROP TABLE IF EXISTS `repeatable_holidays`;
4878 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4879 /*!40101 SET character_set_client = utf8 */;
4880 CREATE TABLE `repeatable_holidays` (
4881   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4882   `branchcode` varchar(10) NOT NULL COMMENT 'foreign key from the branches table, defines which branch this closing is for',
4883   `weekday` smallint(6) DEFAULT NULL COMMENT 'day of the week (0=Sunday, 1=Monday, etc) this closing is repeated on',
4884   `day` smallint(6) DEFAULT NULL COMMENT 'day of the month this closing is on',
4885   `month` smallint(6) DEFAULT NULL COMMENT 'month this closing is in',
4886   `title` varchar(50) NOT NULL DEFAULT '' COMMENT 'title of this closing',
4887   `description` mediumtext NOT NULL COMMENT 'description for this closing',
4888   PRIMARY KEY (`id`),
4889   KEY `repeatable_holidays_ibfk_1` (`branchcode`),
4890   CONSTRAINT `repeatable_holidays_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4891 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4892 /*!40101 SET character_set_client = @saved_cs_client */;
4893
4894 --
4895 -- Table structure for table `reports_dictionary`
4896 --
4897
4898 DROP TABLE IF EXISTS `reports_dictionary`;
4899 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4900 /*!40101 SET character_set_client = utf8 */;
4901 CREATE TABLE `reports_dictionary` (
4902   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4903   `name` varchar(255) DEFAULT NULL COMMENT 'name for this definition',
4904   `description` mediumtext DEFAULT NULL COMMENT 'description for this definition',
4905   `date_created` datetime DEFAULT NULL COMMENT 'date and time this definition was created',
4906   `date_modified` datetime DEFAULT NULL COMMENT 'date and time this definition was last modified',
4907   `saved_sql` mediumtext DEFAULT NULL COMMENT 'SQL snippet for us in reports',
4908   `report_area` varchar(6) DEFAULT NULL COMMENT 'Koha module this definition is for Circulation, Catalog, Patrons, Acquistions, Accounts)',
4909   PRIMARY KEY (`id`),
4910   KEY `dictionary_area_idx` (`report_area`)
4911 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4912 /*!40101 SET character_set_client = @saved_cs_client */;
4913
4914 --
4915 -- Table structure for table `reserves`
4916 --
4917
4918 DROP TABLE IF EXISTS `reserves`;
4919 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4920 /*!40101 SET character_set_client = utf8 */;
4921 CREATE TABLE `reserves` (
4922   `reserve_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
4923   `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
4924   `reservedate` date DEFAULT NULL COMMENT 'the date the hold was placed',
4925   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblio table defining which bib record this hold is on',
4926   `item_group_id` int(11) DEFAULT NULL COMMENT 'foreign key from the item_groups table defining if this is an item group level hold',
4927   `branchcode` varchar(10) NOT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at',
4928   `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
4929   `notificationdate` date DEFAULT NULL COMMENT 'currently unused',
4930   `reminderdate` date DEFAULT NULL COMMENT 'currently unused',
4931   `cancellationdate` date DEFAULT NULL COMMENT 'the date this hold was cancelled',
4932   `cancellation_reason` varchar(80) DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
4933   `reservenotes` longtext DEFAULT NULL COMMENT 'notes related to this hold',
4934   `priority` smallint(6) NOT NULL DEFAULT 1 COMMENT 'where in the queue the patron sits',
4935   `found` varchar(1) DEFAULT NULL COMMENT 'a one letter code defining what the status is of the hold is after it has been confirmed',
4936   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this hold was last updated',
4937   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with',
4938   `waitingdate` date DEFAULT NULL COMMENT 'the date the item was marked as waiting for the patron at the library',
4939   `expirationdate` date DEFAULT NULL COMMENT 'the date the hold expires (calculated value)',
4940   `patron_expiration_date` date DEFAULT NULL COMMENT 'the date the hold expires - usually the date entered by the patron to say they don''t need the hold after a certain date',
4941   `lowestPriority` tinyint(1) NOT NULL DEFAULT 0,
4942   `suspend` tinyint(1) NOT NULL DEFAULT 0,
4943   `suspend_until` datetime DEFAULT NULL,
4944   `itemtype` varchar(10) DEFAULT NULL COMMENT 'If record level hold, the optional itemtype of the item the patron is requesting',
4945   `item_level_hold` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is the hold placed at item level',
4946   `non_priority` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is this a non priority hold',
4947   PRIMARY KEY (`reserve_id`),
4948   KEY `priorityfoundidx` (`priority`,`found`),
4949   KEY `borrowernumber` (`borrowernumber`),
4950   KEY `biblionumber` (`biblionumber`),
4951   KEY `itemnumber` (`itemnumber`),
4952   KEY `branchcode` (`branchcode`),
4953   KEY `desk_id` (`desk_id`),
4954   KEY `itemtype` (`itemtype`),
4955   KEY `reserves_ibfk_ig` (`item_group_id`),
4956   CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4957   CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4958   CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4959   CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
4960   CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
4961   CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE,
4962   CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE
4963 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4964 /*!40101 SET character_set_client = @saved_cs_client */;
4965
4966 --
4967 -- Table structure for table `restriction_types`
4968 --
4969
4970 DROP TABLE IF EXISTS `restriction_types`;
4971 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4972 /*!40101 SET character_set_client = utf8 */;
4973 CREATE TABLE `restriction_types` (
4974   `code` varchar(50) NOT NULL,
4975   `display_text` text NOT NULL,
4976   `is_system` tinyint(1) NOT NULL DEFAULT 0,
4977   `is_default` tinyint(1) NOT NULL DEFAULT 0,
4978   PRIMARY KEY (`code`)
4979 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4980 /*!40101 SET character_set_client = @saved_cs_client */;
4981
4982 --
4983 -- Table structure for table `return_claims`
4984 --
4985
4986 DROP TABLE IF EXISTS `return_claims`;
4987 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4988 /*!40101 SET character_set_client = utf8 */;
4989 CREATE TABLE `return_claims` (
4990   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the return claim',
4991   `itemnumber` int(11) NOT NULL COMMENT 'ID of the item',
4992   `issue_id` int(11) DEFAULT NULL COMMENT 'ID of the checkout that triggered the claim',
4993   `borrowernumber` int(11) NOT NULL COMMENT 'ID of the patron',
4994   `notes` mediumtext DEFAULT NULL COMMENT 'Notes about the claim',
4995   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Time and date the claim was created',
4996   `created_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that registered the claim',
4997   `updated_on` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Time and date of the latest change on the claim (notes)',
4998   `updated_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that updated the claim',
4999   `resolution` varchar(80) DEFAULT NULL COMMENT 'Resolution code (RETURN_CLAIM_RESOLUTION AVs)',
5000   `resolved_on` timestamp NULL DEFAULT NULL COMMENT 'Time and date the claim was resolved',
5001   `resolved_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that resolved the claim',
5002   PRIMARY KEY (`id`),
5003   UNIQUE KEY `item_issue` (`itemnumber`,`issue_id`),
5004   KEY `itemnumber` (`itemnumber`),
5005   KEY `rc_borrowers_ibfk` (`borrowernumber`),
5006   KEY `rc_created_by_ibfk` (`created_by`),
5007   KEY `rc_updated_by_ibfk` (`updated_by`),
5008   KEY `rc_resolved_by_ibfk` (`resolved_by`),
5009   CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5010   CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5011   CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5012   CONSTRAINT `rc_resolved_by_ibfk` FOREIGN KEY (`resolved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5013   CONSTRAINT `rc_updated_by_ibfk` FOREIGN KEY (`updated_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5014 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5015 /*!40101 SET character_set_client = @saved_cs_client */;
5016
5017 --
5018 -- Table structure for table `reviews`
5019 --
5020
5021 DROP TABLE IF EXISTS `reviews`;
5022 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5023 /*!40101 SET character_set_client = utf8 */;
5024 CREATE TABLE `reviews` (
5025   `reviewid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for this comment',
5026   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron left this comment',
5027   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key from the biblio table defining which bibliographic record this comment is for',
5028   `review` mediumtext DEFAULT NULL COMMENT 'the body of the comment',
5029   `approved` tinyint(4) DEFAULT 0 COMMENT 'whether this comment has been approved by a librarian (1 for yes, 0 for no)',
5030   `datereviewed` datetime DEFAULT NULL COMMENT 'the date the comment was left',
5031   PRIMARY KEY (`reviewid`),
5032   KEY `reviews_ibfk_1` (`borrowernumber`),
5033   KEY `reviews_ibfk_2` (`biblionumber`),
5034   CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5035   CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
5036 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5037 /*!40101 SET character_set_client = @saved_cs_client */;
5038
5039 --
5040 -- Table structure for table `saved_reports`
5041 --
5042
5043 DROP TABLE IF EXISTS `saved_reports`;
5044 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5045 /*!40101 SET character_set_client = utf8 */;
5046 CREATE TABLE `saved_reports` (
5047   `id` int(11) NOT NULL AUTO_INCREMENT,
5048   `report_id` int(11) DEFAULT NULL,
5049   `report` longtext DEFAULT NULL,
5050   `date_run` datetime DEFAULT NULL,
5051   PRIMARY KEY (`id`)
5052 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5053 /*!40101 SET character_set_client = @saved_cs_client */;
5054
5055 --
5056 -- Table structure for table `saved_sql`
5057 --
5058
5059 DROP TABLE IF EXISTS `saved_sql`;
5060 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5061 /*!40101 SET character_set_client = utf8 */;
5062 CREATE TABLE `saved_sql` (
5063   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id and primary key assigned by Koha',
5064   `borrowernumber` int(11) DEFAULT NULL COMMENT 'the staff member who created this report (borrowers.borrowernumber)',
5065   `date_created` datetime DEFAULT NULL COMMENT 'the date this report was created',
5066   `last_modified` datetime DEFAULT NULL COMMENT 'the date this report was last edited',
5067   `savedsql` mediumtext DEFAULT NULL COMMENT 'the SQL for this report',
5068   `last_run` datetime DEFAULT NULL,
5069   `report_name` varchar(255) NOT NULL DEFAULT '' COMMENT 'the name of this report',
5070   `type` varchar(255) DEFAULT NULL COMMENT 'always 1 for tabular',
5071   `notes` mediumtext DEFAULT NULL COMMENT 'the notes or description given to this report',
5072   `cache_expiry` int(11) NOT NULL DEFAULT 300,
5073   `public` tinyint(1) NOT NULL DEFAULT 0,
5074   `report_area` varchar(6) DEFAULT NULL,
5075   `report_group` varchar(80) DEFAULT NULL,
5076   `report_subgroup` varchar(80) DEFAULT NULL,
5077   `mana_id` int(11) DEFAULT NULL,
5078   PRIMARY KEY (`id`),
5079   KEY `sql_area_group_idx` (`report_group`,`report_subgroup`),
5080   KEY `boridx` (`borrowernumber`)
5081 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5082 /*!40101 SET character_set_client = @saved_cs_client */;
5083
5084 --
5085 -- Table structure for table `search_field`
5086 --
5087
5088 DROP TABLE IF EXISTS `search_field`;
5089 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5090 /*!40101 SET character_set_client = utf8 */;
5091 CREATE TABLE `search_field` (
5092   `id` int(11) NOT NULL AUTO_INCREMENT,
5093   `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
5094   `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
5095   `type` enum('','string','date','number','boolean','sum','isbn','stdno','year','callnumber') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
5096   `weight` decimal(5,2) DEFAULT NULL,
5097   `facet_order` tinyint(4) DEFAULT NULL COMMENT 'the order place of the field in facet list if faceted',
5098   `staff_client` tinyint(1) NOT NULL DEFAULT 1,
5099   `opac` tinyint(1) NOT NULL DEFAULT 1,
5100   `mandatory` tinyint(1) DEFAULT NULL COMMENT 'if marked this field is not editable or removable',
5101   PRIMARY KEY (`id`),
5102   UNIQUE KEY `name` (`name`(191))
5103 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5104 /*!40101 SET character_set_client = @saved_cs_client */;
5105
5106 --
5107 -- Table structure for table `search_filters`
5108 --
5109
5110 DROP TABLE IF EXISTS `search_filters`;
5111 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5112 /*!40101 SET character_set_client = utf8 */;
5113 CREATE TABLE `search_filters` (
5114   `search_filter_id` int(11) NOT NULL AUTO_INCREMENT,
5115   `name` varchar(255) NOT NULL COMMENT 'filter name',
5116   `query` mediumtext DEFAULT NULL COMMENT 'filter query part',
5117   `limits` mediumtext DEFAULT NULL COMMENT 'filter limits part',
5118   `opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether this filter is shown on OPAC',
5119   `staff_client` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether this filter is shown in staff client',
5120   PRIMARY KEY (`search_filter_id`)
5121 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5122 /*!40101 SET character_set_client = @saved_cs_client */;
5123
5124 --
5125 -- Table structure for table `search_history`
5126 --
5127
5128 DROP TABLE IF EXISTS `search_history`;
5129 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5130 /*!40101 SET character_set_client = utf8 */;
5131 CREATE TABLE `search_history` (
5132   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'search history id',
5133   `userid` int(11) NOT NULL COMMENT 'the patron who performed the search (borrowers.borrowernumber)',
5134   `sessionid` varchar(32) NOT NULL COMMENT 'a system generated session id',
5135   `query_desc` varchar(255) NOT NULL COMMENT 'the search that was performed',
5136   `query_cgi` mediumtext NOT NULL COMMENT 'the string to append to the search url to rerun the search',
5137   `type` varchar(16) NOT NULL DEFAULT 'biblio' COMMENT 'search type, must be ''biblio'' or ''authority''',
5138   `total` int(11) NOT NULL COMMENT 'the total of results found',
5139   `time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the search was run',
5140   PRIMARY KEY (`id`),
5141   KEY `userid` (`userid`),
5142   KEY `sessionid` (`sessionid`)
5143 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Opac search history results';
5144 /*!40101 SET character_set_client = @saved_cs_client */;
5145
5146 --
5147 -- Table structure for table `search_marc_map`
5148 --
5149
5150 DROP TABLE IF EXISTS `search_marc_map`;
5151 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5152 /*!40101 SET character_set_client = utf8 */;
5153 CREATE TABLE `search_marc_map` (
5154   `id` int(11) NOT NULL AUTO_INCREMENT,
5155   `index_name` enum('biblios','authorities') NOT NULL COMMENT 'what storage index this map is for',
5156   `marc_type` enum('marc21','unimarc') NOT NULL COMMENT 'what MARC type this map is for',
5157   `marc_field` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the MARC specifier for this field',
5158   PRIMARY KEY (`id`),
5159   UNIQUE KEY `index_name` (`index_name`,`marc_field`(191),`marc_type`),
5160   KEY `index_name_2` (`index_name`)
5161 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5162 /*!40101 SET character_set_client = @saved_cs_client */;
5163
5164 --
5165 -- Table structure for table `search_marc_to_field`
5166 --
5167
5168 DROP TABLE IF EXISTS `search_marc_to_field`;
5169 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5170 /*!40101 SET character_set_client = utf8 */;
5171 CREATE TABLE `search_marc_to_field` (
5172   `search` tinyint(1) NOT NULL DEFAULT 1,
5173   `search_marc_map_id` int(11) NOT NULL,
5174   `search_field_id` int(11) NOT NULL,
5175   `facet` tinyint(1) DEFAULT 0 COMMENT 'true if a facet field should be generated for this',
5176   `suggestible` tinyint(1) DEFAULT 0 COMMENT 'true if this field can be used to generate suggestions for browse',
5177   `sort` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Sort defaults to 1 (Yes) and creates sort fields in the index, 0 (no) will prevent this',
5178   PRIMARY KEY (`search_marc_map_id`,`search_field_id`),
5179   KEY `search_field_id` (`search_field_id`),
5180   CONSTRAINT `search_marc_to_field_ibfk_1` FOREIGN KEY (`search_marc_map_id`) REFERENCES `search_marc_map` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
5181   CONSTRAINT `search_marc_to_field_ibfk_2` FOREIGN KEY (`search_field_id`) REFERENCES `search_field` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
5182 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5183 /*!40101 SET character_set_client = @saved_cs_client */;
5184
5185 --
5186 -- Table structure for table `serial`
5187 --
5188
5189 DROP TABLE IF EXISTS `serial`;
5190 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5191 /*!40101 SET character_set_client = utf8 */;
5192 CREATE TABLE `serial` (
5193   `serialid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the issue',
5194   `biblionumber` int(11) NOT NULL COMMENT 'foreign key for the biblio.biblionumber that this issue is attached to',
5195   `subscriptionid` int(11) NOT NULL COMMENT 'foreign key to the subscription.subscriptionid that this issue is part of',
5196   `serialseq` varchar(100) NOT NULL DEFAULT '' COMMENT 'issue information (volume, number, etc)',
5197   `serialseq_x` varchar(100) DEFAULT NULL COMMENT 'first part of issue information',
5198   `serialseq_y` varchar(100) DEFAULT NULL COMMENT 'second part of issue information',
5199   `serialseq_z` varchar(100) DEFAULT NULL COMMENT 'third part of issue information',
5200   `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'status code for this issue (see manual for full descriptions)',
5201   `planneddate` date DEFAULT NULL COMMENT 'date expected',
5202   `notes` mediumtext DEFAULT NULL COMMENT 'notes',
5203   `publisheddate` date DEFAULT NULL COMMENT 'date published',
5204   `publisheddatetext` varchar(100) DEFAULT NULL COMMENT 'date published (descriptive)',
5205   `claimdate` date DEFAULT NULL COMMENT 'date claimed',
5206   `claims_count` int(11) DEFAULT 0 COMMENT 'number of claims made related to this issue',
5207   `routingnotes` mediumtext DEFAULT NULL COMMENT 'notes from the routing list',
5208   PRIMARY KEY (`serialid`),
5209   KEY `serial_ibfk_1` (`biblionumber`),
5210   KEY `serial_ibfk_2` (`subscriptionid`),
5211   CONSTRAINT `serial_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5212   CONSTRAINT `serial_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
5213 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5214 /*!40101 SET character_set_client = @saved_cs_client */;
5215
5216 --
5217 -- Table structure for table `serialitems`
5218 --
5219
5220 DROP TABLE IF EXISTS `serialitems`;
5221 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5222 /*!40101 SET character_set_client = utf8 */;
5223 CREATE TABLE `serialitems` (
5224   `itemnumber` int(11) NOT NULL,
5225   `serialid` int(11) NOT NULL,
5226   PRIMARY KEY (`itemnumber`),
5227   KEY `serialitems_sfk_1` (`serialid`),
5228   CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
5229   CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
5230 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5231 /*!40101 SET character_set_client = @saved_cs_client */;
5232
5233 --
5234 -- Table structure for table `sessions`
5235 --
5236
5237 DROP TABLE IF EXISTS `sessions`;
5238 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5239 /*!40101 SET character_set_client = utf8 */;
5240 CREATE TABLE `sessions` (
5241   `id` varchar(32) NOT NULL,
5242   `a_session` longblob NOT NULL,
5243   PRIMARY KEY (`id`)
5244 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5245 /*!40101 SET character_set_client = @saved_cs_client */;
5246
5247 --
5248 -- Table structure for table `sms_providers`
5249 --
5250
5251 DROP TABLE IF EXISTS `sms_providers`;
5252 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5253 /*!40101 SET character_set_client = utf8 */;
5254 CREATE TABLE `sms_providers` (
5255   `id` int(11) NOT NULL AUTO_INCREMENT,
5256   `name` varchar(255) NOT NULL,
5257   `domain` varchar(255) NOT NULL,
5258   PRIMARY KEY (`id`),
5259   UNIQUE KEY `name` (`name`(191))
5260 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5261 /*!40101 SET character_set_client = @saved_cs_client */;
5262
5263 --
5264 -- Table structure for table `smtp_servers`
5265 --
5266
5267 DROP TABLE IF EXISTS `smtp_servers`;
5268 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5269 /*!40101 SET character_set_client = utf8 */;
5270 CREATE TABLE `smtp_servers` (
5271   `id` int(11) NOT NULL AUTO_INCREMENT,
5272   `name` varchar(80) NOT NULL,
5273   `host` varchar(80) NOT NULL DEFAULT 'localhost',
5274   `port` int(11) NOT NULL DEFAULT 25,
5275   `timeout` int(11) NOT NULL DEFAULT 120,
5276   `ssl_mode` enum('disabled','ssl','starttls') NOT NULL,
5277   `user_name` varchar(80) DEFAULT NULL,
5278   `password` varchar(80) DEFAULT NULL,
5279   `debug` tinyint(1) NOT NULL DEFAULT 0,
5280   `is_default` tinyint(1) NOT NULL DEFAULT 0,
5281   PRIMARY KEY (`id`),
5282   KEY `host_idx` (`host`)
5283 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5284 /*!40101 SET character_set_client = @saved_cs_client */;
5285
5286 --
5287 -- Table structure for table `social_data`
5288 --
5289
5290 DROP TABLE IF EXISTS `social_data`;
5291 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5292 /*!40101 SET character_set_client = utf8 */;
5293 CREATE TABLE `social_data` (
5294   `isbn` varchar(30) NOT NULL DEFAULT '',
5295   `num_critics` int(11) DEFAULT NULL,
5296   `num_critics_pro` int(11) DEFAULT NULL,
5297   `num_quotations` int(11) DEFAULT NULL,
5298   `num_videos` int(11) DEFAULT NULL,
5299   `score_avg` decimal(5,2) DEFAULT NULL,
5300   `num_scores` int(11) DEFAULT NULL,
5301   PRIMARY KEY (`isbn`)
5302 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5303 /*!40101 SET character_set_client = @saved_cs_client */;
5304
5305 --
5306 -- Table structure for table `special_holidays`
5307 --
5308
5309 DROP TABLE IF EXISTS `special_holidays`;
5310 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5311 /*!40101 SET character_set_client = utf8 */;
5312 CREATE TABLE `special_holidays` (
5313   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5314   `branchcode` varchar(10) NOT NULL COMMENT 'foreign key from the branches table, defines which branch this closing is for',
5315   `day` smallint(6) NOT NULL DEFAULT 0 COMMENT 'day of the month this closing is on',
5316   `month` smallint(6) NOT NULL DEFAULT 0 COMMENT 'month this closing is in',
5317   `year` smallint(6) NOT NULL DEFAULT 0 COMMENT 'year this closing is in',
5318   `isexception` smallint(1) NOT NULL DEFAULT 1 COMMENT 'is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)',
5319   `title` varchar(50) NOT NULL DEFAULT '' COMMENT 'title for this closing',
5320   `description` mediumtext NOT NULL COMMENT 'description of this closing',
5321   PRIMARY KEY (`id`),
5322   KEY `special_holidays_ibfk_1` (`branchcode`),
5323   CONSTRAINT `special_holidays_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5324 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5325 /*!40101 SET character_set_client = @saved_cs_client */;
5326
5327 --
5328 -- Table structure for table `statistics`
5329 --
5330
5331 DROP TABLE IF EXISTS `statistics`;
5332 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5333 /*!40101 SET character_set_client = utf8 */;
5334 CREATE TABLE `statistics` (
5335   `datetime` datetime DEFAULT NULL COMMENT 'date and time of the transaction',
5336   `branch` varchar(10) DEFAULT NULL COMMENT 'foreign key, branch where the transaction occurred',
5337   `value` double(16,4) DEFAULT NULL COMMENT 'monetary value associated with the transaction',
5338   `type` varchar(16) DEFAULT NULL COMMENT 'transaction type (localuse, issue, return, renew, writeoff, payment)',
5339   `other` longtext DEFAULT NULL COMMENT 'used by SIP',
5340   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key from the items table, links transaction to a specific item',
5341   `itemtype` varchar(10) DEFAULT NULL COMMENT 'foreign key from the itemtypes table, links transaction to a specific item type',
5342   `location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)',
5343   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table, links transaction to a specific borrower',
5344   `ccode` varchar(80) DEFAULT NULL COMMENT 'foreign key from the items table, links transaction to a specific collection code',
5345   `categorycode` varchar(10) DEFAULT NULL COMMENT 'foreign key from the borrowers table, links transaction to a specific borrower category',
5346   KEY `timeidx` (`datetime`),
5347   KEY `branch_idx` (`branch`),
5348   KEY `type_idx` (`type`),
5349   KEY `itemnumber_idx` (`itemnumber`),
5350   KEY `itemtype_idx` (`itemtype`),
5351   KEY `borrowernumber_idx` (`borrowernumber`),
5352   KEY `ccode_idx` (`ccode`)
5353 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5354 /*!40101 SET character_set_client = @saved_cs_client */;
5355
5356 --
5357 -- Table structure for table `stockrotationitems`
5358 --
5359
5360 DROP TABLE IF EXISTS `stockrotationitems`;
5361 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5362 /*!40101 SET character_set_client = utf8 */;
5363 CREATE TABLE `stockrotationitems` (
5364   `itemnumber_id` int(11) NOT NULL COMMENT 'Itemnumber to link to a stage & rota',
5365   `stage_id` int(11) NOT NULL COMMENT 'stage ID to link the item to',
5366   `indemand` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Should this item be skipped for rotation?',
5367   `fresh` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Flag showing item is only just added to rota',
5368   PRIMARY KEY (`itemnumber_id`),
5369   KEY `stockrotationitems_sifk` (`stage_id`),
5370   CONSTRAINT `stockrotationitems_iifk` FOREIGN KEY (`itemnumber_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5371   CONSTRAINT `stockrotationitems_sifk` FOREIGN KEY (`stage_id`) REFERENCES `stockrotationstages` (`stage_id`) ON DELETE CASCADE ON UPDATE CASCADE
5372 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5373 /*!40101 SET character_set_client = @saved_cs_client */;
5374
5375 --
5376 -- Table structure for table `stockrotationrotas`
5377 --
5378
5379 DROP TABLE IF EXISTS `stockrotationrotas`;
5380 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5381 /*!40101 SET character_set_client = utf8 */;
5382 CREATE TABLE `stockrotationrotas` (
5383   `rota_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Stockrotation rota ID',
5384   `title` varchar(100) NOT NULL COMMENT 'Title for this rota',
5385   `description` text NOT NULL COMMENT 'Description for this rota',
5386   `cyclical` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Should items on this rota keep cycling?',
5387   `active` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is this rota currently active?',
5388   PRIMARY KEY (`rota_id`),
5389   UNIQUE KEY `stockrotationrotas_title` (`title`)
5390 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5391 /*!40101 SET character_set_client = @saved_cs_client */;
5392
5393 --
5394 -- Table structure for table `stockrotationstages`
5395 --
5396
5397 DROP TABLE IF EXISTS `stockrotationstages`;
5398 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5399 /*!40101 SET character_set_client = utf8 */;
5400 CREATE TABLE `stockrotationstages` (
5401   `stage_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique stage ID',
5402   `position` int(11) NOT NULL COMMENT 'The position of this stage within its rota',
5403   `rota_id` int(11) NOT NULL COMMENT 'The rota this stage belongs to',
5404   `branchcode_id` varchar(10) NOT NULL COMMENT 'Branch this stage relates to',
5405   `duration` int(11) NOT NULL DEFAULT 4 COMMENT 'The number of days items shoud occupy this stage',
5406   PRIMARY KEY (`stage_id`),
5407   KEY `stockrotationstages_rifk` (`rota_id`),
5408   KEY `stockrotationstages_bifk` (`branchcode_id`),
5409   CONSTRAINT `stockrotationstages_bifk` FOREIGN KEY (`branchcode_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5410   CONSTRAINT `stockrotationstages_rifk` FOREIGN KEY (`rota_id`) REFERENCES `stockrotationrotas` (`rota_id`) ON DELETE CASCADE ON UPDATE CASCADE
5411 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5412 /*!40101 SET character_set_client = @saved_cs_client */;
5413
5414 --
5415 -- Table structure for table `subscription`
5416 --
5417
5418 DROP TABLE IF EXISTS `subscription`;
5419 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5420 /*!40101 SET character_set_client = utf8 */;
5421 CREATE TABLE `subscription` (
5422   `biblionumber` int(11) NOT NULL COMMENT 'foreign key for biblio.biblionumber that this subscription is attached to',
5423   `subscriptionid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for this subscription',
5424   `librarian` varchar(100) DEFAULT '' COMMENT 'the librarian''s username from borrowers.userid',
5425   `startdate` date DEFAULT NULL COMMENT 'start date for this subscription',
5426   `aqbooksellerid` int(11) DEFAULT 0 COMMENT 'foreign key for aqbooksellers.id to link to the vendor',
5427   `cost` int(11) DEFAULT 0,
5428   `aqbudgetid` int(11) DEFAULT 0,
5429   `weeklength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if monthlength or numberlength is set)',
5430   `monthlength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if weeklength or numberlength is set)',
5431   `numberlength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if monthlength or weeklength is set)',
5432   `periodicity` int(11) DEFAULT NULL COMMENT 'frequency type links to subscription_frequencies.id',
5433   `countissuesperunit` int(11) NOT NULL DEFAULT 1,
5434   `notes` longtext DEFAULT NULL COMMENT 'notes',
5435   `status` varchar(100) NOT NULL DEFAULT '' COMMENT 'status of this subscription',
5436   `lastvalue1` int(11) DEFAULT NULL,
5437   `innerloop1` int(11) DEFAULT 0,
5438   `lastvalue2` int(11) DEFAULT NULL,
5439   `innerloop2` int(11) DEFAULT 0,
5440   `lastvalue3` int(11) DEFAULT NULL,
5441   `innerloop3` int(11) DEFAULT 0,
5442   `firstacquidate` date DEFAULT NULL COMMENT 'first issue received date',
5443   `manualhistory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes or no to managing the history manually',
5444   `irregularity` mediumtext DEFAULT NULL COMMENT 'any irregularities in the subscription',
5445   `skip_serialseq` tinyint(1) NOT NULL DEFAULT 0,
5446   `letter` varchar(20) DEFAULT NULL,
5447   `numberpattern` int(11) DEFAULT NULL COMMENT 'the numbering pattern used links to subscription_numberpatterns.id',
5448   `locale` varchar(80) DEFAULT NULL COMMENT 'for foreign language subscriptions to display months, seasons, etc correctly',
5449   `distributedto` mediumtext DEFAULT NULL,
5450   `internalnotes` longtext DEFAULT NULL,
5451   `callnumber` mediumtext DEFAULT NULL COMMENT 'default call number',
5452   `location` varchar(80) DEFAULT '' COMMENT 'default shelving location (items.location)',
5453   `branchcode` varchar(10) NOT NULL DEFAULT '' COMMENT 'default branches (items.homebranch)',
5454   `lastbranch` varchar(10) DEFAULT NULL,
5455   `serialsadditems` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'does receiving this serial create an item record',
5456   `staffdisplaycount` int(11) DEFAULT NULL COMMENT 'how many issues to show to the staff',
5457   `opacdisplaycount` int(11) DEFAULT NULL COMMENT 'how many issues to show to the public',
5458   `graceperiod` int(11) NOT NULL DEFAULT 0 COMMENT 'grace period in days',
5459   `enddate` date DEFAULT NULL COMMENT 'subscription end date',
5460   `closed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes / no if the subscription is closed',
5461   `reneweddate` date DEFAULT NULL COMMENT 'date of last renewal for the subscription',
5462   `itemtype` varchar(10) DEFAULT NULL,
5463   `previousitemtype` varchar(10) DEFAULT NULL,
5464   `mana_id` int(11) DEFAULT NULL,
5465   `ccode` varchar(80) DEFAULT NULL COMMENT 'collection code to assign to serial items',
5466   PRIMARY KEY (`subscriptionid`),
5467   KEY `subscription_ibfk_1` (`periodicity`),
5468   KEY `subscription_ibfk_2` (`numberpattern`),
5469   KEY `subscription_ibfk_3` (`biblionumber`),
5470   CONSTRAINT `subscription_ibfk_1` FOREIGN KEY (`periodicity`) REFERENCES `subscription_frequencies` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
5471   CONSTRAINT `subscription_ibfk_2` FOREIGN KEY (`numberpattern`) REFERENCES `subscription_numberpatterns` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
5472   CONSTRAINT `subscription_ibfk_3` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
5473 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5474 /*!40101 SET character_set_client = @saved_cs_client */;
5475
5476 --
5477 -- Table structure for table `subscription_frequencies`
5478 --
5479
5480 DROP TABLE IF EXISTS `subscription_frequencies`;
5481 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5482 /*!40101 SET character_set_client = utf8 */;
5483 CREATE TABLE `subscription_frequencies` (
5484   `id` int(11) NOT NULL AUTO_INCREMENT,
5485   `description` mediumtext NOT NULL,
5486   `displayorder` int(11) DEFAULT NULL,
5487   `unit` enum('day','week','month','year') DEFAULT NULL,
5488   `unitsperissue` int(11) NOT NULL DEFAULT 1,
5489   `issuesperunit` int(11) NOT NULL DEFAULT 1,
5490   PRIMARY KEY (`id`)
5491 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5492 /*!40101 SET character_set_client = @saved_cs_client */;
5493
5494 --
5495 -- Table structure for table `subscription_numberpatterns`
5496 --
5497
5498 DROP TABLE IF EXISTS `subscription_numberpatterns`;
5499 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5500 /*!40101 SET character_set_client = utf8 */;
5501 CREATE TABLE `subscription_numberpatterns` (
5502   `id` int(11) NOT NULL AUTO_INCREMENT,
5503   `label` varchar(255) NOT NULL,
5504   `displayorder` int(11) DEFAULT NULL,
5505   `description` mediumtext NOT NULL,
5506   `numberingmethod` varchar(255) NOT NULL,
5507   `label1` varchar(255) DEFAULT NULL,
5508   `add1` int(11) DEFAULT NULL,
5509   `every1` int(11) DEFAULT NULL,
5510   `whenmorethan1` int(11) DEFAULT NULL,
5511   `setto1` int(11) DEFAULT NULL,
5512   `numbering1` varchar(255) DEFAULT NULL,
5513   `label2` varchar(255) DEFAULT NULL,
5514   `add2` int(11) DEFAULT NULL,
5515   `every2` int(11) DEFAULT NULL,
5516   `whenmorethan2` int(11) DEFAULT NULL,
5517   `setto2` int(11) DEFAULT NULL,
5518   `numbering2` varchar(255) DEFAULT NULL,
5519   `label3` varchar(255) DEFAULT NULL,
5520   `add3` int(11) DEFAULT NULL,
5521   `every3` int(11) DEFAULT NULL,
5522   `whenmorethan3` int(11) DEFAULT NULL,
5523   `setto3` int(11) DEFAULT NULL,
5524   `numbering3` varchar(255) DEFAULT NULL,
5525   PRIMARY KEY (`id`)
5526 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5527 /*!40101 SET character_set_client = @saved_cs_client */;
5528
5529 --
5530 -- Table structure for table `subscriptionhistory`
5531 --
5532
5533 DROP TABLE IF EXISTS `subscriptionhistory`;
5534 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5535 /*!40101 SET character_set_client = utf8 */;
5536 CREATE TABLE `subscriptionhistory` (
5537   `biblionumber` int(11) NOT NULL,
5538   `subscriptionid` int(11) NOT NULL,
5539   `histstartdate` date DEFAULT NULL,
5540   `histenddate` date DEFAULT NULL,
5541   `missinglist` longtext NOT NULL,
5542   `recievedlist` longtext NOT NULL,
5543   `opacnote` longtext DEFAULT NULL,
5544   `librariannote` longtext DEFAULT NULL,
5545   PRIMARY KEY (`subscriptionid`),
5546   KEY `subscription_history_ibfk_1` (`biblionumber`),
5547   CONSTRAINT `subscription_history_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5548   CONSTRAINT `subscription_history_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
5549 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5550 /*!40101 SET character_set_client = @saved_cs_client */;
5551
5552 --
5553 -- Table structure for table `subscriptionroutinglist`
5554 --
5555
5556 DROP TABLE IF EXISTS `subscriptionroutinglist`;
5557 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5558 /*!40101 SET character_set_client = utf8 */;
5559 CREATE TABLE `subscriptionroutinglist` (
5560   `routingid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5561   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key from the borrowers table, defines with patron is on the routing list',
5562   `ranking` int(11) DEFAULT NULL COMMENT 'where the patron stands in line to receive the serial',
5563   `subscriptionid` int(11) NOT NULL COMMENT 'foreign key from the subscription table, defines which subscription this routing list is for',
5564   PRIMARY KEY (`routingid`),
5565   UNIQUE KEY `subscriptionid` (`subscriptionid`,`borrowernumber`),
5566   KEY `subscriptionroutinglist_ibfk_1` (`borrowernumber`),
5567   CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5568   CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
5569 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5570 /*!40101 SET character_set_client = @saved_cs_client */;
5571
5572 --
5573 -- Table structure for table `suggestions`
5574 --
5575
5576 DROP TABLE IF EXISTS `suggestions`;
5577 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5578 /*!40101 SET character_set_client = utf8 */;
5579 CREATE TABLE `suggestions` (
5580   `suggestionid` int(8) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned automatically by Koha',
5581   `suggestedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the person making the suggestion, foreign key linking to the borrowers table',
5582   `suggesteddate` date NOT NULL COMMENT 'date the suggestion was submitted',
5583   `managedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table',
5584   `manageddate` date DEFAULT NULL COMMENT 'date the suggestion was updated',
5585   `acceptedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table',
5586   `accepteddate` date DEFAULT NULL COMMENT 'date the suggestion was marked as accepted',
5587   `rejectedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table',
5588   `rejecteddate` date DEFAULT NULL COMMENT 'date the suggestion was marked as rejected',
5589   `lastmodificationby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian who edit the suggestion for the last time',
5590   `lastmodificationdate` date DEFAULT NULL COMMENT 'date of the last modification',
5591   `STATUS` varchar(10) NOT NULL DEFAULT '' COMMENT 'suggestion status (ASKED, CHECKED, ACCEPTED, REJECTED, ORDERED, AVAILABLE or a value from the SUGGEST_STATUS authorised value category)',
5592   `archived` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the suggestion archived?',
5593   `note` longtext DEFAULT NULL COMMENT 'note entered on the suggestion',
5594   `staff_note` longtext DEFAULT NULL COMMENT 'non-public note entered on the suggestion',
5595   `author` varchar(80) DEFAULT NULL COMMENT 'author of the suggested item',
5596   `title` varchar(255) DEFAULT NULL COMMENT 'title of the suggested item',
5597   `copyrightdate` smallint(6) DEFAULT NULL COMMENT 'copyright date of the suggested item',
5598   `publishercode` varchar(255) DEFAULT NULL COMMENT 'publisher of the suggested item',
5599   `date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time the suggestion was updated',
5600   `volumedesc` varchar(255) DEFAULT NULL,
5601   `publicationyear` smallint(6) DEFAULT 0,
5602   `place` varchar(255) DEFAULT NULL COMMENT 'publication place of the suggested item',
5603   `isbn` varchar(30) DEFAULT NULL COMMENT 'isbn of the suggested item',
5604   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key linking the suggestion to the biblio table after the suggestion has been ordered',
5605   `reason` mediumtext DEFAULT NULL COMMENT 'reason for accepting or rejecting the suggestion',
5606   `patronreason` mediumtext DEFAULT NULL COMMENT 'reason for making the suggestion',
5607   `budgetid` int(11) DEFAULT NULL COMMENT 'foreign key linking the suggested budget to the aqbudgets table',
5608   `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key linking the suggested branch to the branches table',
5609   `collectiontitle` mediumtext DEFAULT NULL COMMENT 'collection name for the suggested item',
5610   `itemtype` varchar(30) DEFAULT NULL COMMENT 'suggested item type',
5611   `quantity` smallint(6) DEFAULT NULL COMMENT 'suggested quantity to be purchased',
5612   `currency` varchar(10) DEFAULT NULL COMMENT 'suggested currency for the suggested price',
5613   `price` decimal(28,6) DEFAULT NULL COMMENT 'suggested price',
5614   `total` decimal(28,6) DEFAULT NULL COMMENT 'suggested total cost (price*quantity updated for currency)',
5615   PRIMARY KEY (`suggestionid`),
5616   KEY `suggestedby` (`suggestedby`),
5617   KEY `managedby` (`managedby`),
5618   KEY `acceptedby` (`acceptedby`),
5619   KEY `rejectedby` (`rejectedby`),
5620   KEY `biblionumber` (`biblionumber`),
5621   KEY `budgetid` (`budgetid`),
5622   KEY `branchcode` (`branchcode`),
5623   KEY `status` (`STATUS`),
5624   KEY `suggestions_ibfk_lastmodificationby` (`lastmodificationby`),
5625   CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE,
5626   CONSTRAINT `suggestions_ibfk_acceptedby` FOREIGN KEY (`acceptedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5627   CONSTRAINT `suggestions_ibfk_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5628   CONSTRAINT `suggestions_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
5629   CONSTRAINT `suggestions_ibfk_lastmodificationby` FOREIGN KEY (`lastmodificationby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5630   CONSTRAINT `suggestions_ibfk_managedby` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5631   CONSTRAINT `suggestions_ibfk_rejectedby` FOREIGN KEY (`rejectedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5632   CONSTRAINT `suggestions_ibfk_suggestedby` FOREIGN KEY (`suggestedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5633 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5634 /*!40101 SET character_set_client = @saved_cs_client */;
5635
5636 --
5637 -- Table structure for table `systempreferences`
5638 --
5639
5640 DROP TABLE IF EXISTS `systempreferences`;
5641 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5642 /*!40101 SET character_set_client = utf8 */;
5643 CREATE TABLE `systempreferences` (
5644   `variable` varchar(50) NOT NULL DEFAULT '' COMMENT 'system preference name',
5645   `value` mediumtext DEFAULT NULL COMMENT 'system preference values',
5646   `options` longtext DEFAULT NULL COMMENT 'options for multiple choice system preferences',
5647   `explanation` mediumtext DEFAULT NULL COMMENT 'descriptive text for the system preference',
5648   `type` varchar(20) DEFAULT NULL COMMENT 'type of question this preference asks (multiple choice, plain text, yes or no, etc)',
5649   PRIMARY KEY (`variable`)
5650 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5651 /*!40101 SET character_set_client = @saved_cs_client */;
5652
5653 --
5654 -- Table structure for table `tables_settings`
5655 --
5656
5657 DROP TABLE IF EXISTS `tables_settings`;
5658 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5659 /*!40101 SET character_set_client = utf8 */;
5660 CREATE TABLE `tables_settings` (
5661   `module` varchar(255) NOT NULL,
5662   `page` varchar(255) NOT NULL,
5663   `tablename` varchar(255) NOT NULL,
5664   `default_display_length` smallint(6) DEFAULT NULL,
5665   `default_sort_order` varchar(255) DEFAULT NULL,
5666   PRIMARY KEY (`module`(191),`page`(191),`tablename`(191))
5667 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5668 /*!40101 SET character_set_client = @saved_cs_client */;
5669
5670 --
5671 -- Table structure for table `tags`
5672 --
5673
5674 DROP TABLE IF EXISTS `tags`;
5675 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5676 /*!40101 SET character_set_client = utf8 */;
5677 CREATE TABLE `tags` (
5678   `entry` varchar(255) NOT NULL DEFAULT '',
5679   `weight` bigint(20) NOT NULL DEFAULT 0,
5680   PRIMARY KEY (`entry`(191))
5681 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5682 /*!40101 SET character_set_client = @saved_cs_client */;
5683
5684 --
5685 -- Table structure for table `tags_all`
5686 --
5687
5688 DROP TABLE IF EXISTS `tags_all`;
5689 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5690 /*!40101 SET character_set_client = utf8 */;
5691 CREATE TABLE `tags_all` (
5692   `tag_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id and primary key',
5693   `borrowernumber` int(11) DEFAULT NULL COMMENT 'the patron who added the tag (borrowers.borrowernumber)',
5694   `biblionumber` int(11) NOT NULL COMMENT 'the bib record this tag was left on (biblio.biblionumber)',
5695   `term` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the tag',
5696   `language` int(4) DEFAULT NULL COMMENT 'the language the tag was left in',
5697   `date_created` datetime NOT NULL COMMENT 'the date the tag was added',
5698   PRIMARY KEY (`tag_id`),
5699   KEY `tags_borrowers_fk_1` (`borrowernumber`),
5700   KEY `tags_biblionumber_fk_1` (`biblionumber`),
5701   CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5702   CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5703 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5704 /*!40101 SET character_set_client = @saved_cs_client */;
5705
5706 --
5707 -- Table structure for table `tags_approval`
5708 --
5709
5710 DROP TABLE IF EXISTS `tags_approval`;
5711 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5712 /*!40101 SET character_set_client = utf8 */;
5713 CREATE TABLE `tags_approval` (
5714   `term` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the tag',
5715   `approved` int(1) NOT NULL DEFAULT 0 COMMENT 'whether the tag is approved or not (1=yes, 0=pending, -1=rejected)',
5716   `date_approved` datetime DEFAULT NULL COMMENT 'the date this tag was approved',
5717   `approved_by` int(11) DEFAULT NULL COMMENT 'the librarian who approved the tag (borrowers.borrowernumber)',
5718   `weight_total` int(9) NOT NULL DEFAULT 1 COMMENT 'the total number of times this tag was used',
5719   PRIMARY KEY (`term`),
5720   KEY `tags_approval_borrowers_fk_1` (`approved_by`),
5721   CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5722 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5723 /*!40101 SET character_set_client = @saved_cs_client */;
5724
5725 --
5726 -- Table structure for table `tags_index`
5727 --
5728
5729 DROP TABLE IF EXISTS `tags_index`;
5730 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5731 /*!40101 SET character_set_client = utf8 */;
5732 CREATE TABLE `tags_index` (
5733   `term` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the tag',
5734   `biblionumber` int(11) NOT NULL COMMENT 'the bib record this tag was used on (biblio.biblionumber)',
5735   `weight` int(9) NOT NULL DEFAULT 1 COMMENT 'the number of times this term was used on this bib record',
5736   PRIMARY KEY (`term`,`biblionumber`),
5737   KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
5738   CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5739   CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`) REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE
5740 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5741 /*!40101 SET character_set_client = @saved_cs_client */;
5742
5743 --
5744 -- Table structure for table `tickets`
5745 --
5746
5747 DROP TABLE IF EXISTS `tickets`;
5748 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5749 /*!40101 SET character_set_client = utf8 */;
5750 CREATE TABLE IF NOT EXISTS `tickets` (
5751   `id` int(11) NOT NULL auto_increment COMMENT 'primary key',
5752   `reporter_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the patron who reported the ticket',
5753   `reported_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time this ticket was reported',
5754   `title` text NOT NULL COMMENT 'ticket title',
5755   `body` text NOT NULL COMMENT 'ticket details',
5756   `resolver_id` int(11) DEFAULT NULL COMMENT 'id of the user who resolved the ticket',
5757   `resolved_date` datetime DEFAULT NULL COMMENT 'date and time this ticket was resolved',
5758   `biblio_id` int(11) DEFAULT NULL COMMENT 'id of biblio linked',
5759   PRIMARY KEY(`id`),
5760   CONSTRAINT `tickets_ibfk_1` FOREIGN KEY (`reporter_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5761   CONSTRAINT `tickets_ibfk_2` FOREIGN KEY (`resolver_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5762   CONSTRAINT `tickets_ibfk_3` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
5763 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5764 /*!40101 SET character_set_client = @saved_cs_client */;
5765
5766 --
5767 -- Table structure for table `ticket_updates`
5768 --
5769
5770 DROP TABLE IF EXISTS `ticket_updates`;
5771 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5772 /*!40101 SET character_set_client = utf8 */;
5773 CREATE TABLE IF NOT EXISTS `ticket_updates` (
5774   `id` int(11) NOT NULL auto_increment COMMENT 'primary key',
5775   `ticket_id` int(11) NOT NULL COMMENT 'id of catalog ticket the update relates to',
5776   `user_id` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the user who logged the update',
5777   `public` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote whether this update is public',
5778   `date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time this update was logged',
5779   `message` text NOT NULL COMMENT 'update message content',
5780   PRIMARY KEY(`id`),
5781   CONSTRAINT `ticket_updates_ibfk_1` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
5782   CONSTRAINT `ticket_updates_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
5783 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5784 /*!40101 SET character_set_client = @saved_cs_client */;
5785
5786 --
5787 -- Table structure for table `tmp_holdsqueue`
5788 --
5789
5790 DROP TABLE IF EXISTS `tmp_holdsqueue`;
5791 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5792 /*!40101 SET character_set_client = utf8 */;
5793 CREATE TABLE `tmp_holdsqueue` (
5794   `biblionumber` int(11) DEFAULT NULL,
5795   `itemnumber` int(11) DEFAULT NULL,
5796   `barcode` varchar(20) DEFAULT NULL,
5797   `surname` longtext NOT NULL,
5798   `firstname` mediumtext DEFAULT NULL,
5799   `phone` mediumtext DEFAULT NULL,
5800   `borrowernumber` int(11) NOT NULL,
5801   `cardnumber` varchar(32) DEFAULT NULL,
5802   `reservedate` date DEFAULT NULL,
5803   `title` longtext DEFAULT NULL,
5804   `itemcallnumber` varchar(255) DEFAULT NULL,
5805   `holdingbranch` varchar(10) DEFAULT NULL,
5806   `pickbranch` varchar(10) DEFAULT NULL,
5807   `notes` mediumtext DEFAULT NULL,
5808   `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
5809   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
5810   KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
5811   KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
5812   KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
5813   CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5814   CONSTRAINT `tmp_holdsqueue_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5815   CONSTRAINT `tmp_holdsqueue_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
5816 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5817 /*!40101 SET character_set_client = @saved_cs_client */;
5818
5819 --
5820 -- Table structure for table `transport_cost`
5821 --
5822
5823 DROP TABLE IF EXISTS `transport_cost`;
5824 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5825 /*!40101 SET character_set_client = utf8 */;
5826 CREATE TABLE `transport_cost` (
5827   `frombranch` varchar(10) NOT NULL,
5828   `tobranch` varchar(10) NOT NULL,
5829   `cost` decimal(6,2) NOT NULL,
5830   `disable_transfer` tinyint(1) NOT NULL DEFAULT 0,
5831   PRIMARY KEY (`frombranch`,`tobranch`),
5832   KEY `transport_cost_ibfk_2` (`tobranch`),
5833   CONSTRAINT `transport_cost_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5834   CONSTRAINT `transport_cost_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5835 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5836 /*!40101 SET character_set_client = @saved_cs_client */;
5837
5838 --
5839 -- Table structure for table `uploaded_files`
5840 --
5841
5842 DROP TABLE IF EXISTS `uploaded_files`;
5843 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5844 /*!40101 SET character_set_client = utf8 */;
5845 CREATE TABLE `uploaded_files` (
5846   `id` int(11) NOT NULL AUTO_INCREMENT,
5847   `hashvalue` char(40) NOT NULL,
5848   `filename` mediumtext NOT NULL,
5849   `dir` mediumtext NOT NULL,
5850   `filesize` int(11) DEFAULT NULL,
5851   `dtcreated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
5852   `uploadcategorycode` text DEFAULT NULL,
5853   `owner` int(11) DEFAULT NULL,
5854   `public` tinyint(4) DEFAULT NULL,
5855   `permanent` tinyint(4) DEFAULT NULL,
5856   PRIMARY KEY (`id`)
5857 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5858 /*!40101 SET character_set_client = @saved_cs_client */;
5859
5860 --
5861 -- Table structure for table `user_permissions`
5862 --
5863
5864 DROP TABLE IF EXISTS `user_permissions`;
5865 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5866 /*!40101 SET character_set_client = utf8 */;
5867 CREATE TABLE `user_permissions` (
5868   `borrowernumber` int(11) NOT NULL DEFAULT 0,
5869   `module_bit` int(11) NOT NULL DEFAULT 0,
5870   `code` varchar(64) NOT NULL,
5871   PRIMARY KEY (`borrowernumber`,`module_bit`,`code`),
5872   KEY `user_permissions_ibfk_1` (`borrowernumber`),
5873   KEY `user_permissions_ibfk_2` (`module_bit`,`code`),
5874   CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5875   CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`) REFERENCES `permissions` (`module_bit`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
5876 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5877 /*!40101 SET character_set_client = @saved_cs_client */;
5878
5879 --
5880 -- Table structure for table `userflags`
5881 --
5882
5883 DROP TABLE IF EXISTS `userflags`;
5884 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5885 /*!40101 SET character_set_client = utf8 */;
5886 CREATE TABLE `userflags` (
5887   `bit` int(11) NOT NULL DEFAULT 0,
5888   `flag` varchar(30) DEFAULT NULL,
5889   `flagdesc` varchar(255) DEFAULT NULL,
5890   `defaulton` int(11) DEFAULT NULL,
5891   PRIMARY KEY (`bit`)
5892 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5893 /*!40101 SET character_set_client = @saved_cs_client */;
5894
5895 --
5896 -- Table structure for table `vendor_edi_accounts`
5897 --
5898
5899 DROP TABLE IF EXISTS `vendor_edi_accounts`;
5900 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5901 /*!40101 SET character_set_client = utf8 */;
5902 CREATE TABLE `vendor_edi_accounts` (
5903   `id` int(11) NOT NULL AUTO_INCREMENT,
5904   `description` mediumtext NOT NULL,
5905   `host` varchar(40) DEFAULT NULL,
5906   `username` varchar(40) DEFAULT NULL,
5907   `password` varchar(40) DEFAULT NULL,
5908   `last_activity` date DEFAULT NULL,
5909   `vendor_id` int(11) DEFAULT NULL,
5910   `download_directory` mediumtext DEFAULT NULL,
5911   `upload_directory` mediumtext DEFAULT NULL,
5912   `san` varchar(20) DEFAULT NULL,
5913   `standard` varchar(3) DEFAULT 'EUR',
5914   `id_code_qualifier` varchar(3) DEFAULT '14',
5915   `transport` varchar(6) DEFAULT 'FTP',
5916   `quotes_enabled` tinyint(1) NOT NULL DEFAULT 0,
5917   `invoices_enabled` tinyint(1) NOT NULL DEFAULT 0,
5918   `orders_enabled` tinyint(1) NOT NULL DEFAULT 0,
5919   `responses_enabled` tinyint(1) NOT NULL DEFAULT 0,
5920   `auto_orders` tinyint(1) NOT NULL DEFAULT 0,
5921   `shipment_budget` int(11) DEFAULT NULL,
5922   `plugin` varchar(256) NOT NULL DEFAULT '',
5923   PRIMARY KEY (`id`),
5924   KEY `vendorid` (`vendor_id`),
5925   KEY `shipmentbudget` (`shipment_budget`),
5926   CONSTRAINT `vfk_shipment_budget` FOREIGN KEY (`shipment_budget`) REFERENCES `aqbudgets` (`budget_id`),
5927   CONSTRAINT `vfk_vendor_id` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`)
5928 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5929 /*!40101 SET character_set_client = @saved_cs_client */;
5930
5931 --
5932 -- Table structure for table `virtualshelfcontents`
5933 --
5934
5935 DROP TABLE IF EXISTS `virtualshelfcontents`;
5936 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5937 /*!40101 SET character_set_client = utf8 */;
5938 CREATE TABLE `virtualshelfcontents` (
5939   `shelfnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key linking to the virtualshelves table, defines the list that this record has been added to',
5940   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key linking to the biblio table, defines the bib record that has been added to the list',
5941   `flags` int(11) DEFAULT NULL,
5942   `dateadded` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this bib record was added to the list',
5943   `borrowernumber` int(11) DEFAULT NULL COMMENT 'borrower number that created this list entry (only the first one is saved: no need for use in/as key)',
5944   KEY `shelfnumber` (`shelfnumber`),
5945   KEY `biblionumber` (`biblionumber`),
5946   KEY `shelfcontents_ibfk_3` (`borrowernumber`),
5947   CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5948   CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5949   CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE
5950 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5951 /*!40101 SET character_set_client = @saved_cs_client */;
5952
5953 --
5954 -- Table structure for table `virtualshelfshares`
5955 --
5956
5957 DROP TABLE IF EXISTS `virtualshelfshares`;
5958 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5959 /*!40101 SET character_set_client = utf8 */;
5960 CREATE TABLE `virtualshelfshares` (
5961   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key',
5962   `shelfnumber` int(11) NOT NULL COMMENT 'foreign key for virtualshelves',
5963   `borrowernumber` int(11) DEFAULT NULL COMMENT 'borrower that accepted access to this list',
5964   `invitekey` varchar(10) DEFAULT NULL COMMENT 'temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet',
5965   `sharedate` datetime DEFAULT NULL COMMENT 'date of invitation or acceptance of invitation',
5966   PRIMARY KEY (`id`),
5967   KEY `virtualshelfshares_ibfk_1` (`shelfnumber`),
5968   KEY `virtualshelfshares_ibfk_2` (`borrowernumber`),
5969   CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5970   CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL
5971 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5972 /*!40101 SET character_set_client = @saved_cs_client */;
5973
5974 --
5975 -- Table structure for table `virtualshelves`
5976 --
5977
5978 DROP TABLE IF EXISTS `virtualshelves`;
5979 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5980 /*!40101 SET character_set_client = utf8 */;
5981 CREATE TABLE `virtualshelves` (
5982   `shelfnumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5983   `shelfname` varchar(255) DEFAULT NULL COMMENT 'name of the list',
5984   `owner` int(11) DEFAULT NULL COMMENT 'foreign key linking to the borrowers table (using borrowernumber) for the creator of this list (changed from varchar(80) to int)',
5985   `public` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If the list is public',
5986   `sortfield` varchar(16) DEFAULT 'title' COMMENT 'the field this list is sorted on',
5987   `lastmodified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time the list was last modified',
5988   `created_on` datetime NOT NULL COMMENT 'creation time',
5989   `allow_change_from_owner` tinyint(1) DEFAULT 1 COMMENT 'can owner change contents?',
5990   `allow_change_from_others` tinyint(1) DEFAULT 0 COMMENT 'can others change contents?',
5991   `allow_change_from_staff` tinyint(1) DEFAULT 0 COMMENT 'can staff change contents?',
5992   PRIMARY KEY (`shelfnumber`),
5993   KEY `virtualshelves_ibfk_1` (`owner`),
5994   CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL
5995 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5996 /*!40101 SET character_set_client = @saved_cs_client */;
5997
5998 --
5999 -- Table structure for table `z3950servers`
6000 --
6001
6002 DROP TABLE IF EXISTS `z3950servers`;
6003 /*!40101 SET @saved_cs_client     = @@character_set_client */;
6004 /*!40101 SET character_set_client = utf8 */;
6005 CREATE TABLE `z3950servers` (
6006   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
6007   `host` varchar(255) NOT NULL COMMENT 'target''s host name',
6008   `port` int(11) DEFAULT NULL COMMENT 'port number used to connect to target',
6009   `db` varchar(255) DEFAULT NULL COMMENT 'target''s database name',
6010   `userid` varchar(255) DEFAULT NULL COMMENT 'username needed to log in to target',
6011   `password` varchar(255) DEFAULT NULL COMMENT 'password needed to log in to target',
6012   `servername` longtext NOT NULL COMMENT 'name given to the target by the library',
6013   `checked` smallint(6) DEFAULT NULL COMMENT 'whether this target is checked by default  (1 for yes, 0 for no)',
6014   `rank` int(11) DEFAULT NULL COMMENT 'where this target appears in the list of targets',
6015   `syntax` varchar(80) NOT NULL COMMENT 'MARC format provided by this target',
6016   `timeout` int(11) NOT NULL DEFAULT 0 COMMENT 'number of seconds before Koha stops trying to access this server',
6017   `servertype` enum('zed','sru') NOT NULL DEFAULT 'zed' COMMENT 'zed means z39.50 server',
6018   `encoding` mediumtext NOT NULL COMMENT 'characters encoding provided by this target',
6019   `recordtype` enum('authority','biblio') NOT NULL DEFAULT 'biblio' COMMENT 'server contains bibliographic or authority records',
6020   `sru_options` varchar(255) DEFAULT NULL COMMENT 'options like sru=get, sru_version=1.1; will be passed to the server via ZOOM',
6021   `sru_fields` longtext DEFAULT NULL COMMENT 'contains the mapping between the Z3950 search fields and the specific SRU server indexes',
6022   `add_xslt` longtext DEFAULT NULL COMMENT 'zero or more paths to XSLT files to be processed on the search results',
6023   `attributes` varchar(255) DEFAULT NULL COMMENT 'additional attributes passed to PQF queries',
6024   PRIMARY KEY (`id`)
6025 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6026 /*!40101 SET character_set_client = @saved_cs_client */;
6027
6028 --
6029 -- Table structure for table `zebraqueue`
6030 --
6031
6032 DROP TABLE IF EXISTS `zebraqueue`;
6033 /*!40101 SET @saved_cs_client     = @@character_set_client */;
6034 /*!40101 SET character_set_client = utf8 */;
6035 CREATE TABLE `zebraqueue` (
6036   `id` int(11) NOT NULL AUTO_INCREMENT,
6037   `biblio_auth_number` bigint(20) unsigned NOT NULL DEFAULT 0,
6038   `operation` char(20) NOT NULL DEFAULT '',
6039   `server` char(20) NOT NULL DEFAULT '',
6040   `done` int(11) NOT NULL DEFAULT 0,
6041   `time` timestamp NOT NULL DEFAULT current_timestamp(),
6042   PRIMARY KEY (`id`),
6043   KEY `zebraqueue_lookup` (`server`,`biblio_auth_number`,`operation`,`done`)
6044 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6045 /*!40101 SET character_set_client = @saved_cs_client */;
6046 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
6047
6048 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
6049 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
6050 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
6051 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
6052 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
6053 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
6054 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
6055
6056 -- Dump completed on 2022-11-25 14:12:24