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