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