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