Bug 32030: Add users to licenses - DB
[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_user_roles`
2815 --
2816
2817 DROP TABLE IF EXISTS `erm_user_roles`;
2818 CREATE TABLE `erm_user_roles` (
2819     `agreement_id` INT(11) NULL COMMENT 'link to the agreement',
2820     `license_id` INT(11) NULL COMMENT 'link to the license',
2821     `user_id` INT(11) NOT NULL COMMENT 'link to the user',
2822     `role` VARCHAR(80) NOT NULL COMMENT 'role of the user',
2823     CONSTRAINT `erm_user_roles_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2824     CONSTRAINT `erm_user_roles_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2825     CONSTRAINT `erm_user_roles_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2826 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2827
2828 --
2829 -- Table structure for table `erm_licenses`
2830 --
2831
2832 DROP TABLE IF EXISTS `erm_licenses`;
2833 CREATE TABLE `erm_licenses` (
2834     `license_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2835     `vendor_id` INT(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
2836     `name` VARCHAR(255) NOT NULL COMMENT 'name of the license',
2837     `description` LONGTEXT DEFAULT NULL COMMENT 'description of the license',
2838     `type` VARCHAR(80) NOT NULL COMMENT 'type of the license',
2839     `status` VARCHAR(80) NOT NULL COMMENT 'current status of the license',
2840     `started_on` DATE COMMENT 'start of the license',
2841     `ended_on` DATE COMMENT 'end of the license',
2842     CONSTRAINT `erm_licenses_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
2843     PRIMARY KEY(`license_id`)
2844 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2845
2846 --
2847 -- Table structure for table `erm_agreement_licenses`
2848 --
2849
2850 DROP TABLE IF EXISTS `erm_agreement_licenses`;
2851 CREATE TABLE `erm_agreement_licenses` (
2852     `agreement_license_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2853     `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement',
2854     `license_id` INT(11) NOT NULL COMMENT 'link to the license',
2855     `status` VARCHAR(80) NOT NULL COMMENT 'current status of the license',
2856     `physical_location` VARCHAR(80) DEFAULT NULL COMMENT 'physical location of the license',
2857     `notes` mediumtext DEFAULT NULL COMMENT 'notes about this license',
2858     `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the license',
2859     CONSTRAINT `erm_agreement_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2860     CONSTRAINT `erm_agreement_licenses_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2861     PRIMARY KEY(`agreement_license_id`),
2862     UNIQUE KEY `erm_agreement_licenses_uniq` (`agreement_id`, `license_id`)
2863 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2864
2865 --
2866 -- Table structure for table `erm_agreement_relationships`
2867 --
2868
2869 DROP TABLE IF EXISTS `erm_agreement_relationships`;
2870 CREATE TABLE `erm_agreement_relationships` (
2871     `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement',
2872     `related_agreement_id` INT(11) NOT NULL COMMENT 'link to the related agreement',
2873     `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',
2874     `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship',
2875     CONSTRAINT `erm_agreement_relationships_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2876     CONSTRAINT `erm_agreement_relationships_ibfk_2` FOREIGN KEY (`related_agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2877     PRIMARY KEY(`agreement_id`, `related_agreement_id`)
2878 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2879
2880 --
2881 -- Table structure for table `erm_documents`
2882 --
2883
2884 DROP TABLE IF EXISTS `erm_documents`;
2885 CREATE TABLE `erm_documents` (
2886     `document_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2887     `agreement_id` INT(11) NULL COMMENT 'link to the agreement',
2888     `license_id` INT(11) NULL COMMENT 'link to the license',
2889     `file_name` varchar(255) DEFAULT NULL COMMENT 'name of the file',
2890     `file_type` varchar(255) DEFAULT NULL COMMENT 'type of the file',
2891     `file_description` varchar(255) DEFAULT NULL COMMENT 'description of the file',
2892     `file_content` longblob DEFAULT NULL COMMENT 'the content of the file',
2893     `uploaded_on` datetime DEFAULT NULL COMMENT 'datetime when the file as attached',
2894     `physical_location` VARCHAR(255) DEFAULT NULL COMMENT 'physical location of the document',
2895     `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the document',
2896     `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship',
2897     CONSTRAINT `erm_documents_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2898     CONSTRAINT `erm_documents_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2899     PRIMARY KEY(`document_id`)
2900 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2901
2902 --
2903 -- Table structure for table `erm_eholdings_packages`
2904 --
2905
2906 DROP TABLE IF EXISTS `erm_eholdings_packages`;
2907 CREATE TABLE `erm_eholdings_packages` (
2908     `package_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2909     `vendor_id` INT(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
2910     `name` VARCHAR(255) NOT NULL COMMENT 'name of the package',
2911     `external_id` VARCHAR(255) DEFAULT NULL COMMENT 'External key',
2912     `provider` ENUM('ebsco') DEFAULT NULL COMMENT 'External provider',
2913     `package_type` VARCHAR(80) DEFAULT NULL COMMENT 'type of the package',
2914     `content_type` VARCHAR(80) DEFAULT NULL COMMENT 'type of the package',
2915     `notes` mediumtext DEFAULT NULL COMMENT 'notes about this package',
2916     `created_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date of creation of the package',
2917     CONSTRAINT `erm_eholdings_packages_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
2918     PRIMARY KEY(`package_id`)
2919 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2920
2921 --
2922 -- Table structure for table `erm_eholdings_packages_agreements`
2923 --
2924
2925 DROP TABLE IF EXISTS `erm_eholdings_packages_agreements`;
2926 CREATE TABLE `erm_eholdings_packages_agreements` (
2927     `package_id` INT(11) NOT NULL COMMENT 'link to the package',
2928     `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement',
2929     UNIQUE KEY `erm_eholdings_packages_agreements_uniq` (`package_id`, `agreement_id`),
2930     CONSTRAINT `erm_eholdings_packages_agreements_ibfk_1` FOREIGN KEY (`package_id`) REFERENCES `erm_eholdings_packages` (`package_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2931     CONSTRAINT `erm_eholdings_packages_agreements_ibfk_2` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE
2932 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2933
2934 --
2935 -- Table structure for table `erm_eholdings_titles`
2936 --
2937
2938 DROP TABLE IF EXISTS `erm_eholdings_titles`;
2939 CREATE TABLE `erm_eholdings_titles` (
2940     `title_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2941     `biblio_id` INT(11) DEFAULT NULL,
2942     `publication_title` VARCHAR(255) DEFAULT NULL,
2943     `external_id` VARCHAR(255) DEFAULT NULL,
2944     `print_identifier` VARCHAR(255) DEFAULT NULL,
2945     `online_identifier` VARCHAR(255) DEFAULT NULL,
2946     `date_first_issue_online` VARCHAR(255) DEFAULT NULL,
2947     `num_first_vol_online` VARCHAR(255) DEFAULT NULL,
2948     `num_first_issue_online` VARCHAR(255) DEFAULT NULL,
2949     `date_last_issue_online` VARCHAR(255) DEFAULT NULL,
2950     `num_last_vol_online` VARCHAR(255) DEFAULT NULL,
2951     `num_last_issue_online` VARCHAR(255) DEFAULT NULL,
2952     `title_url` VARCHAR(255) DEFAULT NULL,
2953     `first_author` VARCHAR(255) DEFAULT NULL,
2954     `embargo_info` VARCHAR(255) DEFAULT NULL,
2955     `coverage_depth` VARCHAR(255) DEFAULT NULL,
2956     `notes` VARCHAR(255) DEFAULT NULL,
2957     `publisher_name` VARCHAR(255) DEFAULT NULL,
2958     `publication_type` VARCHAR(80) DEFAULT NULL,
2959     `date_monograph_published_print` VARCHAR(255) DEFAULT NULL,
2960     `date_monograph_published_online` VARCHAR(255) DEFAULT NULL,
2961     `monograph_volume` VARCHAR(255) DEFAULT NULL,
2962     `monograph_edition` VARCHAR(255) DEFAULT NULL,
2963     `first_editor` VARCHAR(255) DEFAULT NULL,
2964     `parent_publication_title_id` VARCHAR(255) DEFAULT NULL,
2965     `preceeding_publication_title_id` VARCHAR(255) DEFAULT NULL,
2966     `access_type` VARCHAR(255) DEFAULT NULL,
2967     CONSTRAINT `erm_eholdings_titles_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2968     PRIMARY KEY(`title_id`)
2969 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2970
2971 --
2972 -- Table structure for table `erm_eholdings_resources`
2973 --
2974
2975 DROP TABLE IF EXISTS `erm_eholdings_resources`;
2976 CREATE TABLE `erm_eholdings_resources` (
2977     `resource_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
2978     `title_id` INT(11) NOT NULL,
2979     `package_id` INT(11) NOT NULL,
2980     `vendor_id` INT(11) DEFAULT NULL,
2981     `started_on` DATE,
2982     `ended_on` DATE,
2983     `proxy` VARCHAR(80) DEFAULT NULL,
2984     UNIQUE KEY `erm_eholdings_resources_uniq` (`title_id`, `package_id`),
2985     CONSTRAINT `erm_eholdings_resources_ibfk_1` FOREIGN KEY (`title_id`) REFERENCES `erm_eholdings_titles` (`title_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2986     CONSTRAINT `erm_eholdings_resources_ibfk_2` FOREIGN KEY (`package_id`) REFERENCES `erm_eholdings_packages` (`package_id`) ON DELETE CASCADE ON UPDATE CASCADE,
2987     CONSTRAINT `erm_eholdings_resources_ibfk_3` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
2988     PRIMARY KEY(`resource_id`)
2989 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2990
2991 --
2992 -- Table structure for table `export_format`
2993 --
2994
2995 DROP TABLE IF EXISTS `export_format`;
2996 /*!40101 SET @saved_cs_client     = @@character_set_client */;
2997 /*!40101 SET character_set_client = utf8 */;
2998 CREATE TABLE `export_format` (
2999   `export_format_id` int(11) NOT NULL AUTO_INCREMENT,
3000   `profile` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
3001   `description` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
3002   `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
3003   `csv_separator` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ',',
3004   `field_separator` varchar(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3005   `subfield_separator` varchar(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3006   `encoding` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'utf8',
3007   `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'marc',
3008   `used_for` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT 'export_records',
3009   `staff_only` tinyint(1) NOT NULL DEFAULT 0,
3010   PRIMARY KEY (`export_format_id`),
3011   KEY `used_for_idx` (`used_for`(191)),
3012   KEY `staff_only_idx` (`staff_only`)
3013 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Used for CSV export';
3014 /*!40101 SET character_set_client = @saved_cs_client */;
3015
3016 --
3017 -- Table structure for table `hold_fill_targets`
3018 --
3019
3020 DROP TABLE IF EXISTS `hold_fill_targets`;
3021 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3022 /*!40101 SET character_set_client = utf8 */;
3023 CREATE TABLE `hold_fill_targets` (
3024   `borrowernumber` int(11) NOT NULL,
3025   `biblionumber` int(11) NOT NULL,
3026   `itemnumber` int(11) NOT NULL,
3027   `source_branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3028   `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
3029   `reserve_id` int(11) DEFAULT NULL,
3030   PRIMARY KEY (`itemnumber`),
3031   KEY `bib_branch` (`biblionumber`,`source_branchcode`),
3032   KEY `hold_fill_targets_ibfk_1` (`borrowernumber`),
3033   KEY `hold_fill_targets_ibfk_4` (`source_branchcode`),
3034   CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3035   CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3036   CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3037   CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3038 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3039 /*!40101 SET character_set_client = @saved_cs_client */;
3040
3041 --
3042 -- Table structure for table `housebound_profile`
3043 --
3044
3045 DROP TABLE IF EXISTS `housebound_profile`;
3046 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3047 /*!40101 SET character_set_client = utf8 */;
3048 CREATE TABLE `housebound_profile` (
3049   `borrowernumber` int(11) NOT NULL COMMENT 'Number of the borrower associated with this profile.',
3050   `day` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The preferred day of the week for delivery.',
3051   `frequency` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The Authorised_Value definining the pattern for delivery.',
3052   `fav_itemtypes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Free text describing preferred itemtypes.',
3053   `fav_subjects` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Free text describing preferred subjects.',
3054   `fav_authors` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Free text describing preferred authors.',
3055   `referral` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Free text indicating how the borrower was added to the service.',
3056   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Free text for additional notes.',
3057   PRIMARY KEY (`borrowernumber`),
3058   CONSTRAINT `housebound_profile_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3059 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3060 /*!40101 SET character_set_client = @saved_cs_client */;
3061
3062 --
3063 -- Table structure for table `housebound_role`
3064 --
3065
3066 DROP TABLE IF EXISTS `housebound_role`;
3067 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3068 /*!40101 SET character_set_client = utf8 */;
3069 CREATE TABLE `housebound_role` (
3070   `borrowernumber_id` int(11) NOT NULL COMMENT 'borrowernumber link',
3071   `housebound_chooser` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'set to 1 to indicate this patron is a housebound chooser volunteer',
3072   `housebound_deliverer` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'set to 1 to indicate this patron is a housebound deliverer volunteer',
3073   PRIMARY KEY (`borrowernumber_id`),
3074   CONSTRAINT `houseboundrole_bnfk` FOREIGN KEY (`borrowernumber_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3075 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3076 /*!40101 SET character_set_client = @saved_cs_client */;
3077
3078 --
3079 -- Table structure for table `housebound_visit`
3080 --
3081
3082 DROP TABLE IF EXISTS `housebound_visit`;
3083 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3084 /*!40101 SET character_set_client = utf8 */;
3085 CREATE TABLE `housebound_visit` (
3086   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID of the visit.',
3087   `borrowernumber` int(11) NOT NULL COMMENT 'Number of the borrower, & the profile, linked to this visit.',
3088   `appointment_date` date DEFAULT NULL COMMENT 'Date of visit.',
3089   `day_segment` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Rough time frame: ''morning'', ''afternoon'' ''evening''',
3090   `chooser_brwnumber` int(11) DEFAULT NULL COMMENT 'Number of the borrower to choose items  for delivery.',
3091   `deliverer_brwnumber` int(11) DEFAULT NULL COMMENT 'Number of the borrower to deliver items.',
3092   PRIMARY KEY (`id`),
3093   KEY `houseboundvisit_bnfk` (`borrowernumber`),
3094   KEY `houseboundvisit_bnfk_1` (`chooser_brwnumber`),
3095   KEY `houseboundvisit_bnfk_2` (`deliverer_brwnumber`),
3096   CONSTRAINT `houseboundvisit_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `housebound_profile` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3097   CONSTRAINT `houseboundvisit_bnfk_1` FOREIGN KEY (`chooser_brwnumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3098   CONSTRAINT `houseboundvisit_bnfk_2` FOREIGN KEY (`deliverer_brwnumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3099 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3100 /*!40101 SET character_set_client = @saved_cs_client */;
3101
3102 --
3103 -- Table structure for table `illcomments`
3104 --
3105
3106 DROP TABLE IF EXISTS `illcomments`;
3107 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3108 /*!40101 SET character_set_client = utf8 */;
3109 CREATE TABLE `illcomments` (
3110   `illcomment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the comment',
3111   `illrequest_id` bigint(20) unsigned NOT NULL COMMENT 'ILL request number',
3112   `borrowernumber` int(11) DEFAULT NULL COMMENT 'Link to the user who made the comment (could be librarian, patron or ILL partner library)',
3113   `comment` text COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'The text of the comment',
3114   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date and time when the comment was made',
3115   PRIMARY KEY (`illcomment_id`),
3116   KEY `illcomments_bnfk` (`borrowernumber`),
3117   KEY `illcomments_ifk` (`illrequest_id`),
3118   CONSTRAINT `illcomments_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3119   CONSTRAINT `illcomments_ifk` FOREIGN KEY (`illrequest_id`) REFERENCES `illrequests` (`illrequest_id`) ON DELETE CASCADE ON UPDATE CASCADE
3120 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3121 /*!40101 SET character_set_client = @saved_cs_client */;
3122
3123 --
3124 -- Table structure for table `illrequestattributes`
3125 --
3126
3127 DROP TABLE IF EXISTS `illrequestattributes`;
3128 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3129 /*!40101 SET character_set_client = utf8 */;
3130 CREATE TABLE `illrequestattributes` (
3131   `illrequest_id` bigint(20) unsigned NOT NULL COMMENT 'ILL request number',
3132   `type` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'API ILL property name',
3133   `value` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'API ILL property value',
3134   `readonly` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Is this attribute read only',
3135   PRIMARY KEY (`illrequest_id`,`type`(191)),
3136   CONSTRAINT `illrequestattributes_ifk` FOREIGN KEY (`illrequest_id`) REFERENCES `illrequests` (`illrequest_id`) ON DELETE CASCADE ON UPDATE CASCADE
3137 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3138 /*!40101 SET character_set_client = @saved_cs_client */;
3139
3140 --
3141 -- Table structure for table `illrequests`
3142 --
3143
3144 DROP TABLE IF EXISTS `illrequests`;
3145 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3146 /*!40101 SET character_set_client = utf8 */;
3147 CREATE TABLE `illrequests` (
3148   `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number',
3149   `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request',
3150   `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request',
3151   `due_date` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation',
3152   `branchcode` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The branch associated with the request',
3153   `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Current Koha status of request',
3154   `status_alias` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Foreign key to relevant authorised_values.authorised_value',
3155   `placed` date DEFAULT NULL COMMENT 'Date the request was placed',
3156   `replied` date DEFAULT NULL COMMENT 'Last API response',
3157   `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
3158   `completed` date DEFAULT NULL COMMENT 'Date the request was completed',
3159   `medium` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'The Koha request type',
3160   `accessurl` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Potential URL for accessing item',
3161   `cost` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Quotes cost of request',
3162   `price_paid` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Final cost of request',
3163   `notesopac` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Patron notes attached to request',
3164   `notesstaff` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Staff notes attached to request',
3165   `orderid` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Backend id attached to request',
3166   `backend` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'The backend used to create request',
3167   PRIMARY KEY (`illrequest_id`),
3168   KEY `illrequests_bnfk` (`borrowernumber`),
3169   KEY `illrequests_bcfk_2` (`branchcode`),
3170   KEY `illrequests_safk` (`status_alias`),
3171   CONSTRAINT `illrequests_bcfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3172   CONSTRAINT `illrequests_bnfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3173   CONSTRAINT `illrequests_safk` FOREIGN KEY (`status_alias`) REFERENCES `authorised_values` (`authorised_value`) ON DELETE SET NULL ON UPDATE CASCADE
3174 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3175 /*!40101 SET character_set_client = @saved_cs_client */;
3176
3177 --
3178 -- Table structure for table `import_auths`
3179 --
3180
3181 DROP TABLE IF EXISTS `import_auths`;
3182 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3183 /*!40101 SET character_set_client = utf8 */;
3184 CREATE TABLE `import_auths` (
3185   `import_record_id` int(11) NOT NULL,
3186   `matched_authid` int(11) DEFAULT NULL,
3187   `control_number` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3188   `authorized_heading` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3189   `original_source` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3190   KEY `import_auths_ibfk_1` (`import_record_id`),
3191   KEY `matched_authid` (`matched_authid`),
3192   CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3193 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3194 /*!40101 SET character_set_client = @saved_cs_client */;
3195
3196 --
3197 -- Table structure for table `import_batch_profiles`
3198 --
3199
3200 DROP TABLE IF EXISTS `import_batch_profiles`;
3201 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3202 /*!40101 SET character_set_client = utf8 */;
3203 CREATE TABLE `import_batch_profiles` (
3204   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier and primary key',
3205   `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'name of this profile',
3206   `matcher_id` int(11) DEFAULT NULL COMMENT 'the id of the match rule used (matchpoints.matcher_id)',
3207   `template_id` int(11) DEFAULT NULL COMMENT 'the id of the marc modification template',
3208   `overlay_action` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'how to handle duplicate records',
3209   `nomatch_action` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'how to handle records where no match is found',
3210   `item_action` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'what to do with item records',
3211   `parse_items` tinyint(1) DEFAULT NULL COMMENT 'should items be parsed',
3212   `record_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'type of record in the batch',
3213   `encoding` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'file encoding',
3214   `format` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'marc format',
3215   `comments` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any comments added when the file was uploaded',
3216   PRIMARY KEY (`id`),
3217   UNIQUE KEY `u_import_batch_profiles__name` (`name`)
3218 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3219 /*!40101 SET character_set_client = @saved_cs_client */;
3220
3221 --
3222 -- Table structure for table `import_batches`
3223 --
3224
3225 DROP TABLE IF EXISTS `import_batches`;
3226 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3227 /*!40101 SET character_set_client = utf8 */;
3228 CREATE TABLE `import_batches` (
3229   `import_batch_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier and primary key',
3230   `matcher_id` int(11) DEFAULT NULL COMMENT 'the id of the match rule used (matchpoints.matcher_id)',
3231   `template_id` int(11) DEFAULT NULL,
3232   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3233   `num_records` int(11) NOT NULL DEFAULT 0 COMMENT 'number of records in the file',
3234   `num_items` int(11) NOT NULL DEFAULT 0 COMMENT 'number of items in the file',
3235   `upload_timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the file was uploaded',
3236   `overlay_action` enum('replace','create_new','use_template','ignore') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'create_new' COMMENT 'how to handle duplicate records',
3237   `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',
3238   `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',
3239   `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',
3240   `batch_type` enum('batch','z3950','webservice') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'batch' COMMENT 'where this batch has come from',
3241   `record_type` enum('biblio','auth','holdings') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'biblio' COMMENT 'type of record in the batch',
3242   `file_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the name of the file uploaded',
3243   `comments` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any comments added when the file was uploaded',
3244   `profile_id` int(11) DEFAULT NULL,
3245   PRIMARY KEY (`import_batch_id`),
3246   KEY `branchcode` (`branchcode`),
3247   KEY `import_batches_ibfk_1` (`profile_id`),
3248   CONSTRAINT `import_batches_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `import_batch_profiles` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
3249 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3250 /*!40101 SET character_set_client = @saved_cs_client */;
3251
3252 --
3253 -- Table structure for table `import_biblios`
3254 --
3255
3256 DROP TABLE IF EXISTS `import_biblios`;
3257 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3258 /*!40101 SET character_set_client = utf8 */;
3259 CREATE TABLE `import_biblios` (
3260   `import_record_id` int(11) NOT NULL,
3261   `matched_biblionumber` int(11) DEFAULT NULL,
3262   `control_number` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3263   `original_source` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3264   `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3265   `author` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3266   `isbn` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3267   `issn` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3268   `has_items` tinyint(1) NOT NULL DEFAULT 0,
3269   PRIMARY KEY (`import_record_id`),
3270   KEY `import_biblios_ibfk_1` (`import_record_id`),
3271   KEY `matched_biblionumber` (`matched_biblionumber`),
3272   KEY `title` (`title`(191)),
3273   KEY `isbn` (`isbn`(191)),
3274   CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3275 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3276 /*!40101 SET character_set_client = @saved_cs_client */;
3277
3278 --
3279 -- Table structure for table `import_items`
3280 --
3281
3282 DROP TABLE IF EXISTS `import_items`;
3283 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3284 /*!40101 SET character_set_client = utf8 */;
3285 CREATE TABLE `import_items` (
3286   `import_items_id` int(11) NOT NULL AUTO_INCREMENT,
3287   `import_record_id` int(11) NOT NULL,
3288   `itemnumber` int(11) DEFAULT NULL,
3289   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3290   `status` enum('error','staged','imported','reverted','ignored') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'staged',
3291   `marcxml` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
3292   `import_error` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3293   PRIMARY KEY (`import_items_id`),
3294   KEY `import_items_ibfk_1` (`import_record_id`),
3295   KEY `itemnumber` (`itemnumber`),
3296   KEY `branchcode` (`branchcode`),
3297   CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3298 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3299 /*!40101 SET character_set_client = @saved_cs_client */;
3300
3301 --
3302 -- Table structure for table `import_record_matches`
3303 --
3304
3305 DROP TABLE IF EXISTS `import_record_matches`;
3306 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3307 /*!40101 SET character_set_client = utf8 */;
3308 CREATE TABLE `import_record_matches` (
3309   `import_record_id` int(11) NOT NULL COMMENT 'the id given to the imported bib record (import_records.import_record_id)',
3310   `candidate_match_id` int(11) NOT NULL COMMENT 'the biblio the imported record matches (biblio.biblionumber)',
3311   `score` int(11) NOT NULL DEFAULT 0 COMMENT 'the match score',
3312   `chosen` tinyint(1) DEFAULT NULL COMMENT 'whether this match has been allowed or denied',
3313   PRIMARY KEY (`import_record_id`,`candidate_match_id`),
3314   KEY `record_score` (`import_record_id`,`score`),
3315   CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3316 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3317 /*!40101 SET character_set_client = @saved_cs_client */;
3318
3319 --
3320 -- Table structure for table `import_records`
3321 --
3322
3323 DROP TABLE IF EXISTS `import_records`;
3324 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3325 /*!40101 SET character_set_client = utf8 */;
3326 CREATE TABLE `import_records` (
3327   `import_record_id` int(11) NOT NULL AUTO_INCREMENT,
3328   `import_batch_id` int(11) NOT NULL,
3329   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3330   `record_sequence` int(11) NOT NULL DEFAULT 0,
3331   `upload_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
3332   `import_date` date DEFAULT NULL,
3333   `marc` longblob NOT NULL,
3334   `marcxml` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
3335   `marcxml_old` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
3336   `record_type` enum('biblio','auth','holdings') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'biblio',
3337   `overlay_status` enum('no_match','auto_match','manual_match','match_applied') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'no_match',
3338   `status` enum('error','staged','imported','reverted','items_reverted','ignored') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'staged',
3339   `import_error` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3340   `encoding` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3341   PRIMARY KEY (`import_record_id`),
3342   KEY `branchcode` (`branchcode`),
3343   KEY `batch_sequence` (`import_batch_id`,`record_sequence`),
3344   KEY `batch_id_record_type` (`import_batch_id`,`record_type`),
3345   CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`) REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE
3346 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3347 /*!40101 SET character_set_client = @saved_cs_client */;
3348
3349 --
3350 -- Table structure for table `issues`
3351 --
3352
3353 DROP TABLE IF EXISTS `issues`;
3354 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3355 /*!40101 SET character_set_client = utf8 */;
3356 CREATE TABLE `issues` (
3357   `issue_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key for issues table',
3358   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
3359   `issuer_id` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the user who checked out this item',
3360   `itemnumber` int(11) NOT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out',
3361   `date_due` datetime DEFAULT NULL COMMENT 'datetime the item is due (yyyy-mm-dd hh:mm::ss)',
3362   `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',
3363   `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned, will be NULL until moved to old_issues',
3364   `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
3365   `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
3366   `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
3367   `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
3368   `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error',
3369   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this record was last touched',
3370   `issuedate` datetime DEFAULT NULL COMMENT 'date the item was checked out or issued',
3371   `onsite_checkout` int(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag',
3372   `note` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'issue note text',
3373   `notedate` datetime DEFAULT NULL COMMENT 'datetime of issue note (yyyy-mm-dd hh:mm::ss)',
3374   `noteseen` int(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null',
3375   PRIMARY KEY (`issue_id`),
3376   UNIQUE KEY `itemnumber` (`itemnumber`),
3377   KEY `issuesborridx` (`borrowernumber`),
3378   KEY `itemnumber_idx` (`itemnumber`),
3379   KEY `branchcode_idx` (`branchcode`),
3380   KEY `bordate` (`borrowernumber`,`timestamp`),
3381   KEY `issues_ibfk_borrowers_borrowernumber` (`issuer_id`),
3382   CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE,
3383   CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON UPDATE CASCADE,
3384   CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
3385 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3386 /*!40101 SET character_set_client = @saved_cs_client */;
3387
3388 --
3389 -- Table structure for table `item_circulation_alert_preferences`
3390 --
3391
3392 DROP TABLE IF EXISTS `item_circulation_alert_preferences`;
3393 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3394 /*!40101 SET character_set_client = utf8 */;
3395 CREATE TABLE `item_circulation_alert_preferences` (
3396   `id` int(11) NOT NULL AUTO_INCREMENT,
3397   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
3398   `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
3399   `item_type` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
3400   `notification` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
3401   PRIMARY KEY (`id`),
3402   KEY `branchcode` (`branchcode`,`categorycode`,`item_type`,`notification`)
3403 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3404 /*!40101 SET character_set_client = @saved_cs_client */;
3405
3406 --
3407 -- Table structure for table `items`
3408 --
3409
3410 DROP TABLE IF EXISTS `items`;
3411 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3412 /*!40101 SET character_set_client = utf8 */;
3413 CREATE TABLE `items` (
3414   `itemnumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key and unique identifier added by Koha',
3415   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from biblio table used to link this item to the right bib record',
3416   `biblioitemnumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblioitems table to link to item to additional information',
3417   `barcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'item barcode (MARC21 952$p)',
3418   `dateaccessioned` date DEFAULT NULL COMMENT 'date the item was acquired or added to Koha (MARC21 952$d)',
3419   `booksellerid` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'where the item was purchased (MARC21 952$e)',
3420   `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)',
3421   `price` decimal(8,2) DEFAULT NULL COMMENT 'purchase price (MARC21 952$g)',
3422   `replacementprice` decimal(8,2) DEFAULT NULL COMMENT 'cost the library charges to replace the item if it has been marked lost (MARC21 952$v)',
3423   `replacementpricedate` date DEFAULT NULL COMMENT 'the date the price is effective from (MARC21 952$w)',
3424   `datelastborrowed` date DEFAULT NULL COMMENT 'the date the item was last checked out/issued',
3425   `datelastseen` date DEFAULT NULL COMMENT 'the date the item was last see (usually the last time the barcode was scanned or inventory was done)',
3426   `stack` tinyint(1) DEFAULT NULL,
3427   `notforloan` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining why this item is not for loan (MARC21 952$7)',
3428   `damaged` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as damaged (MARC21 952$4)',
3429   `damaged_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as damaged, NULL if not damaged',
3430   `itemlost` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as lost (MARC21 952$1)',
3431   `itemlost_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as lost, NULL if not lost',
3432   `withdrawn` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'authorized value defining this item as withdrawn (MARC21 952$0)',
3433   `withdrawn_on` datetime DEFAULT NULL COMMENT 'the date and time an item was last marked as withdrawn, NULL if not withdrawn',
3434   `itemcallnumber` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'call number for this item (MARC21 952$o)',
3435   `coded_location_qualifier` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'coded location qualifier(MARC21 952$f)',
3436   `issues` smallint(6) DEFAULT 0 COMMENT 'number of times this item has been checked out/issued',
3437   `renewals` smallint(6) DEFAULT NULL COMMENT 'number of times this item has been renewed',
3438   `reserves` smallint(6) DEFAULT NULL COMMENT 'number of times this item has been placed on hold/reserved',
3439   `restricted` tinyint(1) DEFAULT NULL COMMENT 'authorized value defining use restrictions for this item (MARC21 952$5)',
3440   `itemnotes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'public notes on this item (MARC21 952$z)',
3441   `itemnotes_nonpublic` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'non-public notes on this item (MARC21 952$x)',
3442   `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)',
3443   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this item was last altered',
3444   `deleted_on` DATETIME DEFAULT NULL COMMENT 'date/time of deletion',
3445   `location` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)',
3446   `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',
3447   `onloan` date DEFAULT NULL COMMENT 'defines if item is checked out (NULL for not checked out, and due date for checked out)',
3448   `cn_source` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'classification source used on this item (MARC21 952$2)',
3449   `cn_sort` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'normalized form of the call number (MARC21 952$o) used for sorting',
3450   `ccode` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'authorized value for the collection code associated with this item (MARC21 952$8)',
3451   `materials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'materials specified (MARC21 952$3)',
3452   `uri` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'URL for the item (MARC21 952$u)',
3453   `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)',
3454   `more_subfields_xml` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'additional 952 subfields in XML format',
3455   `enumchron` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'serial enumeration/chronology for the item (MARC21 952$h)',
3456   `copynumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'copy number (MARC21 952$t)',
3457   `stocknumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'inventory number (MARC21 952$i)',
3458   `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.',
3459   `exclude_from_local_holds_priority` tinyint(1) DEFAULT NULL COMMENT 'Exclude this item from local holds priority',
3460   PRIMARY KEY (`itemnumber`),
3461   UNIQUE KEY `itembarcodeidx` (`barcode`),
3462   KEY `itemstocknumberidx` (`stocknumber`),
3463   KEY `itembinoidx` (`biblioitemnumber`),
3464   KEY `itembibnoidx` (`biblionumber`),
3465   KEY `homebranch` (`homebranch`),
3466   KEY `holdingbranch` (`holdingbranch`),
3467   KEY `itemcallnumber` (`itemcallnumber`(191)),
3468   KEY `items_location` (`location`),
3469   KEY `items_ccode` (`ccode`),
3470   KEY `itype_idx` (`itype`),
3471   KEY `timestamp` (`timestamp`),
3472   CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3473   CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
3474   CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE,
3475   CONSTRAINT `items_ibfk_4` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
3476 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3477 /*!40101 SET character_set_client = @saved_cs_client */;
3478
3479 --
3480 -- Table structure for table item_bundles
3481 --
3482
3483 DROP TABLE IF EXISTS `item_bundles`;
3484 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3485 /*!40101 SET character_set_client = utf8 */;
3486 CREATE TABLE `item_bundles` (
3487   `item` int(11) NOT NULL,
3488   `host` int(11) NOT NULL,
3489   PRIMARY KEY (`host`, `item`),
3490   UNIQUE KEY `item_bundles_uniq_1` (`item`),
3491   CONSTRAINT `item_bundles_ibfk_1` FOREIGN KEY (`item`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3492   CONSTRAINT `item_bundles_ibfk_2` FOREIGN KEY (`host`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
3493 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3494 /*!40101 SET character_set_client = @saved_cs_client */;
3495
3496 --
3497 -- Table structure for table `items_last_borrower`
3498 --
3499
3500 DROP TABLE IF EXISTS `items_last_borrower`;
3501 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3502 /*!40101 SET character_set_client = utf8 */;
3503 CREATE TABLE `items_last_borrower` (
3504   `id` int(11) NOT NULL AUTO_INCREMENT,
3505   `itemnumber` int(11) NOT NULL,
3506   `borrowernumber` int(11) NOT NULL,
3507   `created_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
3508   PRIMARY KEY (`id`),
3509   UNIQUE KEY `itemnumber` (`itemnumber`),
3510   KEY `borrowernumber` (`borrowernumber`),
3511   CONSTRAINT `items_last_borrower_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3512   CONSTRAINT `items_last_borrower_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
3513 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3514 /*!40101 SET character_set_client = @saved_cs_client */;
3515
3516 --
3517 -- Table structure for table `items_search_fields`
3518 --
3519
3520 DROP TABLE IF EXISTS `items_search_fields`;
3521 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3522 /*!40101 SET character_set_client = utf8 */;
3523 CREATE TABLE `items_search_fields` (
3524   `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
3525   `label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
3526   `tagfield` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
3527   `tagsubfield` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3528   `authorised_values_category` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3529   PRIMARY KEY (`name`(191)),
3530   KEY `items_search_fields_authorised_values_category` (`authorised_values_category`),
3531   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
3532 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3533 /*!40101 SET character_set_client = @saved_cs_client */;
3534
3535 --
3536 -- Table structure for table `itemtypes`
3537 --
3538
3539 DROP TABLE IF EXISTS `itemtypes`;
3540 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3541 /*!40101 SET character_set_client = utf8 */;
3542 CREATE TABLE `itemtypes` (
3543   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'unique key, a code associated with the item type',
3544   `parent_type` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, a code associated with the item type',
3545   `description` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'a plain text explanation of the item type',
3546   `rentalcharge` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged when this item is checked out/issued',
3547   `rentalcharge_daily` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each day between checkout date and due date',
3548   `rentalcharge_daily_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the daily rental fee is calculated directly or using finesCalendar',
3549   `rentalcharge_hourly` decimal(28,6) DEFAULT NULL COMMENT 'the amount charged for each hour between checkout date and due date',
3550   `rentalcharge_hourly_calendar` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'controls if the hourly rental fee is calculated directly or using finesCalendar',
3551   `defaultreplacecost` decimal(28,6) DEFAULT NULL COMMENT 'default replacement cost',
3552   `processfee` decimal(28,6) DEFAULT NULL COMMENT 'default text be recorded in the column note when the processing fee is applied',
3553   `notforloan` smallint(6) DEFAULT NULL COMMENT '1 if the item is not for loan, 0 if the item is available for loan',
3554   `imageurl` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'URL for the item type icon',
3555   `summary` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'information from the summary field, may include HTML',
3556   `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',
3557   `checkinmsgtype` char(16) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'message' COMMENT 'type (CSS class) for the checkinmsg, can be ''alert'' or ''message''',
3558   `sip_media_type` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'SIP2 protocol media type for this itemtype',
3559   `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
3560   `searchcategory` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
3561   `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
3562   PRIMARY KEY (`itemtype`),
3563   UNIQUE KEY `itemtype` (`itemtype`),
3564   KEY `itemtypes_ibfk_1` (`parent_type`),
3565   CONSTRAINT `itemtypes_ibfk_1` FOREIGN KEY (`parent_type`) REFERENCES `itemtypes` (`itemtype`)
3566 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3567 /*!40101 SET character_set_client = @saved_cs_client */;
3568
3569 --
3570 -- Table structure for table `itemtypes_branches`
3571 --
3572
3573 DROP TABLE IF EXISTS `itemtypes_branches`;
3574 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3575 /*!40101 SET character_set_client = utf8 */;
3576 CREATE TABLE `itemtypes_branches` (
3577   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
3578   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
3579   KEY `itemtype` (`itemtype`),
3580   KEY `branchcode` (`branchcode`),
3581   CONSTRAINT `itemtypes_branches_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE,
3582   CONSTRAINT `itemtypes_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
3583 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3584 /*!40101 SET character_set_client = @saved_cs_client */;
3585
3586 --
3587 -- Table structure for table `keyboard_shortcuts`
3588 --
3589
3590 DROP TABLE IF EXISTS `keyboard_shortcuts`;
3591 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3592 /*!40101 SET character_set_client = utf8 */;
3593 CREATE TABLE `keyboard_shortcuts` (
3594   `shortcut_name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
3595   `shortcut_keys` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
3596   PRIMARY KEY (`shortcut_name`)
3597 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3598 /*!40101 SET character_set_client = @saved_cs_client */;
3599
3600 --
3601 -- Table structure for table `language_descriptions`
3602 --
3603
3604 DROP TABLE IF EXISTS `language_descriptions`;
3605 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3606 /*!40101 SET character_set_client = utf8 */;
3607 CREATE TABLE `language_descriptions` (
3608   `subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3609   `type` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3610   `lang` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3611   `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3612   `id` int(11) NOT NULL AUTO_INCREMENT,
3613   PRIMARY KEY (`id`),
3614   UNIQUE KEY `uniq_desc` (`subtag`,`type`,`lang`),
3615   KEY `lang` (`lang`)
3616 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3617 /*!40101 SET character_set_client = @saved_cs_client */;
3618
3619 --
3620 -- Table structure for table `language_rfc4646_to_iso639`
3621 --
3622
3623 DROP TABLE IF EXISTS `language_rfc4646_to_iso639`;
3624 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3625 /*!40101 SET character_set_client = utf8 */;
3626 CREATE TABLE `language_rfc4646_to_iso639` (
3627   `rfc4646_subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3628   `iso639_2_code` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3629   `id` int(11) NOT NULL AUTO_INCREMENT,
3630   PRIMARY KEY (`id`),
3631   UNIQUE KEY `uniq_code` (`rfc4646_subtag`,`iso639_2_code`),
3632   KEY `rfc4646_subtag` (`rfc4646_subtag`)
3633 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3634 /*!40101 SET character_set_client = @saved_cs_client */;
3635
3636 --
3637 -- Table structure for table `language_script_bidi`
3638 --
3639
3640 DROP TABLE IF EXISTS `language_script_bidi`;
3641 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3642 /*!40101 SET character_set_client = utf8 */;
3643 CREATE TABLE `language_script_bidi` (
3644   `rfc4646_subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'script subtag, Arab, Hebr, etc.',
3645   `bidi` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'rtl ltr',
3646   KEY `rfc4646_subtag` (`rfc4646_subtag`)
3647 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3648 /*!40101 SET character_set_client = @saved_cs_client */;
3649
3650 --
3651 -- Table structure for table `language_script_mapping`
3652 --
3653
3654 DROP TABLE IF EXISTS `language_script_mapping`;
3655 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3656 /*!40101 SET character_set_client = utf8 */;
3657 CREATE TABLE `language_script_mapping` (
3658   `language_subtag` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL,
3659   `script_subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3660   PRIMARY KEY (`language_subtag`)
3661 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3662 /*!40101 SET character_set_client = @saved_cs_client */;
3663
3664 --
3665 -- Table structure for table `language_subtag_registry`
3666 --
3667
3668 DROP TABLE IF EXISTS `language_subtag_registry`;
3669 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3670 /*!40101 SET character_set_client = utf8 */;
3671 CREATE TABLE `language_subtag_registry` (
3672   `subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3673   `type` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'language-script-region-variant-extension-privateuse',
3674   `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',
3675   `added` date DEFAULT NULL,
3676   `id` int(11) NOT NULL AUTO_INCREMENT,
3677   PRIMARY KEY (`id`),
3678   UNIQUE KEY `uniq_lang` (`subtag`,`type`),
3679   KEY `subtag` (`subtag`)
3680 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3681 /*!40101 SET character_set_client = @saved_cs_client */;
3682
3683 --
3684 -- Table structure for table `letter`
3685 --
3686
3687 DROP TABLE IF EXISTS `letter`;
3688 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3689 /*!40101 SET character_set_client = utf8 */;
3690 CREATE TABLE `letter` (
3691   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
3692   `module` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'Koha module that triggers this notice or slip',
3693   `code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'unique identifier for this notice or slip',
3694   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'the branch this notice or slip is used at (branches.branchcode)',
3695   `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'plain text name for this notice or slip',
3696   `is_html` tinyint(1) DEFAULT 0 COMMENT 'does this notice or slip use HTML (1 for yes, 0 for no)',
3697   `title` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'subject line of the notice',
3698   `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'body text for the notice or slip',
3699   `message_transport_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice',
3700   `lang` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'default' COMMENT 'lang of the notice',
3701   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
3702   PRIMARY KEY (`id`),
3703   UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`),
3704   KEY `message_transport_type_fk` (`message_transport_type`),
3705   CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
3706 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3707 /*!40101 SET character_set_client = @saved_cs_client */;
3708
3709 --
3710 -- Table structure for table `library_groups`
3711 --
3712
3713 DROP TABLE IF EXISTS `library_groups`;
3714 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3715 /*!40101 SET character_set_client = utf8 */;
3716 CREATE TABLE `library_groups` (
3717   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for each group',
3718   `parent_id` int(11) DEFAULT NULL COMMENT 'if this is a child group, the id of the parent group',
3719   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'The branchcode of a branch belonging to the parent group',
3720   `title` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Short description of the goup',
3721   `description` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Longer explanation of the group, if necessary',
3722   `ft_hide_patron_info` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Turn on the feature ''Hide patron''s info'' for this group',
3723   `ft_search_groups_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group for staff side search groups',
3724   `ft_search_groups_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group for opac side search groups',
3725   `ft_local_hold_group` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group to identify libraries as pick up location for holds',
3726   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Date and time of creation',
3727   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Date and time of last',
3728   PRIMARY KEY (`id`),
3729   UNIQUE KEY `title` (`title`),
3730   UNIQUE KEY `library_groups_uniq_2` (`parent_id`,`branchcode`),
3731   KEY `branchcode` (`branchcode`),
3732   CONSTRAINT `library_groups_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `library_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
3733   CONSTRAINT `library_groups_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3734 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3735 /*!40101 SET character_set_client = @saved_cs_client */;
3736
3737 --
3738 -- Table structure for table `library_smtp_servers`
3739 --
3740
3741 DROP TABLE IF EXISTS `library_smtp_servers`;
3742 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3743 /*!40101 SET character_set_client = utf8 */;
3744 CREATE TABLE `library_smtp_servers` (
3745   `id` int(11) NOT NULL AUTO_INCREMENT,
3746   `library_id` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
3747   `smtp_server_id` int(11) NOT NULL,
3748   PRIMARY KEY (`id`),
3749   UNIQUE KEY `library_id_idx` (`library_id`),
3750   KEY `smtp_server_id_idx` (`smtp_server_id`),
3751   CONSTRAINT `library_smtp_servers_library_fk` FOREIGN KEY (`library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3752   CONSTRAINT `library_smtp_servers_smtp_servers_fk` FOREIGN KEY (`smtp_server_id`) REFERENCES `smtp_servers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3753 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3754 /*!40101 SET character_set_client = @saved_cs_client */;
3755
3756 --
3757 -- Table structure for table `linktracker`
3758 --
3759
3760 DROP TABLE IF EXISTS `linktracker`;
3761 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3762 /*!40101 SET character_set_client = utf8 */;
3763 CREATE TABLE `linktracker` (
3764   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
3765   `biblionumber` int(11) DEFAULT NULL COMMENT 'biblionumber of the record the link is from',
3766   `itemnumber` int(11) DEFAULT NULL COMMENT 'itemnumber if applicable that the link was from',
3767   `borrowernumber` int(11) DEFAULT NULL COMMENT 'borrowernumber who clicked the link',
3768   `url` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the link itself',
3769   `timeclicked` datetime DEFAULT NULL COMMENT 'the date and time the link was clicked',
3770   PRIMARY KEY (`id`),
3771   KEY `bibidx` (`biblionumber`),
3772   KEY `itemidx` (`itemnumber`),
3773   KEY `borridx` (`borrowernumber`),
3774   KEY `dateidx` (`timeclicked`),
3775   CONSTRAINT `linktracker_biblio_ibfk` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL,
3776   CONSTRAINT `linktracker_borrower_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
3777   CONSTRAINT `linktracker_item_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
3778 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3779 /*!40101 SET character_set_client = @saved_cs_client */;
3780
3781 --
3782 -- Table structure for table `localization`
3783 --
3784
3785 DROP TABLE IF EXISTS `localization`;
3786 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3787 /*!40101 SET character_set_client = utf8 */;
3788 CREATE TABLE `localization` (
3789   `localization_id` int(11) NOT NULL AUTO_INCREMENT,
3790   `entity` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
3791   `code` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
3792   `lang` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'could be a foreign key',
3793   `translation` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3794   PRIMARY KEY (`localization_id`),
3795   UNIQUE KEY `entity_code_lang` (`entity`,`code`,`lang`)
3796 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3797 /*!40101 SET character_set_client = @saved_cs_client */;
3798
3799 --
3800 -- Table structure for table `marc_matchers`
3801 --
3802
3803 DROP TABLE IF EXISTS `marc_matchers`;
3804 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3805 /*!40101 SET character_set_client = utf8 */;
3806 CREATE TABLE `marc_matchers` (
3807   `matcher_id` int(11) NOT NULL AUTO_INCREMENT,
3808   `code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3809   `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3810   `record_type` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'biblio',
3811   `threshold` int(11) NOT NULL DEFAULT 0,
3812   PRIMARY KEY (`matcher_id`),
3813   KEY `code` (`code`),
3814   KEY `record_type` (`record_type`)
3815 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3816 /*!40101 SET character_set_client = @saved_cs_client */;
3817
3818 --
3819 -- Table structure for table `marc_modification_template_actions`
3820 --
3821
3822 DROP TABLE IF EXISTS `marc_modification_template_actions`;
3823 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3824 /*!40101 SET character_set_client = utf8 */;
3825 CREATE TABLE `marc_modification_template_actions` (
3826   `mmta_id` int(11) NOT NULL AUTO_INCREMENT,
3827   `template_id` int(11) NOT NULL,
3828   `ordering` int(3) NOT NULL,
3829   `action` enum('delete_field','add_field','update_field','move_field','copy_field','copy_and_replace_field') COLLATE utf8mb4_unicode_ci NOT NULL,
3830   `field_number` smallint(6) NOT NULL DEFAULT 0,
3831   `from_field` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL,
3832   `from_subfield` varchar(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3833   `field_value` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3834   `to_field` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3835   `to_subfield` varchar(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3836   `to_regex_search` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3837   `to_regex_replace` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3838   `to_regex_modifiers` varchar(8) COLLATE utf8mb4_unicode_ci DEFAULT '',
3839   `conditional` enum('if','unless') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3840   `conditional_field` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3841   `conditional_subfield` varchar(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3842   `conditional_comparison` enum('exists','not_exists','equals','not_equals') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3843   `conditional_value` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3844   `conditional_regex` tinyint(1) NOT NULL DEFAULT 0,
3845   `description` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3846   PRIMARY KEY (`mmta_id`),
3847   KEY `mmta_ibfk_1` (`template_id`),
3848   CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
3849 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3850 /*!40101 SET character_set_client = @saved_cs_client */;
3851
3852 --
3853 -- Table structure for table `marc_modification_templates`
3854 --
3855
3856 DROP TABLE IF EXISTS `marc_modification_templates`;
3857 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3858 /*!40101 SET character_set_client = utf8 */;
3859 CREATE TABLE `marc_modification_templates` (
3860   `template_id` int(11) NOT NULL AUTO_INCREMENT,
3861   `name` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
3862   PRIMARY KEY (`template_id`)
3863 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3864 /*!40101 SET character_set_client = @saved_cs_client */;
3865
3866 --
3867 -- Table structure for table `marc_overlay_rules`
3868 --
3869
3870 DROP TABLE IF EXISTS `marc_overlay_rules`;
3871 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3872 /*!40101 SET character_set_client = utf8 */;
3873 CREATE TABLE `marc_overlay_rules` (
3874   `id` int(11) NOT NULL AUTO_INCREMENT,
3875   `tag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
3876   `module` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL,
3877   `filter` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
3878   `add` tinyint(1) NOT NULL DEFAULT 0,
3879   `append` tinyint(1) NOT NULL DEFAULT 0,
3880   `remove` tinyint(1) NOT NULL DEFAULT 0,
3881   `delete` tinyint(1) NOT NULL DEFAULT 0,
3882   PRIMARY KEY (`id`)
3883 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3884 /*!40101 SET character_set_client = @saved_cs_client */;
3885
3886 --
3887 -- Table structure for table `marc_subfield_structure`
3888 --
3889
3890 DROP TABLE IF EXISTS `marc_subfield_structure`;
3891 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3892 /*!40101 SET character_set_client = utf8 */;
3893 CREATE TABLE `marc_subfield_structure` (
3894   `tagfield` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3895   `tagsubfield` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
3896   `liblibrarian` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3897   `libopac` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3898   `repeatable` tinyint(4) NOT NULL DEFAULT 0,
3899   `mandatory` tinyint(4) NOT NULL DEFAULT 0,
3900   `important` tinyint(4) NOT NULL DEFAULT 0,
3901   `kohafield` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3902   `tab` tinyint(1) DEFAULT NULL,
3903   `authorised_value` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3904   `authtypecode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3905   `value_builder` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3906   `isurl` tinyint(1) DEFAULT NULL,
3907   `hidden` tinyint(1) NOT NULL DEFAULT 8,
3908   `frameworkcode` varchar(4) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3909   `seealso` varchar(1100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3910   `link` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3911   `defaultvalue` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3912   `maxlength` int(4) NOT NULL DEFAULT 9999,
3913   `display_order` int(2) NOT NULL DEFAULT 0,
3914   PRIMARY KEY (`frameworkcode`,`tagfield`,`tagsubfield`),
3915   KEY `kohafield_2` (`kohafield`),
3916   KEY `tab` (`frameworkcode`,`tab`),
3917   KEY `kohafield` (`frameworkcode`,`kohafield`),
3918   KEY `marc_subfield_structure_ibfk_1` (`authorised_value`),
3919   CONSTRAINT `marc_subfield_structure_ibfk_1` FOREIGN KEY (`authorised_value`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE
3920 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3921 /*!40101 SET character_set_client = @saved_cs_client */;
3922
3923 --
3924 -- Table structure for table `marc_tag_structure`
3925 --
3926
3927 DROP TABLE IF EXISTS `marc_tag_structure`;
3928 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3929 /*!40101 SET character_set_client = utf8 */;
3930 CREATE TABLE `marc_tag_structure` (
3931   `tagfield` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3932   `liblibrarian` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3933   `libopac` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3934   `repeatable` tinyint(4) NOT NULL DEFAULT 0,
3935   `mandatory` tinyint(4) NOT NULL DEFAULT 0,
3936   `important` tinyint(4) NOT NULL DEFAULT 0,
3937   `authorised_value` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3938   `ind1_defaultvalue` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3939   `ind2_defaultvalue` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3940   `frameworkcode` varchar(4) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3941   PRIMARY KEY (`frameworkcode`,`tagfield`)
3942 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3943 /*!40101 SET character_set_client = @saved_cs_client */;
3944
3945 --
3946 -- Table structure for table `matchchecks`
3947 --
3948
3949 DROP TABLE IF EXISTS `matchchecks`;
3950 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3951 /*!40101 SET character_set_client = utf8 */;
3952 CREATE TABLE `matchchecks` (
3953   `matcher_id` int(11) NOT NULL,
3954   `matchcheck_id` int(11) NOT NULL AUTO_INCREMENT,
3955   `source_matchpoint_id` int(11) NOT NULL,
3956   `target_matchpoint_id` int(11) NOT NULL,
3957   PRIMARY KEY (`matchcheck_id`),
3958   KEY `matcher_matchchecks_ifbk_1` (`matcher_id`),
3959   KEY `matcher_matchchecks_ifbk_2` (`source_matchpoint_id`),
3960   KEY `matcher_matchchecks_ifbk_3` (`target_matchpoint_id`),
3961   CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`) REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3962   CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3963   CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
3964 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3965 /*!40101 SET character_set_client = @saved_cs_client */;
3966
3967 --
3968 -- Table structure for table `matcher_matchpoints`
3969 --
3970
3971 DROP TABLE IF EXISTS `matcher_matchpoints`;
3972 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3973 /*!40101 SET character_set_client = utf8 */;
3974 CREATE TABLE `matcher_matchpoints` (
3975   `matcher_id` int(11) NOT NULL,
3976   `matchpoint_id` int(11) NOT NULL,
3977   KEY `matcher_matchpoints_ifbk_1` (`matcher_id`),
3978   KEY `matcher_matchpoints_ifbk_2` (`matchpoint_id`),
3979   CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`) REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
3980   CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
3981 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3982 /*!40101 SET character_set_client = @saved_cs_client */;
3983
3984 --
3985 -- Table structure for table `matchpoint_component_norms`
3986 --
3987
3988 DROP TABLE IF EXISTS `matchpoint_component_norms`;
3989 /*!40101 SET @saved_cs_client     = @@character_set_client */;
3990 /*!40101 SET character_set_client = utf8 */;
3991 CREATE TABLE `matchpoint_component_norms` (
3992   `matchpoint_component_id` int(11) NOT NULL,
3993   `sequence` int(11) NOT NULL DEFAULT 0,
3994   `norm_routine` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
3995   KEY `matchpoint_component_norms` (`matchpoint_component_id`,`sequence`),
3996   CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`) REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
3997 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3998 /*!40101 SET character_set_client = @saved_cs_client */;
3999
4000 --
4001 -- Table structure for table `matchpoint_components`
4002 --
4003
4004 DROP TABLE IF EXISTS `matchpoint_components`;
4005 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4006 /*!40101 SET character_set_client = utf8 */;
4007 CREATE TABLE `matchpoint_components` (
4008   `matchpoint_id` int(11) NOT NULL,
4009   `matchpoint_component_id` int(11) NOT NULL AUTO_INCREMENT,
4010   `sequence` int(11) NOT NULL DEFAULT 0,
4011   `tag` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4012   `subfields` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4013   `offset` int(4) NOT NULL DEFAULT 0,
4014   `length` int(4) NOT NULL DEFAULT 0,
4015   PRIMARY KEY (`matchpoint_component_id`),
4016   KEY `by_sequence` (`matchpoint_id`,`sequence`),
4017   CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`) REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
4018 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4019 /*!40101 SET character_set_client = @saved_cs_client */;
4020
4021 --
4022 -- Table structure for table `matchpoints`
4023 --
4024
4025 DROP TABLE IF EXISTS `matchpoints`;
4026 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4027 /*!40101 SET character_set_client = utf8 */;
4028 CREATE TABLE `matchpoints` (
4029   `matcher_id` int(11) NOT NULL,
4030   `matchpoint_id` int(11) NOT NULL AUTO_INCREMENT,
4031   `search_index` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4032   `score` int(11) NOT NULL DEFAULT 0,
4033   PRIMARY KEY (`matchpoint_id`),
4034   KEY `matchpoints_ifbk_1` (`matcher_id`),
4035   CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`) REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
4036 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4037 /*!40101 SET character_set_client = @saved_cs_client */;
4038
4039 --
4040 -- Table structure for table `message_attributes`
4041 --
4042
4043 DROP TABLE IF EXISTS `message_attributes`;
4044 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4045 /*!40101 SET character_set_client = utf8 */;
4046 CREATE TABLE `message_attributes` (
4047   `message_attribute_id` int(11) NOT NULL AUTO_INCREMENT,
4048   `message_name` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4049   `takes_days` tinyint(1) NOT NULL DEFAULT 0,
4050   PRIMARY KEY (`message_attribute_id`),
4051   UNIQUE KEY `message_name` (`message_name`)
4052 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4053 /*!40101 SET character_set_client = @saved_cs_client */;
4054
4055 --
4056 -- Table structure for table `message_queue`
4057 --
4058
4059 DROP TABLE IF EXISTS `message_queue`;
4060 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4061 /*!40101 SET character_set_client = utf8 */;
4062 CREATE TABLE `message_queue` (
4063   `message_id` int(11) NOT NULL AUTO_INCREMENT,
4064   `letter_id` int(11) DEFAULT NULL COMMENT 'Foreign key to the letters table',
4065   `borrowernumber` int(11) DEFAULT NULL,
4066   `subject` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4067   `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4068   `metadata` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4069   `letter_code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4070   `message_transport_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
4071   `status` enum('sent','pending','failed','deleted') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
4072   `time_queued` timestamp NULL DEFAULT NULL,
4073   `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
4074   `to_address` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4075   `from_address` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4076   `reply_address` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4077   `content_type` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4078   `failure_code` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4079   PRIMARY KEY (`message_id`),
4080   KEY `borrowernumber` (`borrowernumber`),
4081   KEY `message_transport_type` (`message_transport_type`),
4082   CONSTRAINT `letter_fk` FOREIGN KEY (`letter_id`) REFERENCES `letter` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
4083   CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4084   CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON UPDATE CASCADE
4085 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4086 /*!40101 SET character_set_client = @saved_cs_client */;
4087
4088 --
4089 -- Table structure for table `message_transport_types`
4090 --
4091
4092 DROP TABLE IF EXISTS `message_transport_types`;
4093 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4094 /*!40101 SET character_set_client = utf8 */;
4095 CREATE TABLE `message_transport_types` (
4096   `message_transport_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
4097   PRIMARY KEY (`message_transport_type`)
4098 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4099 /*!40101 SET character_set_client = @saved_cs_client */;
4100
4101 --
4102 -- Table structure for table `message_transports`
4103 --
4104
4105 DROP TABLE IF EXISTS `message_transports`;
4106 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4107 /*!40101 SET character_set_client = utf8 */;
4108 CREATE TABLE `message_transports` (
4109   `message_attribute_id` int(11) NOT NULL,
4110   `message_transport_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
4111   `is_digest` tinyint(1) NOT NULL DEFAULT 0,
4112   `letter_module` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4113   `letter_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4114   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4115   PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
4116   KEY `message_transport_type` (`message_transport_type`),
4117   KEY `letter_module` (`letter_module`,`letter_code`),
4118   CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4119   CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
4120 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4121 /*!40101 SET character_set_client = @saved_cs_client */;
4122
4123 --
4124 -- Table structure for table `messages`
4125 --
4126
4127 DROP TABLE IF EXISTS `messages`;
4128 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4129 /*!40101 SET character_set_client = utf8 */;
4130 CREATE TABLE `messages` (
4131   `message_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4132   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key linking this message to the borrowers table',
4133   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key linking the message to the branches table',
4134   `message_type` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'whether the message is for the librarians (L) or the patron (B)',
4135   `message` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the text of the message',
4136   `message_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the message was written',
4137   `manager_id` int(11) DEFAULT NULL COMMENT 'creator of message',
4138   PRIMARY KEY (`message_id`),
4139   KEY `messages_ibfk_1` (`manager_id`),
4140   KEY `messages_borrowernumber` (`borrowernumber`),
4141   CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4142   CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL
4143 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4144 /*!40101 SET character_set_client = @saved_cs_client */;
4145
4146 --
4147 -- Table structure for table `misc_files`
4148 --
4149
4150 DROP TABLE IF EXISTS `misc_files`;
4151 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4152 /*!40101 SET character_set_client = utf8 */;
4153 CREATE TABLE `misc_files` (
4154   `file_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the file record',
4155   `table_tag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'usually table name, or arbitrary unique tag',
4156   `record_id` int(11) NOT NULL COMMENT 'record id from the table this file is associated to',
4157   `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'file name',
4158   `file_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'MIME type of the file',
4159   `file_description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'description given to the file',
4160   `file_content` longblob NOT NULL COMMENT 'file content',
4161   `date_uploaded` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the file was added',
4162   PRIMARY KEY (`file_id`),
4163   KEY `table_tag` (`table_tag`(191)),
4164   KEY `record_id` (`record_id`)
4165 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4166 /*!40101 SET character_set_client = @saved_cs_client */;
4167
4168 --
4169 -- Table structure for table `need_merge_authorities`
4170 --
4171
4172 DROP TABLE IF EXISTS `need_merge_authorities`;
4173 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4174 /*!40101 SET character_set_client = utf8 */;
4175 CREATE TABLE `need_merge_authorities` (
4176   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id',
4177   `authid` bigint(20) NOT NULL COMMENT 'reference to original authority record',
4178   `authid_new` bigint(20) DEFAULT NULL COMMENT 'reference to optional new authority record',
4179   `reportxml` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'xml showing original reporting tag',
4180   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time last modified',
4181   `done` tinyint(4) DEFAULT 0,
4182   PRIMARY KEY (`id`)
4183 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4184 /*!40101 SET character_set_client = @saved_cs_client */;
4185
4186 --
4187 -- Table structure for table `oai_sets`
4188 --
4189
4190 DROP TABLE IF EXISTS `oai_sets`;
4191 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4192 /*!40101 SET character_set_client = utf8 */;
4193 CREATE TABLE `oai_sets` (
4194   `id` int(11) NOT NULL AUTO_INCREMENT,
4195   `spec` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
4196   `name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
4197   PRIMARY KEY (`id`),
4198   UNIQUE KEY `spec` (`spec`)
4199 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4200 /*!40101 SET character_set_client = @saved_cs_client */;
4201
4202 --
4203 -- Table structure for table `oai_sets_biblios`
4204 --
4205
4206 DROP TABLE IF EXISTS `oai_sets_biblios`;
4207 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4208 /*!40101 SET character_set_client = utf8 */;
4209 CREATE TABLE `oai_sets_biblios` (
4210   `biblionumber` int(11) NOT NULL,
4211   `set_id` int(11) NOT NULL,
4212   PRIMARY KEY (`biblionumber`,`set_id`),
4213   KEY `oai_sets_biblios_ibfk_2` (`set_id`),
4214   CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4215 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4216 /*!40101 SET character_set_client = @saved_cs_client */;
4217
4218 --
4219 -- Table structure for table `oai_sets_descriptions`
4220 --
4221
4222 DROP TABLE IF EXISTS `oai_sets_descriptions`;
4223 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4224 /*!40101 SET character_set_client = utf8 */;
4225 CREATE TABLE `oai_sets_descriptions` (
4226   `set_id` int(11) NOT NULL,
4227   `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
4228   KEY `oai_sets_descriptions_ibfk_1` (`set_id`),
4229   CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4230 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4231 /*!40101 SET character_set_client = @saved_cs_client */;
4232
4233 --
4234 -- Table structure for table `oai_sets_mappings`
4235 --
4236
4237 DROP TABLE IF EXISTS `oai_sets_mappings`;
4238 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4239 /*!40101 SET character_set_client = utf8 */;
4240 CREATE TABLE `oai_sets_mappings` (
4241   `set_id` int(11) NOT NULL,
4242   `rule_order` int(11) DEFAULT NULL,
4243   `rule_operator` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4244   `marcfield` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
4245   `marcsubfield` char(1) COLLATE utf8mb4_unicode_ci NOT NULL,
4246   `operator` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'equal',
4247   `marcvalue` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
4248   KEY `oai_sets_mappings_ibfk_1` (`set_id`),
4249   CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4250 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4251 /*!40101 SET character_set_client = @saved_cs_client */;
4252
4253 --
4254 -- Table structure for table `oauth_access_tokens`
4255 --
4256
4257 DROP TABLE IF EXISTS `oauth_access_tokens`;
4258 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4259 /*!40101 SET character_set_client = utf8 */;
4260 CREATE TABLE `oauth_access_tokens` (
4261   `access_token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'generarated access token',
4262   `client_id` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the client id the access token belongs to',
4263   `expires` int(11) NOT NULL COMMENT 'expiration time in seconds',
4264   PRIMARY KEY (`access_token`)
4265 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4266 /*!40101 SET character_set_client = @saved_cs_client */;
4267
4268 --
4269 -- Table structure for table `old_issues`
4270 --
4271
4272 DROP TABLE IF EXISTS `old_issues`;
4273 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4274 /*!40101 SET character_set_client = utf8 */;
4275 CREATE TABLE `old_issues` (
4276   `issue_id` int(11) NOT NULL COMMENT 'primary key for issues table',
4277   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
4278   `issuer_id` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the user who checked out this item',
4279   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out',
4280   `date_due` datetime DEFAULT NULL COMMENT 'date the item is due (yyyy-mm-dd)',
4281   `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',
4282   `returndate` datetime DEFAULT NULL COMMENT 'date the item was returned',
4283   `lastreneweddate` datetime DEFAULT NULL COMMENT 'date the item was last renewed',
4284   `renewals_count` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of times the item was renewed',
4285   `unseen_renewals` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'lists the number of consecutive times the item was renewed without being seen',
4286   `auto_renew` tinyint(1) DEFAULT 0 COMMENT 'automatic renewal',
4287   `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'automatic renewal error',
4288   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this record was last touched',
4289   `issuedate` datetime DEFAULT NULL COMMENT 'date the item was checked out or issued',
4290   `onsite_checkout` int(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag',
4291   `note` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'issue note text',
4292   `notedate` datetime DEFAULT NULL COMMENT 'datetime of issue note (yyyy-mm-dd hh:mm::ss)',
4293   `noteseen` int(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null',
4294   PRIMARY KEY (`issue_id`),
4295   KEY `old_issuesborridx` (`borrowernumber`),
4296   KEY `old_issuesitemidx` (`itemnumber`),
4297   KEY `branchcode_idx` (`branchcode`),
4298   KEY `old_bordate` (`borrowernumber`,`timestamp`),
4299   KEY `old_issues_ibfk_borrowers_borrowernumber` (`issuer_id`),
4300   CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4301   CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4302   CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
4303 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4304 /*!40101 SET character_set_client = @saved_cs_client */;
4305
4306 --
4307 -- Table structure for table `old_reserves`
4308 --
4309
4310 DROP TABLE IF EXISTS `old_reserves`;
4311 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4312 /*!40101 SET character_set_client = utf8 */;
4313 CREATE TABLE `old_reserves` (
4314   `reserve_id` int(11) NOT NULL COMMENT 'primary key',
4315   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
4316   `reservedate` date DEFAULT NULL COMMENT 'the date the hold was places',
4317   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key from the biblio table defining which bib record this hold is on',
4318   `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',
4319   `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',
4320   `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
4321   `notificationdate` date DEFAULT NULL COMMENT 'currently unused',
4322   `reminderdate` date DEFAULT NULL COMMENT 'currently unused',
4323   `cancellationdate` date DEFAULT NULL COMMENT 'the date this hold was cancelled',
4324   `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
4325   `reservenotes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'notes related to this hold',
4326   `priority` smallint(6) NOT NULL DEFAULT 1 COMMENT 'where in the queue the patron sits',
4327   `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',
4328   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this hold was last updated',
4329   `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',
4330   `waitingdate` date DEFAULT NULL COMMENT 'the date the item was marked as waiting for the patron at the library',
4331   `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)',
4332   `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',
4333   `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)',
4334   `suspend` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'in this hold suspended (1 for yes, 0 for no)',
4335   `suspend_until` datetime DEFAULT NULL COMMENT 'the date this hold is suspended until (NULL for infinitely)',
4336   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'If record level hold, the optional itemtype of the item the patron is requesting',
4337   `item_level_hold` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is the hpld placed at item level',
4338   `non_priority` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is this a non priority hold',
4339   PRIMARY KEY (`reserve_id`),
4340   KEY `old_reserves_borrowernumber` (`borrowernumber`),
4341   KEY `old_reserves_biblionumber` (`biblionumber`),
4342   KEY `old_reserves_itemnumber` (`itemnumber`),
4343   KEY `old_reserves_branchcode` (`branchcode`),
4344   KEY `old_reserves_itemtype` (`itemtype`),
4345   CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL,
4346   CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4347   CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4348   CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
4349   CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE SET NULL ON UPDATE SET NULL
4350 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4351 /*!40101 SET character_set_client = @saved_cs_client */;
4352
4353 --
4354 -- Table structure for table `overduerules`
4355 --
4356
4357 DROP TABLE IF EXISTS `overduerules`;
4358 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4359 /*!40101 SET character_set_client = utf8 */;
4360 CREATE TABLE `overduerules` (
4361   `overduerules_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the overduerules',
4362   `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)',
4363   `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',
4364   `delay1` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the first notice is sent',
4365   `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',
4366   `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)',
4367   `delay2` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the second notice is sent',
4368   `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)',
4369   `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',
4370   `delay3` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the third notice is sent',
4371   `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',
4372   `debarred3` int(1) DEFAULT 0 COMMENT 'is the patron restricted when the third notice is sent (1 for yes, 0 for no)',
4373   PRIMARY KEY (`overduerules_id`),
4374   UNIQUE KEY `overduerules_branch_cat` (`branchcode`,`categorycode`)
4375 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4376 /*!40101 SET character_set_client = @saved_cs_client */;
4377
4378 --
4379 -- Table structure for table `overduerules_transport_types`
4380 --
4381
4382 DROP TABLE IF EXISTS `overduerules_transport_types`;
4383 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4384 /*!40101 SET character_set_client = utf8 */;
4385 CREATE TABLE `overduerules_transport_types` (
4386   `id` int(11) NOT NULL AUTO_INCREMENT,
4387   `letternumber` int(1) NOT NULL DEFAULT 1,
4388   `message_transport_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'email',
4389   `overduerules_id` int(11) NOT NULL,
4390   PRIMARY KEY (`id`),
4391   KEY `overduerules_fk` (`overduerules_id`),
4392   KEY `mtt_fk` (`message_transport_type`),
4393   CONSTRAINT `mtt_fk` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
4394   CONSTRAINT `overduerules_fk` FOREIGN KEY (`overduerules_id`) REFERENCES `overduerules` (`overduerules_id`) ON DELETE CASCADE ON UPDATE CASCADE
4395 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4396 /*!40101 SET character_set_client = @saved_cs_client */;
4397
4398 --
4399 -- Table structure for table `patron_consent`
4400 --
4401
4402 DROP TABLE IF EXISTS `patron_consent`;
4403 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4404 /*!40101 SET character_set_client = utf8 */;
4405 CREATE TABLE `patron_consent` (
4406   `id` int(11) NOT NULL AUTO_INCREMENT,
4407   `borrowernumber` int(11) NOT NULL,
4408   `type` enum('GDPR_PROCESSING') COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'allows for future extension',
4409   `given_on` datetime DEFAULT NULL,
4410   `refused_on` datetime DEFAULT NULL,
4411   PRIMARY KEY (`id`),
4412   KEY `borrowernumber` (`borrowernumber`),
4413   CONSTRAINT `patron_consent_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4414 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4415 /*!40101 SET character_set_client = @saved_cs_client */;
4416
4417 --
4418 -- Table structure for table `patron_list_patrons`
4419 --
4420
4421 DROP TABLE IF EXISTS `patron_list_patrons`;
4422 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4423 /*!40101 SET character_set_client = utf8 */;
4424 CREATE TABLE `patron_list_patrons` (
4425   `patron_list_patron_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
4426   `patron_list_id` int(11) NOT NULL COMMENT 'the list this entry is part of',
4427   `borrowernumber` int(11) NOT NULL COMMENT 'the borrower that is part of this list',
4428   PRIMARY KEY (`patron_list_patron_id`),
4429   KEY `patron_list_id` (`patron_list_id`),
4430   KEY `borrowernumber` (`borrowernumber`),
4431   CONSTRAINT `patron_list_patrons_ibfk_1` FOREIGN KEY (`patron_list_id`) REFERENCES `patron_lists` (`patron_list_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4432   CONSTRAINT `patron_list_patrons_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4433 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4434 /*!40101 SET character_set_client = @saved_cs_client */;
4435
4436 --
4437 -- Table structure for table `patron_lists`
4438 --
4439
4440 DROP TABLE IF EXISTS `patron_lists`;
4441 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4442 /*!40101 SET character_set_client = utf8 */;
4443 CREATE TABLE `patron_lists` (
4444   `patron_list_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
4445   `name` varchar(255) CHARACTER SET utf8mb4 NOT NULL COMMENT 'the list''s name',
4446   `owner` int(11) NOT NULL COMMENT 'borrowernumber of the list creator',
4447   `shared` tinyint(1) DEFAULT 0,
4448   PRIMARY KEY (`patron_list_id`),
4449   KEY `owner` (`owner`),
4450   CONSTRAINT `patron_lists_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4451 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4452 /*!40101 SET character_set_client = @saved_cs_client */;
4453
4454 --
4455 -- Table structure for table `patronimage`
4456 --
4457
4458 DROP TABLE IF EXISTS `patronimage`;
4459 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4460 /*!40101 SET character_set_client = utf8 */;
4461 CREATE TABLE `patronimage` (
4462   `borrowernumber` int(11) NOT NULL COMMENT 'the borrowernumber of the patron this image is attached to (borrowers.borrowernumber)',
4463   `mimetype` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the format of the image (png, jpg, etc)',
4464   `imagefile` mediumblob NOT NULL COMMENT 'the image',
4465   PRIMARY KEY (`borrowernumber`),
4466   CONSTRAINT `patronimage_fk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
4467 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4468 /*!40101 SET character_set_client = @saved_cs_client */;
4469
4470 --
4471 -- Table structure for table `pending_offline_operations`
4472 --
4473
4474 DROP TABLE IF EXISTS `pending_offline_operations`;
4475 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4476 /*!40101 SET character_set_client = utf8 */;
4477 CREATE TABLE `pending_offline_operations` (
4478   `operationid` int(11) NOT NULL AUTO_INCREMENT,
4479   `userid` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
4480   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
4481   `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
4482   `action` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
4483   `barcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4484   `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4485   `amount` decimal(28,6) DEFAULT NULL,
4486   PRIMARY KEY (`operationid`)
4487 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4488 /*!40101 SET character_set_client = @saved_cs_client */;
4489
4490 --
4491 -- Table structure for table `permissions`
4492 --
4493
4494 DROP TABLE IF EXISTS `permissions`;
4495 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4496 /*!40101 SET character_set_client = utf8 */;
4497 CREATE TABLE `permissions` (
4498   `module_bit` int(11) NOT NULL DEFAULT 0,
4499   `code` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4500   `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4501   PRIMARY KEY (`module_bit`,`code`),
4502   CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`) ON DELETE CASCADE ON UPDATE CASCADE
4503 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4504 /*!40101 SET character_set_client = @saved_cs_client */;
4505
4506 --
4507 -- Table structure for table `plugin_data`
4508 --
4509
4510 DROP TABLE IF EXISTS `plugin_data`;
4511 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4512 /*!40101 SET character_set_client = utf8 */;
4513 CREATE TABLE `plugin_data` (
4514   `plugin_class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
4515   `plugin_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
4516   `plugin_value` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4517   PRIMARY KEY (`plugin_class`(191),`plugin_key`(191))
4518 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4519 /*!40101 SET character_set_client = @saved_cs_client */;
4520
4521 --
4522 -- Table structure for table `plugin_methods`
4523 --
4524
4525 DROP TABLE IF EXISTS `plugin_methods`;
4526 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4527 /*!40101 SET character_set_client = utf8 */;
4528 CREATE TABLE `plugin_methods` (
4529   `plugin_class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
4530   `plugin_method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
4531   PRIMARY KEY (`plugin_class`(191),`plugin_method`(191))
4532 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4533 /*!40101 SET character_set_client = @saved_cs_client */;
4534
4535 --
4536 -- Table structure for table `printers_profile`
4537 --
4538
4539 DROP TABLE IF EXISTS `printers_profile`;
4540 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4541 /*!40101 SET character_set_client = utf8 */;
4542 CREATE TABLE `printers_profile` (
4543   `profile_id` int(4) NOT NULL AUTO_INCREMENT,
4544   `printer_name` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Default Printer',
4545   `template_id` int(4) NOT NULL DEFAULT 0,
4546   `paper_bin` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Bypass',
4547   `offset_horz` float NOT NULL DEFAULT 0,
4548   `offset_vert` float NOT NULL DEFAULT 0,
4549   `creep_horz` float NOT NULL DEFAULT 0,
4550   `creep_vert` float NOT NULL DEFAULT 0,
4551   `units` char(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'POINT',
4552   `creator` char(15) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Labels',
4553   PRIMARY KEY (`profile_id`),
4554   UNIQUE KEY `printername` (`printer_name`,`template_id`,`paper_bin`,`creator`)
4555 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4556 /*!40101 SET character_set_client = @saved_cs_client */;
4557
4558 --
4559 -- Table structure for table `problem_reports`
4560 --
4561
4562 DROP TABLE IF EXISTS `problem_reports`;
4563 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4564 /*!40101 SET character_set_client = utf8 */;
4565 CREATE TABLE `problem_reports` (
4566   `reportid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4567   `title` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'report subject line',
4568   `content` text COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'report message content',
4569   `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'the user who created the problem report',
4570   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'borrower''s branch',
4571   `username` varchar(75) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'OPAC username',
4572   `problempage` text COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'page the user triggered the problem report form from',
4573   `recipient` enum('admin','library') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'library' COMMENT 'the ''to-address'' of the problem report',
4574   `created_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'timestamp of report submission',
4575   `status` varchar(6) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'New' COMMENT 'status of the report. New, Viewed, Closed',
4576   PRIMARY KEY (`reportid`),
4577   KEY `problem_reports_ibfk1` (`borrowernumber`),
4578   KEY `problem_reports_ibfk2` (`branchcode`),
4579   CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4580   CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4581 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4582 /*!40101 SET character_set_client = @saved_cs_client */;
4583
4584 --
4585 -- Table structure for table `pseudonymized_borrower_attributes`
4586 --
4587
4588 DROP TABLE IF EXISTS `pseudonymized_borrower_attributes`;
4589 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4590 /*!40101 SET character_set_client = utf8 */;
4591 CREATE TABLE `pseudonymized_borrower_attributes` (
4592   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Row id field',
4593   `transaction_id` int(11) NOT NULL,
4594   `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',
4595   `attribute` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'custom patron field value',
4596   PRIMARY KEY (`id`),
4597   KEY `pseudonymized_borrower_attributes_ibfk_1` (`transaction_id`),
4598   KEY `anonymized_borrower_attributes_ibfk_2` (`code`),
4599   CONSTRAINT `anonymized_borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
4600   CONSTRAINT `pseudonymized_borrower_attributes_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pseudonymized_transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4601 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4602 /*!40101 SET character_set_client = @saved_cs_client */;
4603
4604 --
4605 -- Table structure for table `pseudonymized_transactions`
4606 --
4607
4608 DROP TABLE IF EXISTS `pseudonymized_transactions`;
4609 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4610 /*!40101 SET character_set_client = utf8 */;
4611 CREATE TABLE `pseudonymized_transactions` (
4612   `id` int(11) NOT NULL AUTO_INCREMENT,
4613   `hashed_borrowernumber` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
4614   `has_cardnumber` tinyint(1) NOT NULL DEFAULT 0,
4615   `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4616   `city` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4617   `state` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4618   `zipcode` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4619   `country` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4620   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4621   `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
4622   `dateenrolled` date DEFAULT NULL,
4623   `sex` varchar(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4624   `sort1` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4625   `sort2` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4626   `datetime` datetime DEFAULT NULL,
4627   `transaction_branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4628   `transaction_type` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4629   `itemnumber` int(11) DEFAULT NULL,
4630   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4631   `holdingbranch` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4632   `homebranch` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4633   `location` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4634   `itemcallnumber` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4635   `ccode` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4636   PRIMARY KEY (`id`),
4637   KEY `pseudonymized_transactions_ibfk_1` (`categorycode`),
4638   KEY `pseudonymized_transactions_borrowers_ibfk_2` (`branchcode`),
4639   KEY `pseudonymized_transactions_borrowers_ibfk_3` (`transaction_branchcode`)
4640 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4641 /*!40101 SET character_set_client = @saved_cs_client */;
4642
4643 --
4644 -- Table structure for table `quotes`
4645 --
4646
4647 DROP TABLE IF EXISTS `quotes`;
4648 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4649 /*!40101 SET character_set_client = utf8 */;
4650 CREATE TABLE `quotes` (
4651   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the quote',
4652   `source` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'source/credit for the quote',
4653   `text` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'text of the quote',
4654   `timestamp` datetime DEFAULT NULL COMMENT 'date and time that the quote last appeared in the opac',
4655   PRIMARY KEY (`id`)
4656 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4657 /*!40101 SET character_set_client = @saved_cs_client */;
4658
4659 --
4660 -- Table structure for table `ratings`
4661 --
4662
4663 DROP TABLE IF EXISTS `ratings`;
4664 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4665 /*!40101 SET character_set_client = utf8 */;
4666 CREATE TABLE `ratings` (
4667   `borrowernumber` int(11) NOT NULL COMMENT 'the borrowernumber of the patron who left this rating (borrowers.borrowernumber)',
4668   `biblionumber` int(11) NOT NULL COMMENT 'the biblio this rating is for (biblio.biblionumber)',
4669   `rating_value` tinyint(1) NOT NULL COMMENT 'the rating, from 1 to 5',
4670   `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
4671   PRIMARY KEY (`borrowernumber`,`biblionumber`),
4672   KEY `ratings_ibfk_2` (`biblionumber`),
4673   CONSTRAINT `ratings_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4674   CONSTRAINT `ratings_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4675 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4676 /*!40101 SET character_set_client = @saved_cs_client */;
4677
4678 --
4679 -- Table structure for table `recalls`
4680 --
4681
4682 DROP TABLE IF EXISTS `recalls`;
4683 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4684 /*!40101 SET character_set_client = utf8 */;
4685 CREATE TABLE `recalls` (
4686   `recall_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique identifier for this recall',
4687   `patron_id` int(11) NOT NULL DEFAULT 0 COMMENT 'Identifier for patron who requested recall',
4688   `created_date` datetime DEFAULT NULL COMMENT 'Date the recall was requested',
4689   `biblio_id` int(11) NOT NULL DEFAULT 0 COMMENT 'Identifier for bibliographic record that has been recalled',
4690   `pickup_library_id` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Identifier for recall pickup library',
4691   `completed_date` datetime DEFAULT NULL COMMENT 'Date the recall is completed (fulfilled, cancelled or expired)',
4692   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Notes related to the recall',
4693   `priority` smallint(6) DEFAULT NULL COMMENT 'Where in the queue the patron sits',
4694   `status` enum('requested','overdue','waiting','in_transit','cancelled','expired','fulfilled') COLLATE utf8mb4_unicode_ci DEFAULT 'requested' COMMENT 'Status of recall',
4695   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Date and time the recall was last updated',
4696   `item_id` int(11) DEFAULT NULL COMMENT 'Identifier for item record that was recalled, if an item-level recall',
4697   `waiting_date` datetime DEFAULT NULL COMMENT 'Date an item was marked as waiting for the patron at the library',
4698   `expiration_date` datetime DEFAULT NULL COMMENT 'Date recall is no longer required, or date recall will expire after waiting on shelf for pickup',
4699   `completed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Flag if recall is old and no longer active, i.e. expired, cancelled or completed',
4700   `item_level` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Flag if recall is for a specific item',
4701   PRIMARY KEY (`recall_id`),
4702   KEY `recalls_ibfk_1` (`patron_id`),
4703   KEY `recalls_ibfk_2` (`biblio_id`),
4704   KEY `recalls_ibfk_3` (`item_id`),
4705   KEY `recalls_ibfk_4` (`pickup_library_id`),
4706   CONSTRAINT `recalls_ibfk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4707   CONSTRAINT `recalls_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4708   CONSTRAINT `recalls_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4709   CONSTRAINT `recalls_ibfk_4` FOREIGN KEY (`pickup_library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4710 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Information related to recalls in Koha';
4711 /*!40101 SET character_set_client = @saved_cs_client */;
4712
4713 --
4714 -- Table structure for table `repeatable_holidays`
4715 --
4716
4717 DROP TABLE IF EXISTS `repeatable_holidays`;
4718 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4719 /*!40101 SET character_set_client = utf8 */;
4720 CREATE TABLE `repeatable_holidays` (
4721   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4722   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the branches table, defines which branch this closing is for',
4723   `weekday` smallint(6) DEFAULT NULL COMMENT 'day of the week (0=Sunday, 1=Monday, etc) this closing is repeated on',
4724   `day` smallint(6) DEFAULT NULL COMMENT 'day of the month this closing is on',
4725   `month` smallint(6) DEFAULT NULL COMMENT 'month this closing is in',
4726   `title` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'title of this closing',
4727   `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'description for this closing',
4728   PRIMARY KEY (`id`),
4729   KEY `repeatable_holidays_ibfk_1` (`branchcode`),
4730   CONSTRAINT `repeatable_holidays_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4731 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4732 /*!40101 SET character_set_client = @saved_cs_client */;
4733
4734 --
4735 -- Table structure for table `reports_dictionary`
4736 --
4737
4738 DROP TABLE IF EXISTS `reports_dictionary`;
4739 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4740 /*!40101 SET character_set_client = utf8 */;
4741 CREATE TABLE `reports_dictionary` (
4742   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4743   `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'name for this definition',
4744   `description` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'description for this definition',
4745   `date_created` datetime DEFAULT NULL COMMENT 'date and time this definition was created',
4746   `date_modified` datetime DEFAULT NULL COMMENT 'date and time this definition was last modified',
4747   `saved_sql` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'SQL snippet for us in reports',
4748   `report_area` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Koha module this definition is for Circulation, Catalog, Patrons, Acquistions, Accounts)',
4749   PRIMARY KEY (`id`),
4750   KEY `dictionary_area_idx` (`report_area`)
4751 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4752 /*!40101 SET character_set_client = @saved_cs_client */;
4753
4754 --
4755 -- Table structure for table `reserves`
4756 --
4757
4758 DROP TABLE IF EXISTS `reserves`;
4759 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4760 /*!40101 SET character_set_client = utf8 */;
4761 CREATE TABLE `reserves` (
4762   `reserve_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
4763   `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the borrowers table defining which patron this hold is for',
4764   `reservedate` date DEFAULT NULL COMMENT 'the date the hold was placed',
4765   `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblio table defining which bib record this hold is on',
4766   `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',
4767   `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',
4768   `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at',
4769   `notificationdate` date DEFAULT NULL COMMENT 'currently unused',
4770   `reminderdate` date DEFAULT NULL COMMENT 'currently unused',
4771   `cancellationdate` date DEFAULT NULL COMMENT 'the date this hold was cancelled',
4772   `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value CANCELLATION_REASON',
4773   `reservenotes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'notes related to this hold',
4774   `priority` smallint(6) NOT NULL DEFAULT 1 COMMENT 'where in the queue the patron sits',
4775   `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',
4776   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this hold was last updated',
4777   `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',
4778   `waitingdate` date DEFAULT NULL COMMENT 'the date the item was marked as waiting for the patron at the library',
4779   `expirationdate` date DEFAULT NULL COMMENT 'the date the hold expires (calculated value)',
4780   `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',
4781   `lowestPriority` tinyint(1) NOT NULL DEFAULT 0,
4782   `suspend` tinyint(1) NOT NULL DEFAULT 0,
4783   `suspend_until` datetime DEFAULT NULL,
4784   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'If record level hold, the optional itemtype of the item the patron is requesting',
4785   `item_level_hold` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is the hpld placed at item level',
4786   `non_priority` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is this a non priority hold',
4787   PRIMARY KEY (`reserve_id`),
4788   KEY `priorityfoundidx` (`priority`,`found`),
4789   KEY `borrowernumber` (`borrowernumber`),
4790   KEY `biblionumber` (`biblionumber`),
4791   KEY `itemnumber` (`itemnumber`),
4792   KEY `branchcode` (`branchcode`),
4793   KEY `desk_id` (`desk_id`),
4794   KEY `itemtype` (`itemtype`),
4795   CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
4796   CONSTRAINT `reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4797   CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4798   CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4799   CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
4800   CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
4801   CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE
4802 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4803 /*!40101 SET character_set_client = @saved_cs_client */;
4804
4805 --
4806 -- Table structure for table `hold_cancellation_requests`
4807 --
4808
4809 DROP TABLE IF EXISTS `hold_cancellation_requests`;
4810 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4811 /*!40101 SET character_set_client = utf8 */;
4812 CREATE TABLE `hold_cancellation_requests` (
4813   `hold_cancellation_request_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the cancellation request',
4814   `hold_id` int(11) NOT null COMMENT 'ID of the hold',
4815   `creation_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Time and date the cancellation request was created',
4816   PRIMARY KEY (`hold_cancellation_request_id`)
4817 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4818 /*!40101 SET character_set_client = @saved_cs_client */;
4819
4820 --
4821 -- Table structure for table `return_claims`
4822 --
4823
4824 DROP TABLE IF EXISTS `return_claims`;
4825 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4826 /*!40101 SET character_set_client = utf8 */;
4827 CREATE TABLE `return_claims` (
4828   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the return claim',
4829   `itemnumber` int(11) NOT NULL COMMENT 'ID of the item',
4830   `issue_id` int(11) DEFAULT NULL COMMENT 'ID of the checkout that triggered the claim',
4831   `borrowernumber` int(11) NOT NULL COMMENT 'ID of the patron',
4832   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Notes about the claim',
4833   `created_on` timestamp NULL DEFAULT NULL COMMENT 'Time and date the claim was created',
4834   `created_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that registered the claim',
4835   `updated_on` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Time and date of the latest change on the claim (notes)',
4836   `updated_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that updated the claim',
4837   `resolution` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Resolution code (RETURN_CLAIM_RESOLUTION AVs)',
4838   `resolved_on` timestamp NULL DEFAULT NULL COMMENT 'Time and date the claim was resolved',
4839   `resolved_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that resolved the claim',
4840   PRIMARY KEY (`id`),
4841   UNIQUE KEY `item_issue` (`itemnumber`, `issue_id`),
4842   KEY `itemnumber` (`itemnumber`),
4843   KEY `rc_borrowers_ibfk` (`borrowernumber`),
4844   KEY `rc_created_by_ibfk` (`created_by`),
4845   KEY `rc_updated_by_ibfk` (`updated_by`),
4846   KEY `rc_resolved_by_ibfk` (`resolved_by`),
4847   CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4848   CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
4849   CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4850   CONSTRAINT `rc_resolved_by_ibfk` FOREIGN KEY (`resolved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
4851   CONSTRAINT `rc_updated_by_ibfk` FOREIGN KEY (`updated_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
4852 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4853 /*!40101 SET character_set_client = @saved_cs_client */;
4854
4855 --
4856 -- Table structure for table `reviews`
4857 --
4858
4859 DROP TABLE IF EXISTS `reviews`;
4860 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4861 /*!40101 SET character_set_client = utf8 */;
4862 CREATE TABLE `reviews` (
4863   `reviewid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for this comment',
4864   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table defining which patron left this comment',
4865   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key from the biblio table defining which bibliographic record this comment is for',
4866   `review` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the body of the comment',
4867   `approved` tinyint(4) DEFAULT 0 COMMENT 'whether this comment has been approved by a librarian (1 for yes, 0 for no)',
4868   `datereviewed` datetime DEFAULT NULL COMMENT 'the date the comment was left',
4869   PRIMARY KEY (`reviewid`),
4870   KEY `reviews_ibfk_1` (`borrowernumber`),
4871   KEY `reviews_ibfk_2` (`biblionumber`),
4872   CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
4873   CONSTRAINT `reviews_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4874 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4875 /*!40101 SET character_set_client = @saved_cs_client */;
4876
4877 --
4878 -- Table structure for table `saved_reports`
4879 --
4880
4881 DROP TABLE IF EXISTS `saved_reports`;
4882 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4883 /*!40101 SET character_set_client = utf8 */;
4884 CREATE TABLE `saved_reports` (
4885   `id` int(11) NOT NULL AUTO_INCREMENT,
4886   `report_id` int(11) DEFAULT NULL,
4887   `report` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4888   `date_run` datetime DEFAULT NULL,
4889   PRIMARY KEY (`id`)
4890 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4891 /*!40101 SET character_set_client = @saved_cs_client */;
4892
4893 --
4894 -- Table structure for table `saved_sql`
4895 --
4896
4897 DROP TABLE IF EXISTS `saved_sql`;
4898 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4899 /*!40101 SET character_set_client = utf8 */;
4900 CREATE TABLE `saved_sql` (
4901   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id and primary key assigned by Koha',
4902   `borrowernumber` int(11) DEFAULT NULL COMMENT 'the staff member who created this report (borrowers.borrowernumber)',
4903   `date_created` datetime DEFAULT NULL COMMENT 'the date this report was created',
4904   `last_modified` datetime DEFAULT NULL COMMENT 'the date this report was last edited',
4905   `savedsql` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the SQL for this report',
4906   `last_run` datetime DEFAULT NULL,
4907   `report_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'the name of this report',
4908   `type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'always 1 for tabular',
4909   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the notes or description given to this report',
4910   `cache_expiry` int(11) NOT NULL DEFAULT 300,
4911   `public` tinyint(1) NOT NULL DEFAULT 0,
4912   `report_area` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4913   `report_group` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4914   `report_subgroup` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
4915   `mana_id` int(11) DEFAULT NULL,
4916   PRIMARY KEY (`id`),
4917   KEY `sql_area_group_idx` (`report_group`,`report_subgroup`),
4918   KEY `boridx` (`borrowernumber`)
4919 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4920 /*!40101 SET character_set_client = @saved_cs_client */;
4921
4922 --
4923 -- Table structure for table `search_field`
4924 --
4925
4926 DROP TABLE IF EXISTS `search_field`;
4927 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4928 /*!40101 SET character_set_client = utf8 */;
4929 CREATE TABLE `search_field` (
4930   `id` int(11) NOT NULL AUTO_INCREMENT,
4931   `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
4932   `label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the human readable name of the field, for display',
4933   `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',
4934   `weight` decimal(5,2) DEFAULT NULL,
4935   `facet_order` tinyint(4) DEFAULT NULL COMMENT 'the order place of the field in facet list if faceted',
4936   `staff_client` tinyint(1) NOT NULL DEFAULT 1,
4937   `opac` tinyint(1) NOT NULL DEFAULT 1,
4938   `mandatory` tinyint(1) DEFAULT NULL COMMENT 'if marked this field is not editable or removable',
4939   PRIMARY KEY (`id`),
4940   UNIQUE KEY `name` (`name`(191))
4941 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4942 /*!40101 SET character_set_client = @saved_cs_client */;
4943
4944 --
4945 -- Table structure for table `search_filters`
4946 --
4947
4948 DROP TABLE IF EXISTS `search_filters`;
4949 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4950 /*!40101 SET character_set_client = utf8 */;
4951 CREATE TABLE `search_filters` (
4952   `search_filter_id` int(11) NOT NULL AUTO_INCREMENT,
4953   `name` varchar(255) NOT NULL COMMENT 'filter name',
4954   `query` mediumtext NULL DEFAULT NULL COMMENT 'filter query part',
4955   `limits` mediumtext NULL DEFAULT NULL COMMENT 'filter limits part',
4956   `opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether this filter is shown on OPAC',
4957   `staff_client` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether this filter is shown in staff client',
4958   PRIMARY KEY (`search_filter_id`)
4959 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4960 /*!40101 SET character_set_client = @saved_cs_client */;
4961
4962 --
4963 -- Table structure for table `search_history`
4964 --
4965
4966 DROP TABLE IF EXISTS `search_history`;
4967 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4968 /*!40101 SET character_set_client = utf8 */;
4969 CREATE TABLE `search_history` (
4970   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'search history id',
4971   `userid` int(11) NOT NULL COMMENT 'the patron who performed the search (borrowers.borrowernumber)',
4972   `sessionid` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'a system generated session id',
4973   `query_desc` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the search that was performed',
4974   `query_cgi` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the string to append to the search url to rerun the search',
4975   `type` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'biblio' COMMENT 'search type, must be ''biblio'' or ''authority''',
4976   `total` int(11) NOT NULL COMMENT 'the total of results found',
4977   `time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'the date and time the search was run',
4978   PRIMARY KEY (`id`),
4979   KEY `userid` (`userid`),
4980   KEY `sessionid` (`sessionid`)
4981 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Opac search history results';
4982 /*!40101 SET character_set_client = @saved_cs_client */;
4983
4984 --
4985 -- Table structure for table `search_marc_map`
4986 --
4987
4988 DROP TABLE IF EXISTS `search_marc_map`;
4989 /*!40101 SET @saved_cs_client     = @@character_set_client */;
4990 /*!40101 SET character_set_client = utf8 */;
4991 CREATE TABLE `search_marc_map` (
4992   `id` int(11) NOT NULL AUTO_INCREMENT,
4993   `index_name` enum('biblios','authorities') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'what storage index this map is for',
4994   `marc_type` enum('marc21','unimarc') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'what MARC type this map is for',
4995   `marc_field` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the MARC specifier for this field',
4996   PRIMARY KEY (`id`),
4997   UNIQUE KEY `index_name` (`index_name`,`marc_field`(191),`marc_type`),
4998   KEY `index_name_2` (`index_name`)
4999 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5000 /*!40101 SET character_set_client = @saved_cs_client */;
5001
5002 --
5003 -- Table structure for table `search_marc_to_field`
5004 --
5005
5006 DROP TABLE IF EXISTS `search_marc_to_field`;
5007 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5008 /*!40101 SET character_set_client = utf8 */;
5009 CREATE TABLE `search_marc_to_field` (
5010   `search` tinyint(1) NOT NULL DEFAULT 1,
5011   `search_marc_map_id` int(11) NOT NULL,
5012   `search_field_id` int(11) NOT NULL,
5013   `facet` tinyint(1) DEFAULT 0 COMMENT 'true if a facet field should be generated for this',
5014   `suggestible` tinyint(1) DEFAULT 0 COMMENT 'true if this field can be used to generate suggestions for browse',
5015   `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',
5016   PRIMARY KEY (`search_marc_map_id`,`search_field_id`),
5017   KEY `search_field_id` (`search_field_id`),
5018   CONSTRAINT `search_marc_to_field_ibfk_1` FOREIGN KEY (`search_marc_map_id`) REFERENCES `search_marc_map` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
5019   CONSTRAINT `search_marc_to_field_ibfk_2` FOREIGN KEY (`search_field_id`) REFERENCES `search_field` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
5020 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5021 /*!40101 SET character_set_client = @saved_cs_client */;
5022
5023 --
5024 -- Table structure for table `serial`
5025 --
5026
5027 DROP TABLE IF EXISTS `serial`;
5028 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5029 /*!40101 SET character_set_client = utf8 */;
5030 CREATE TABLE `serial` (
5031   `serialid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the issue',
5032   `biblionumber` int(11) NOT NULL COMMENT 'foreign key for the biblio.biblionumber that this issue is attached to',
5033   `subscriptionid` int(11) NOT NULL COMMENT 'foreign key to the subscription.subscriptionid that this issue is part of',
5034   `serialseq` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'issue information (volume, number, etc)',
5035   `serialseq_x` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'first part of issue information',
5036   `serialseq_y` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'second part of issue information',
5037   `serialseq_z` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'third part of issue information',
5038   `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'status code for this issue (see manual for full descriptions)',
5039   `planneddate` date DEFAULT NULL COMMENT 'date expected',
5040   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'notes',
5041   `publisheddate` date DEFAULT NULL COMMENT 'date published',
5042   `publisheddatetext` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'date published (descriptive)',
5043   `claimdate` date DEFAULT NULL COMMENT 'date claimed',
5044   `claims_count` int(11) DEFAULT 0 COMMENT 'number of claims made related to this issue',
5045   `routingnotes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'notes from the routing list',
5046   PRIMARY KEY (`serialid`),
5047   KEY `serial_ibfk_1` (`biblionumber`),
5048   KEY `serial_ibfk_2` (`subscriptionid`),
5049   CONSTRAINT `serial_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5050   CONSTRAINT `serial_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
5051 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5052 /*!40101 SET character_set_client = @saved_cs_client */;
5053
5054 --
5055 -- Table structure for table `serialitems`
5056 --
5057
5058 DROP TABLE IF EXISTS `serialitems`;
5059 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5060 /*!40101 SET character_set_client = utf8 */;
5061 CREATE TABLE `serialitems` (
5062   `itemnumber` int(11) NOT NULL,
5063   `serialid` int(11) NOT NULL,
5064   PRIMARY KEY (`itemnumber`),
5065   KEY `serialitems_sfk_1` (`serialid`),
5066   CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
5067   CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
5068 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5069 /*!40101 SET character_set_client = @saved_cs_client */;
5070
5071 --
5072 -- Table structure for table `sessions`
5073 --
5074
5075 DROP TABLE IF EXISTS `sessions`;
5076 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5077 /*!40101 SET character_set_client = utf8 */;
5078 CREATE TABLE `sessions` (
5079   `id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
5080   `a_session` longblob NOT NULL,
5081   PRIMARY KEY (`id`)
5082 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5083 /*!40101 SET character_set_client = @saved_cs_client */;
5084
5085 --
5086 -- Table structure for table `sms_providers`
5087 --
5088
5089 DROP TABLE IF EXISTS `sms_providers`;
5090 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5091 /*!40101 SET character_set_client = utf8 */;
5092 CREATE TABLE `sms_providers` (
5093   `id` int(11) NOT NULL AUTO_INCREMENT,
5094   `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5095   `domain` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5096   PRIMARY KEY (`id`),
5097   UNIQUE KEY `name` (`name`(191))
5098 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5099 /*!40101 SET character_set_client = @saved_cs_client */;
5100
5101 --
5102 -- Table structure for table `smtp_servers`
5103 --
5104
5105 DROP TABLE IF EXISTS `smtp_servers`;
5106 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5107 /*!40101 SET character_set_client = utf8 */;
5108 CREATE TABLE `smtp_servers` (
5109   `id` int(11) NOT NULL AUTO_INCREMENT,
5110   `name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
5111   `host` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'localhost',
5112   `port` int(11) NOT NULL DEFAULT 25,
5113   `timeout` int(11) NOT NULL DEFAULT 120,
5114   `ssl_mode` enum('disabled','ssl','starttls') COLLATE utf8mb4_unicode_ci NOT NULL,
5115   `user_name` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5116   `password` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5117   `debug` tinyint(1) NOT NULL DEFAULT 0,
5118   PRIMARY KEY (`id`),
5119   KEY `host_idx` (`host`)
5120 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5121 /*!40101 SET character_set_client = @saved_cs_client */;
5122
5123 --
5124 -- Table structure for table `social_data`
5125 --
5126
5127 DROP TABLE IF EXISTS `social_data`;
5128 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5129 /*!40101 SET character_set_client = utf8 */;
5130 CREATE TABLE `social_data` (
5131   `isbn` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
5132   `num_critics` int(11) DEFAULT NULL,
5133   `num_critics_pro` int(11) DEFAULT NULL,
5134   `num_quotations` int(11) DEFAULT NULL,
5135   `num_videos` int(11) DEFAULT NULL,
5136   `score_avg` decimal(5,2) DEFAULT NULL,
5137   `num_scores` int(11) DEFAULT NULL,
5138   PRIMARY KEY (`isbn`)
5139 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5140 /*!40101 SET character_set_client = @saved_cs_client */;
5141
5142 --
5143 -- Table structure for table `special_holidays`
5144 --
5145
5146 DROP TABLE IF EXISTS `special_holidays`;
5147 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5148 /*!40101 SET character_set_client = utf8 */;
5149 CREATE TABLE `special_holidays` (
5150   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5151   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the branches table, defines which branch this closing is for',
5152   `day` smallint(6) NOT NULL DEFAULT 0 COMMENT 'day of the month this closing is on',
5153   `month` smallint(6) NOT NULL DEFAULT 0 COMMENT 'month this closing is in',
5154   `year` smallint(6) NOT NULL DEFAULT 0 COMMENT 'year this closing is in',
5155   `isexception` smallint(1) NOT NULL DEFAULT 1 COMMENT 'is this a holiday exception to a repeatable holiday (1 for yes, 0 for no)',
5156   `title` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'title for this closing',
5157   `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'description of this closing',
5158   PRIMARY KEY (`id`),
5159   KEY `special_holidays_ibfk_1` (`branchcode`),
5160   CONSTRAINT `special_holidays_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5161 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5162 /*!40101 SET character_set_client = @saved_cs_client */;
5163
5164 --
5165 -- Table structure for table `statistics`
5166 --
5167
5168 DROP TABLE IF EXISTS `statistics`;
5169 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5170 /*!40101 SET character_set_client = utf8 */;
5171 CREATE TABLE `statistics` (
5172   `datetime` datetime DEFAULT NULL COMMENT 'date and time of the transaction',
5173   `branch` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key, branch where the transaction occurred',
5174   `value` double(16,4) DEFAULT NULL COMMENT 'monetary value associated with the transaction',
5175   `type` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'transaction type (localuse, issue, return, renew, writeoff, payment)',
5176   `other` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'used by SIP',
5177   `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key from the items table, links transaction to a specific item',
5178   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the itemtypes table, links transaction to a specific item type',
5179   `location` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)',
5180   `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key from the borrowers table, links transaction to a specific borrower',
5181   `ccode` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the items table, links transaction to a specific collection code',
5182   `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the borrowers table, links transaction to a specific borrower category',
5183   KEY `timeidx` (`datetime`),
5184   KEY `branch_idx` (`branch`),
5185   KEY `type_idx` (`type`),
5186   KEY `itemnumber_idx` (`itemnumber`),
5187   KEY `itemtype_idx` (`itemtype`),
5188   KEY `borrowernumber_idx` (`borrowernumber`),
5189   KEY `ccode_idx` (`ccode`)
5190 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5191 /*!40101 SET character_set_client = @saved_cs_client */;
5192
5193 --
5194 -- Table structure for table `stockrotationitems`
5195 --
5196
5197 DROP TABLE IF EXISTS `stockrotationitems`;
5198 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5199 /*!40101 SET character_set_client = utf8 */;
5200 CREATE TABLE `stockrotationitems` (
5201   `itemnumber_id` int(11) NOT NULL COMMENT 'Itemnumber to link to a stage & rota',
5202   `stage_id` int(11) NOT NULL COMMENT 'stage ID to link the item to',
5203   `indemand` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Should this item be skipped for rotation?',
5204   `fresh` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Flag showing item is only just added to rota',
5205   PRIMARY KEY (`itemnumber_id`),
5206   KEY `stockrotationitems_sifk` (`stage_id`),
5207   CONSTRAINT `stockrotationitems_iifk` FOREIGN KEY (`itemnumber_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5208   CONSTRAINT `stockrotationitems_sifk` FOREIGN KEY (`stage_id`) REFERENCES `stockrotationstages` (`stage_id`) ON DELETE CASCADE ON UPDATE CASCADE
5209 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5210 /*!40101 SET character_set_client = @saved_cs_client */;
5211
5212 --
5213 -- Table structure for table `stockrotationrotas`
5214 --
5215
5216 DROP TABLE IF EXISTS `stockrotationrotas`;
5217 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5218 /*!40101 SET character_set_client = utf8 */;
5219 CREATE TABLE `stockrotationrotas` (
5220   `rota_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Stockrotation rota ID',
5221   `title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Title for this rota',
5222   `description` text COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Description for this rota',
5223   `cyclical` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Should items on this rota keep cycling?',
5224   `active` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Is this rota currently active?',
5225   PRIMARY KEY (`rota_id`),
5226   UNIQUE KEY `stockrotationrotas_title` (`title`)
5227 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5228 /*!40101 SET character_set_client = @saved_cs_client */;
5229
5230 --
5231 -- Table structure for table `stockrotationstages`
5232 --
5233
5234 DROP TABLE IF EXISTS `stockrotationstages`;
5235 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5236 /*!40101 SET character_set_client = utf8 */;
5237 CREATE TABLE `stockrotationstages` (
5238   `stage_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique stage ID',
5239   `position` int(11) NOT NULL COMMENT 'The position of this stage within its rota',
5240   `rota_id` int(11) NOT NULL COMMENT 'The rota this stage belongs to',
5241   `branchcode_id` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Branch this stage relates to',
5242   `duration` int(11) NOT NULL DEFAULT 4 COMMENT 'The number of days items shoud occupy this stage',
5243   PRIMARY KEY (`stage_id`),
5244   KEY `stockrotationstages_rifk` (`rota_id`),
5245   KEY `stockrotationstages_bifk` (`branchcode_id`),
5246   CONSTRAINT `stockrotationstages_bifk` FOREIGN KEY (`branchcode_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5247   CONSTRAINT `stockrotationstages_rifk` FOREIGN KEY (`rota_id`) REFERENCES `stockrotationrotas` (`rota_id`) ON DELETE CASCADE ON UPDATE CASCADE
5248 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5249 /*!40101 SET character_set_client = @saved_cs_client */;
5250
5251 --
5252 -- Table structure for table `subscription`
5253 --
5254
5255 DROP TABLE IF EXISTS `subscription`;
5256 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5257 /*!40101 SET character_set_client = utf8 */;
5258 CREATE TABLE `subscription` (
5259   `biblionumber` int(11) NOT NULL COMMENT 'foreign key for biblio.biblionumber that this subscription is attached to',
5260   `subscriptionid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for this subscription',
5261   `librarian` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT 'the librarian''s username from borrowers.userid',
5262   `startdate` date DEFAULT NULL COMMENT 'start date for this subscription',
5263   `aqbooksellerid` int(11) DEFAULT 0 COMMENT 'foreign key for aqbooksellers.id to link to the vendor',
5264   `cost` int(11) DEFAULT 0,
5265   `aqbudgetid` int(11) DEFAULT 0,
5266   `weeklength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if monthlength or numberlength is set)',
5267   `monthlength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if weeklength or numberlength is set)',
5268   `numberlength` int(11) DEFAULT 0 COMMENT 'subscription length in weeks (will not be filled in if monthlength or weeklength is set)',
5269   `periodicity` int(11) DEFAULT NULL COMMENT 'frequency type links to subscription_frequencies.id',
5270   `countissuesperunit` int(11) NOT NULL DEFAULT 1,
5271   `notes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'notes',
5272   `status` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'status of this subscription',
5273   `lastvalue1` int(11) DEFAULT NULL,
5274   `innerloop1` int(11) DEFAULT 0,
5275   `lastvalue2` int(11) DEFAULT NULL,
5276   `innerloop2` int(11) DEFAULT 0,
5277   `lastvalue3` int(11) DEFAULT NULL,
5278   `innerloop3` int(11) DEFAULT 0,
5279   `firstacquidate` date DEFAULT NULL COMMENT 'first issue received date',
5280   `manualhistory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes or no to managing the history manually',
5281   `irregularity` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any irregularities in the subscription',
5282   `skip_serialseq` tinyint(1) NOT NULL DEFAULT 0,
5283   `letter` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5284   `numberpattern` int(11) DEFAULT NULL COMMENT 'the numbering pattern used links to subscription_numberpatterns.id',
5285   `locale` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'for foreign language subscriptions to display months, seasons, etc correctly',
5286   `distributedto` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5287   `internalnotes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5288   `callnumber` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'default call number',
5289   `location` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT 'default shelving location (items.location)',
5290   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'default branches (items.homebranch)',
5291   `lastbranch` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5292   `serialsadditems` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'does receiving this serial create an item record',
5293   `staffdisplaycount` INT(11) NULL DEFAULT NULL COMMENT 'how many issues to show to the staff',
5294   `opacdisplaycount` INT(11) NULL DEFAULT NULL COMMENT 'how many issues to show to the public',
5295   `graceperiod` int(11) NOT NULL DEFAULT 0 COMMENT 'grace period in days',
5296   `enddate` date DEFAULT NULL COMMENT 'subscription end date',
5297   `closed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'yes / no if the subscription is closed',
5298   `reneweddate` date DEFAULT NULL COMMENT 'date of last renewal for the subscription',
5299   `itemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5300   `previousitemtype` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5301   `mana_id` int(11) DEFAULT NULL,
5302   `ccode` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'collection code to assign to serial items',
5303   PRIMARY KEY (`subscriptionid`),
5304   KEY `subscription_ibfk_1` (`periodicity`),
5305   KEY `subscription_ibfk_2` (`numberpattern`),
5306   KEY `subscription_ibfk_3` (`biblionumber`),
5307   CONSTRAINT `subscription_ibfk_1` FOREIGN KEY (`periodicity`) REFERENCES `subscription_frequencies` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
5308   CONSTRAINT `subscription_ibfk_2` FOREIGN KEY (`numberpattern`) REFERENCES `subscription_numberpatterns` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
5309   CONSTRAINT `subscription_ibfk_3` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
5310 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5311 /*!40101 SET character_set_client = @saved_cs_client */;
5312
5313 --
5314 -- Table structure for table `subscription_frequencies`
5315 --
5316
5317 DROP TABLE IF EXISTS `subscription_frequencies`;
5318 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5319 /*!40101 SET character_set_client = utf8 */;
5320 CREATE TABLE `subscription_frequencies` (
5321   `id` int(11) NOT NULL AUTO_INCREMENT,
5322   `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5323   `displayorder` int(11) DEFAULT NULL,
5324   `unit` enum('day','week','month','year') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5325   `unitsperissue` int(11) NOT NULL DEFAULT 1,
5326   `issuesperunit` int(11) NOT NULL DEFAULT 1,
5327   PRIMARY KEY (`id`)
5328 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5329 /*!40101 SET character_set_client = @saved_cs_client */;
5330
5331 --
5332 -- Table structure for table `subscription_numberpatterns`
5333 --
5334
5335 DROP TABLE IF EXISTS `subscription_numberpatterns`;
5336 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5337 /*!40101 SET character_set_client = utf8 */;
5338 CREATE TABLE `subscription_numberpatterns` (
5339   `id` int(11) NOT NULL AUTO_INCREMENT,
5340   `label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5341   `displayorder` int(11) DEFAULT NULL,
5342   `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5343   `numberingmethod` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5344   `label1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5345   `add1` int(11) DEFAULT NULL,
5346   `every1` int(11) DEFAULT NULL,
5347   `whenmorethan1` int(11) DEFAULT NULL,
5348   `setto1` int(11) DEFAULT NULL,
5349   `numbering1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5350   `label2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5351   `add2` int(11) DEFAULT NULL,
5352   `every2` int(11) DEFAULT NULL,
5353   `whenmorethan2` int(11) DEFAULT NULL,
5354   `setto2` int(11) DEFAULT NULL,
5355   `numbering2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5356   `label3` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5357   `add3` int(11) DEFAULT NULL,
5358   `every3` int(11) DEFAULT NULL,
5359   `whenmorethan3` int(11) DEFAULT NULL,
5360   `setto3` int(11) DEFAULT NULL,
5361   `numbering3` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5362   PRIMARY KEY (`id`)
5363 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5364 /*!40101 SET character_set_client = @saved_cs_client */;
5365
5366 --
5367 -- Table structure for table `subscriptionhistory`
5368 --
5369
5370 DROP TABLE IF EXISTS `subscriptionhistory`;
5371 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5372 /*!40101 SET character_set_client = utf8 */;
5373 CREATE TABLE `subscriptionhistory` (
5374   `biblionumber` int(11) NOT NULL,
5375   `subscriptionid` int(11) NOT NULL,
5376   `histstartdate` date DEFAULT NULL,
5377   `histenddate` date DEFAULT NULL,
5378   `missinglist` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
5379   `recievedlist` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
5380   `opacnote` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5381   `librariannote` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5382   PRIMARY KEY (`subscriptionid`),
5383   KEY `subscription_history_ibfk_1` (`biblionumber`),
5384   CONSTRAINT `subscription_history_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5385   CONSTRAINT `subscription_history_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
5386 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5387 /*!40101 SET character_set_client = @saved_cs_client */;
5388
5389 --
5390 -- Table structure for table `subscriptionroutinglist`
5391 --
5392
5393 DROP TABLE IF EXISTS `subscriptionroutinglist`;
5394 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5395 /*!40101 SET character_set_client = utf8 */;
5396 CREATE TABLE `subscriptionroutinglist` (
5397   `routingid` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5398   `borrowernumber` int(11) NOT NULL COMMENT 'foreign key from the borrowers table, defines with patron is on the routing list',
5399   `ranking` int(11) DEFAULT NULL COMMENT 'where the patron stands in line to receive the serial',
5400   `subscriptionid` int(11) NOT NULL COMMENT 'foreign key from the subscription table, defines which subscription this routing list is for',
5401   PRIMARY KEY (`routingid`),
5402   UNIQUE KEY `subscriptionid` (`subscriptionid`,`borrowernumber`),
5403   KEY `subscriptionroutinglist_ibfk_1` (`borrowernumber`),
5404   CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5405   CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE
5406 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5407 /*!40101 SET character_set_client = @saved_cs_client */;
5408
5409 --
5410 -- Table structure for table `suggestions`
5411 --
5412
5413 DROP TABLE IF EXISTS `suggestions`;
5414 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5415 /*!40101 SET character_set_client = utf8 */;
5416 CREATE TABLE `suggestions` (
5417   `suggestionid` int(8) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned automatically by Koha',
5418   `suggestedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the person making the suggestion, foreign key linking to the borrowers table',
5419   `suggesteddate` date NOT NULL COMMENT 'date the suggestion was submitted',
5420   `managedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian managing the suggestion, foreign key linking to the borrowers table',
5421   `manageddate` date DEFAULT NULL COMMENT 'date the suggestion was updated',
5422   `acceptedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian who accepted the suggestion, foreign key linking to the borrowers table',
5423   `accepteddate` date DEFAULT NULL COMMENT 'date the suggestion was marked as accepted',
5424   `rejectedby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table',
5425   `rejecteddate` date DEFAULT NULL COMMENT 'date the suggestion was marked as rejected',
5426   `lastmodificationby` int(11) DEFAULT NULL COMMENT 'borrowernumber for the librarian who edit the suggestion for the last time',
5427   `lastmodificationdate` date DEFAULT NULL COMMENT 'date of the last modification',
5428   `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)',
5429   `archived` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the suggestion archived?',
5430   `note` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'note entered on the suggestion',
5431   `staff_note` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'non-public note entered on the suggestion',
5432   `author` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'author of the suggested item',
5433   `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'title of the suggested item',
5434   `copyrightdate` smallint(6) DEFAULT NULL COMMENT 'copyright date of the suggested item',
5435   `publishercode` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'publisher of the suggested item',
5436   `date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time the suggestion was updated',
5437   `volumedesc` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5438   `publicationyear` smallint(6) DEFAULT 0,
5439   `place` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'publication place of the suggested item',
5440   `isbn` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'isbn of the suggested item',
5441   `biblionumber` int(11) DEFAULT NULL COMMENT 'foreign key linking the suggestion to the biblio table after the suggestion has been ordered',
5442   `reason` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'reason for accepting or rejecting the suggestion',
5443   `patronreason` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'reason for making the suggestion',
5444   `budgetid` int(11) DEFAULT NULL COMMENT 'foreign key linking the suggested budget to the aqbudgets table',
5445   `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key linking the suggested branch to the branches table',
5446   `collectiontitle` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'collection name for the suggested item',
5447   `itemtype` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'suggested item type',
5448   `quantity` smallint(6) DEFAULT NULL COMMENT 'suggested quantity to be purchased',
5449   `currency` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'suggested currency for the suggested price',
5450   `price` decimal(28,6) DEFAULT NULL COMMENT 'suggested price',
5451   `total` decimal(28,6) DEFAULT NULL COMMENT 'suggested total cost (price*quantity updated for currency)',
5452   PRIMARY KEY (`suggestionid`),
5453   KEY `suggestedby` (`suggestedby`),
5454   KEY `managedby` (`managedby`),
5455   KEY `acceptedby` (`acceptedby`),
5456   KEY `rejectedby` (`rejectedby`),
5457   KEY `biblionumber` (`biblionumber`),
5458   KEY `budgetid` (`budgetid`),
5459   KEY `branchcode` (`branchcode`),
5460   KEY `status` (`STATUS`),
5461   KEY `suggestions_ibfk_lastmodificationby` (`lastmodificationby`),
5462   CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE,
5463   CONSTRAINT `suggestions_ibfk_acceptedby` FOREIGN KEY (`acceptedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5464   CONSTRAINT `suggestions_ibfk_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5465   CONSTRAINT `suggestions_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
5466   CONSTRAINT `suggestions_ibfk_lastmodificationby` FOREIGN KEY (`lastmodificationby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5467   CONSTRAINT `suggestions_ibfk_managedby` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5468   CONSTRAINT `suggestions_ibfk_rejectedby` FOREIGN KEY (`rejectedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5469   CONSTRAINT `suggestions_ibfk_suggestedby` FOREIGN KEY (`suggestedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5470 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5471 /*!40101 SET character_set_client = @saved_cs_client */;
5472
5473 --
5474 -- Table structure for table `systempreferences`
5475 --
5476
5477 DROP TABLE IF EXISTS `systempreferences`;
5478 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5479 /*!40101 SET character_set_client = utf8 */;
5480 CREATE TABLE `systempreferences` (
5481   `variable` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'system preference name',
5482   `value` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'system preference values',
5483   `options` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'options for multiple choice system preferences',
5484   `explanation` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'descriptive text for the system preference',
5485   `type` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'type of question this preference asks (multiple choice, plain text, yes or no, etc)',
5486   PRIMARY KEY (`variable`)
5487 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5488 /*!40101 SET character_set_client = @saved_cs_client */;
5489
5490 --
5491 -- Table structure for table `tables_settings`
5492 --
5493
5494 DROP TABLE IF EXISTS `tables_settings`;
5495 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5496 /*!40101 SET character_set_client = utf8 */;
5497 CREATE TABLE `tables_settings` (
5498   `module` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5499   `page` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5500   `tablename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
5501   `default_display_length` smallint(6) DEFAULT NULL,
5502   `default_sort_order` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5503   PRIMARY KEY (`module`(191),`page`(191),`tablename`(191))
5504 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5505 /*!40101 SET character_set_client = @saved_cs_client */;
5506
5507 --
5508 -- Table structure for table `tags`
5509 --
5510
5511 DROP TABLE IF EXISTS `tags`;
5512 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5513 /*!40101 SET character_set_client = utf8 */;
5514 CREATE TABLE `tags` (
5515   `entry` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
5516   `weight` bigint(20) NOT NULL DEFAULT 0,
5517   PRIMARY KEY (`entry`(191))
5518 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5519 /*!40101 SET character_set_client = @saved_cs_client */;
5520
5521 --
5522 -- Table structure for table `tags_all`
5523 --
5524
5525 DROP TABLE IF EXISTS `tags_all`;
5526 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5527 /*!40101 SET character_set_client = utf8 */;
5528 CREATE TABLE `tags_all` (
5529   `tag_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id and primary key',
5530   `borrowernumber` int(11) DEFAULT NULL COMMENT 'the patron who added the tag (borrowers.borrowernumber)',
5531   `biblionumber` int(11) NOT NULL COMMENT 'the bib record this tag was left on (biblio.biblionumber)',
5532   `term` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the tag',
5533   `language` int(4) DEFAULT NULL COMMENT 'the language the tag was left in',
5534   `date_created` datetime NOT NULL COMMENT 'the date the tag was added',
5535   PRIMARY KEY (`tag_id`),
5536   KEY `tags_borrowers_fk_1` (`borrowernumber`),
5537   KEY `tags_biblionumber_fk_1` (`biblionumber`),
5538   CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5539   CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5540 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5541 /*!40101 SET character_set_client = @saved_cs_client */;
5542
5543 --
5544 -- Table structure for table `tags_approval`
5545 --
5546
5547 DROP TABLE IF EXISTS `tags_approval`;
5548 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5549 /*!40101 SET character_set_client = utf8 */;
5550 CREATE TABLE `tags_approval` (
5551   `term` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the tag',
5552   `approved` int(1) NOT NULL DEFAULT 0 COMMENT 'whether the tag is approved or not (1=yes, 0=pending, -1=rejected)',
5553   `date_approved` datetime DEFAULT NULL COMMENT 'the date this tag was approved',
5554   `approved_by` int(11) DEFAULT NULL COMMENT 'the librarian who approved the tag (borrowers.borrowernumber)',
5555   `weight_total` int(9) NOT NULL DEFAULT 1 COMMENT 'the total number of times this tag was used',
5556   PRIMARY KEY (`term`),
5557   KEY `tags_approval_borrowers_fk_1` (`approved_by`),
5558   CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
5559 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5560 /*!40101 SET character_set_client = @saved_cs_client */;
5561
5562 --
5563 -- Table structure for table `tags_index`
5564 --
5565
5566 DROP TABLE IF EXISTS `tags_index`;
5567 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5568 /*!40101 SET character_set_client = utf8 */;
5569 CREATE TABLE `tags_index` (
5570   `term` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'the tag',
5571   `biblionumber` int(11) NOT NULL COMMENT 'the bib record this tag was used on (biblio.biblionumber)',
5572   `weight` int(9) NOT NULL DEFAULT 1 COMMENT 'the number of times this term was used on this bib record',
5573   PRIMARY KEY (`term`,`biblionumber`),
5574   KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
5575   CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5576   CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`) REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE
5577 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5578 /*!40101 SET character_set_client = @saved_cs_client */;
5579
5580 --
5581 -- Table structure for table `tmp_holdsqueue`
5582 --
5583
5584 DROP TABLE IF EXISTS `tmp_holdsqueue`;
5585 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5586 /*!40101 SET character_set_client = utf8 */;
5587 CREATE TABLE `tmp_holdsqueue` (
5588   `biblionumber` int(11) DEFAULT NULL,
5589   `itemnumber` int(11) DEFAULT NULL,
5590   `barcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5591   `surname` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
5592   `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5593   `phone` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5594   `borrowernumber` int(11) NOT NULL,
5595   `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5596   `reservedate` date DEFAULT NULL,
5597   `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5598   `itemcallnumber` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5599   `holdingbranch` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5600   `pickbranch` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5601   `notes` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5602   `item_level_request` tinyint(4) NOT NULL DEFAULT 0,
5603   `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
5604   KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
5605   KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
5606   KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
5607   CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5608   CONSTRAINT `tmp_holdsqueue_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5609   CONSTRAINT `tmp_holdsqueue_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
5610 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5611 /*!40101 SET character_set_client = @saved_cs_client */;
5612
5613 --
5614 -- Table structure for table `transport_cost`
5615 --
5616
5617 DROP TABLE IF EXISTS `transport_cost`;
5618 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5619 /*!40101 SET character_set_client = utf8 */;
5620 CREATE TABLE `transport_cost` (
5621   `frombranch` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
5622   `tobranch` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
5623   `cost` decimal(6,2) NOT NULL,
5624   `disable_transfer` tinyint(1) NOT NULL DEFAULT 0,
5625   PRIMARY KEY (`frombranch`,`tobranch`),
5626   KEY `transport_cost_ibfk_2` (`tobranch`),
5627   CONSTRAINT `transport_cost_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5628   CONSTRAINT `transport_cost_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5629 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5630 /*!40101 SET character_set_client = @saved_cs_client */;
5631
5632 --
5633 -- Table structure for table `uploaded_files`
5634 --
5635
5636 DROP TABLE IF EXISTS `uploaded_files`;
5637 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5638 /*!40101 SET character_set_client = utf8 */;
5639 CREATE TABLE `uploaded_files` (
5640   `id` int(11) NOT NULL AUTO_INCREMENT,
5641   `hashvalue` char(40) COLLATE utf8mb4_unicode_ci NOT NULL,
5642   `filename` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5643   `dir` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5644   `filesize` int(11) DEFAULT NULL,
5645   `dtcreated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
5646   `uploadcategorycode` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5647   `owner` int(11) DEFAULT NULL,
5648   `public` tinyint(4) DEFAULT NULL,
5649   `permanent` tinyint(4) DEFAULT NULL,
5650   PRIMARY KEY (`id`)
5651 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5652 /*!40101 SET character_set_client = @saved_cs_client */;
5653
5654 --
5655 -- Table structure for table `user_permissions`
5656 --
5657
5658 DROP TABLE IF EXISTS `user_permissions`;
5659 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5660 /*!40101 SET character_set_client = utf8 */;
5661 CREATE TABLE `user_permissions` (
5662   `borrowernumber` int(11) NOT NULL DEFAULT 0,
5663   `module_bit` int(11) NOT NULL DEFAULT 0,
5664   `code` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
5665   PRIMARY KEY (`borrowernumber`,`module_bit`,`code`),
5666   KEY `user_permissions_ibfk_1` (`borrowernumber`),
5667   KEY `user_permissions_ibfk_2` (`module_bit`,`code`),
5668   CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5669   CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`) REFERENCES `permissions` (`module_bit`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
5670 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5671 /*!40101 SET character_set_client = @saved_cs_client */;
5672
5673 --
5674 -- Table structure for table `userflags`
5675 --
5676
5677 DROP TABLE IF EXISTS `userflags`;
5678 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5679 /*!40101 SET character_set_client = utf8 */;
5680 CREATE TABLE `userflags` (
5681   `bit` int(11) NOT NULL DEFAULT 0,
5682   `flag` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5683   `flagdesc` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5684   `defaulton` int(11) DEFAULT NULL,
5685   PRIMARY KEY (`bit`)
5686 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5687 /*!40101 SET character_set_client = @saved_cs_client */;
5688
5689 --
5690 -- Table structure for table `vendor_edi_accounts`
5691 --
5692
5693 DROP TABLE IF EXISTS `vendor_edi_accounts`;
5694 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5695 /*!40101 SET character_set_client = utf8 */;
5696 CREATE TABLE `vendor_edi_accounts` (
5697   `id` int(11) NOT NULL AUTO_INCREMENT,
5698   `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
5699   `host` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5700   `username` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5701   `password` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5702   `last_activity` date DEFAULT NULL,
5703   `vendor_id` int(11) DEFAULT NULL,
5704   `download_directory` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5705   `upload_directory` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5706   `san` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
5707   `standard` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT 'EUR',
5708   `id_code_qualifier` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT '14',
5709   `transport` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT 'FTP',
5710   `quotes_enabled` tinyint(1) NOT NULL DEFAULT 0,
5711   `invoices_enabled` tinyint(1) NOT NULL DEFAULT 0,
5712   `orders_enabled` tinyint(1) NOT NULL DEFAULT 0,
5713   `responses_enabled` tinyint(1) NOT NULL DEFAULT 0,
5714   `auto_orders` tinyint(1) NOT NULL DEFAULT 0,
5715   `shipment_budget` int(11) DEFAULT NULL,
5716   `plugin` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
5717   PRIMARY KEY (`id`),
5718   KEY `vendorid` (`vendor_id`),
5719   KEY `shipmentbudget` (`shipment_budget`),
5720   CONSTRAINT `vfk_shipment_budget` FOREIGN KEY (`shipment_budget`) REFERENCES `aqbudgets` (`budget_id`),
5721   CONSTRAINT `vfk_vendor_id` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`)
5722 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5723 /*!40101 SET character_set_client = @saved_cs_client */;
5724
5725 --
5726 -- Table structure for table `virtualshelfcontents`
5727 --
5728
5729 DROP TABLE IF EXISTS `virtualshelfcontents`;
5730 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5731 /*!40101 SET character_set_client = utf8 */;
5732 CREATE TABLE `virtualshelfcontents` (
5733   `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',
5734   `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',
5735   `flags` int(11) DEFAULT NULL,
5736   `dateadded` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this bib record was added to the list',
5737   `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)',
5738   KEY `shelfnumber` (`shelfnumber`),
5739   KEY `biblionumber` (`biblionumber`),
5740   KEY `shelfcontents_ibfk_3` (`borrowernumber`),
5741   CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5742   CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5743   CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE
5744 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5745 /*!40101 SET character_set_client = @saved_cs_client */;
5746
5747 --
5748 -- Table structure for table `virtualshelfshares`
5749 --
5750
5751 DROP TABLE IF EXISTS `virtualshelfshares`;
5752 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5753 /*!40101 SET character_set_client = utf8 */;
5754 CREATE TABLE `virtualshelfshares` (
5755   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key',
5756   `shelfnumber` int(11) NOT NULL COMMENT 'foreign key for virtualshelves',
5757   `borrowernumber` int(11) DEFAULT NULL COMMENT 'borrower that accepted access to this list',
5758   `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',
5759   `sharedate` datetime DEFAULT NULL COMMENT 'date of invitation or acceptance of invitation',
5760   PRIMARY KEY (`id`),
5761   KEY `virtualshelfshares_ibfk_1` (`shelfnumber`),
5762   KEY `virtualshelfshares_ibfk_2` (`borrowernumber`),
5763   CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5764   CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL
5765 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5766 /*!40101 SET character_set_client = @saved_cs_client */;
5767
5768 --
5769 -- Table structure for table `virtualshelves`
5770 --
5771
5772 DROP TABLE IF EXISTS `virtualshelves`;
5773 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5774 /*!40101 SET character_set_client = utf8 */;
5775 CREATE TABLE `virtualshelves` (
5776   `shelfnumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5777   `shelfname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'name of the list',
5778   `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)',
5779   `public` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If the list is public',
5780   `sortfield` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT 'title' COMMENT 'the field this list is sorted on',
5781   `lastmodified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time the list was last modified',
5782   `created_on` datetime NOT NULL COMMENT 'creation time',
5783   `allow_change_from_owner` tinyint(1) DEFAULT 1 COMMENT 'can owner change contents?',
5784   `allow_change_from_others` tinyint(1) DEFAULT 0 COMMENT 'can others change contents?',
5785   `allow_change_from_staff` tinyint(1) DEFAULT 0 COMMENT 'can staff change contents?',
5786   PRIMARY KEY (`shelfnumber`),
5787   KEY `virtualshelves_ibfk_1` (`owner`),
5788   CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL
5789 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5790 /*!40101 SET character_set_client = @saved_cs_client */;
5791
5792 --
5793 -- Table structure for table `z3950servers`
5794 --
5795
5796 DROP TABLE IF EXISTS `z3950servers`;
5797 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5798 /*!40101 SET character_set_client = utf8 */;
5799 CREATE TABLE `z3950servers` (
5800   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
5801   `host` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'target''s host name',
5802   `port` int(11) DEFAULT NULL COMMENT 'port number used to connect to target',
5803   `db` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'target''s database name',
5804   `userid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'username needed to log in to target',
5805   `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'password needed to log in to target',
5806   `servername` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'name given to the target by the library',
5807   `checked` smallint(6) DEFAULT NULL COMMENT 'whether this target is checked by default  (1 for yes, 0 for no)',
5808   `rank` int(11) DEFAULT NULL COMMENT 'where this target appears in the list of targets',
5809   `syntax` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'MARC format provided by this target',
5810   `timeout` int(11) NOT NULL DEFAULT 0 COMMENT 'number of seconds before Koha stops trying to access this server',
5811   `servertype` enum('zed','sru') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'zed' COMMENT 'zed means z39.50 server',
5812   `encoding` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'characters encoding provided by this target',
5813   `recordtype` enum('authority','biblio') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'biblio' COMMENT 'server contains bibliographic or authority records',
5814   `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',
5815   `sru_fields` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'contains the mapping between the Z3950 search fields and the specific SRU server indexes',
5816   `add_xslt` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'zero or more paths to XSLT files to be processed on the search results',
5817   `attributes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'additional attributes passed to PQF queries',
5818   PRIMARY KEY (`id`)
5819 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5820 /*!40101 SET character_set_client = @saved_cs_client */;
5821
5822 --
5823 -- Table structure for table `zebraqueue`
5824 --
5825
5826 DROP TABLE IF EXISTS `zebraqueue`;
5827 /*!40101 SET @saved_cs_client     = @@character_set_client */;
5828 /*!40101 SET character_set_client = utf8 */;
5829 CREATE TABLE `zebraqueue` (
5830   `id` int(11) NOT NULL AUTO_INCREMENT,
5831   `biblio_auth_number` bigint(20) unsigned NOT NULL DEFAULT 0,
5832   `operation` char(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
5833   `server` char(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
5834   `done` int(11) NOT NULL DEFAULT 0,
5835   `time` timestamp NOT NULL DEFAULT current_timestamp(),
5836   PRIMARY KEY (`id`),
5837   KEY `zebraqueue_lookup` (`server`,`biblio_auth_number`,`operation`,`done`)
5838 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5839 /*!40101 SET character_set_client = @saved_cs_client */;
5840 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
5841
5842 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
5843 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
5844 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
5845 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
5846 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
5847 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
5848 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
5849
5850 -- Dump completed on 2022-05-26  2:46:01