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