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