2 * Copyright (C) 2004-2008 Georgia Public Library Service
3 * Copyright (C) 2008 Equinox Software, Inc.
4 * Mike Rylander <miker@esilibrary.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
20 DROP SCHEMA stats CASCADE;
21 DROP SCHEMA config CASCADE;
27 COMMENT ON SCHEMA config IS $$
29 * Copyright (C) 2005 Georgia Public Library Service
30 * Mike Rylander <mrylander@gmail.com>
32 * The config schema holds static configuration data for the
33 * Open-ILS installation.
37 * This program is free software; you can redistribute it and/or
38 * modify it under the terms of the GNU General Public License
39 * as published by the Free Software Foundation; either version 2
40 * of the License, or (at your option) any later version.
42 * This program is distributed in the hope that it will be useful,
43 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 * GNU General Public License for more details.
49 CREATE TABLE config.upgrade_log (
50 version TEXT PRIMARY KEY,
51 install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
54 CREATE TABLE config.bib_source (
55 id SERIAL PRIMARY KEY,
56 quality INT CHECK ( quality BETWEEN 0 AND 100 ),
57 source TEXT NOT NULL UNIQUE,
58 transcendant BOOL NOT NULL DEFAULT FALSE
60 COMMENT ON TABLE config.bib_source IS $$
62 * Copyright (C) 2005 Georgia Public Library Service
63 * Mike Rylander <mrylander@gmail.com>
65 * Valid sources of MARC records
67 * This is table is used to set up the relative "quality" of each
68 * MARC source, such as OCLC.
72 * This program is free software; you can redistribute it and/or
73 * modify it under the terms of the GNU General Public License
74 * as published by the Free Software Foundation; either version 2
75 * of the License, or (at your option) any later version.
77 * This program is distributed in the hope that it will be useful,
78 * but WITHOUT ANY WARRANTY; without even the implied warranty of
79 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80 * GNU General Public License for more details.
84 CREATE TABLE config.standing (
85 id SERIAL PRIMARY KEY,
86 value TEXT NOT NULL UNIQUE
88 COMMENT ON TABLE config.standing IS $$
90 * Copyright (C) 2005 Georgia Public Library Service
91 * Mike Rylander <mrylander@gmail.com>
95 * This table contains the values that can be applied to a patron
96 * by a staff member. These values should not be changed, other
97 * than for translation, as the ID column is currently a "magic
98 * number" in the source. :(
102 * This program is free software; you can redistribute it and/or
103 * modify it under the terms of the GNU General Public License
104 * as published by the Free Software Foundation; either version 2
105 * of the License, or (at your option) any later version.
107 * This program is distributed in the hope that it will be useful,
108 * but WITHOUT ANY WARRANTY; without even the implied warranty of
109 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110 * GNU General Public License for more details.
114 CREATE TABLE config.standing_penalty (
115 id SERIAL PRIMARY KEY,
116 name TEXT NOT NULL UNIQUE,
120 INSERT INTO config.standing_penalty (id,name,label,block_list)
121 VALUES (1,'PATRON_EXCEEDS_FINES','Patron exceeds fine threshold','CIRC|HOLD|RENEW');
122 INSERT INTO config.standing_penalty (id,name,label,block_list)
123 VALUES (2,'PATRON_EXCEEDS_OVERDUE_COUNT','Patron exceeds max overdue item threshold','CIRC|HOLD|RENEW');
124 INSERT INTO config.standing_penalty (id,name,label,block_list)
125 VALUES (3,'PATRON_EXCEEDS_CHECKOUT_COUNT','Patron exceeds max checked out item threshold','CIRC');
126 INSERT INTO config.standing_penalty (id,name,label,block_list)
127 VALUES (4,'PATRON_EXCEEDS_COLLECTIONS_WARNING','Patron exceeds pre-collections warning fine threshold','CIRC|HOLD|RENEW');
129 INSERT INTO config.standing_penalty (id,name,label) VALUES (20,'ALERT_NOTE','Alerting Note, no blocks');
130 INSERT INTO config.standing_penalty (id,name,label) VALUES (21,'SILENT_NOTE','Note, no blocks');
131 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (22,'STAFF_C','Alerting block on Circ','CIRC');
132 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (23,'STAFF_CH','Alerting block on Circ and Hold','CIRC|HOLD');
133 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (24,'STAFF_CR','Alerting block on Circ and Renew','CIRC|RENEW');
134 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (25,'STAFF_CHR','Alerting block on Circ, Hold and Renew','CIRC|HOLD|RENEW');
135 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (26,'STAFF_HR','Alerting block on Hold and Renew','HOLD|RENEW');
136 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (27,'STAFF_H','Alerting block on Hold','HOLD');
137 INSERT INTO config.standing_penalty (id,name,label,block_list) VALUES (28,'STAFF_R','Alerting block on Renew','RENEW');
138 INSERT INTO config.standing_penalty (id,name,label) VALUES (29,'INVALID_PATRON_ADDRESS','Patron has an invalid address');
140 SELECT SETVAL('config.standing_penalty_id_seq', 100);
142 CREATE TABLE config.xml_transform (
143 name TEXT PRIMARY KEY,
144 namespace_uri TEXT NOT NULL,
145 prefix TEXT NOT NULL,
149 CREATE TABLE config.metabib_field (
150 id SERIAL PRIMARY KEY,
151 field_class TEXT NOT NULL CHECK (lower(field_class) IN ('title','author','subject','keyword','series')),
154 weight INT NOT NULL DEFAULT 1,
155 format TEXT NOT NULL DEFAULT 'mods33',
156 search_field BOOL NOT NULL DEFAULT TRUE,
157 facet_field BOOL NOT NULL DEFAULT FALSE
159 COMMENT ON TABLE config.metabib_field IS $$
161 * Copyright (C) 2005 Georgia Public Library Service
162 * Mike Rylander <mrylander@gmail.com>
164 * XPath used for record indexing ingest
166 * This table contains the XPath used to chop up MODS into its
167 * indexable parts. Each XPath entry is named and assigned to
168 * a "class" of either title, subject, author, keyword or series.
173 * This program is free software; you can redistribute it and/or
174 * modify it under the terms of the GNU General Public License
175 * as published by the Free Software Foundation; either version 2
176 * of the License, or (at your option) any later version.
178 * This program is distributed in the hope that it will be useful,
179 * but WITHOUT ANY WARRANTY; without even the implied warranty of
180 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181 * GNU General Public License for more details.
185 CREATE UNIQUE INDEX config_metabib_field_class_name_idx ON config.metabib_field (field_class, name);
187 CREATE TABLE config.non_cataloged_type (
188 id SERIAL PRIMARY KEY,
189 owning_lib INT NOT NULL, -- REFERENCES actor.org_unit (id),
191 circ_duration INTERVAL NOT NULL DEFAULT '14 days'::INTERVAL,
192 in_house BOOL NOT NULL DEFAULT FALSE,
193 CONSTRAINT noncat_once_per_lib UNIQUE (owning_lib,name)
195 COMMENT ON TABLE config.non_cataloged_type IS $$
197 * Copyright (C) 2005 Georgia Public Library Service
198 * Mike Rylander <mrylander@gmail.com>
200 * Types of valid non-cataloged items.
205 * This program is free software; you can redistribute it and/or
206 * modify it under the terms of the GNU General Public License
207 * as published by the Free Software Foundation; either version 2
208 * of the License, or (at your option) any later version.
210 * This program is distributed in the hope that it will be useful,
211 * but WITHOUT ANY WARRANTY; without even the implied warranty of
212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
213 * GNU General Public License for more details.
217 CREATE TABLE config.identification_type (
218 id SERIAL PRIMARY KEY,
219 name TEXT NOT NULL UNIQUE
221 COMMENT ON TABLE config.identification_type IS $$
223 * Copyright (C) 2005 Georgia Public Library Service
224 * Mike Rylander <mrylander@gmail.com>
226 * Types of valid patron identification.
228 * Each patron must display at least one valid form of identification
229 * in order to get a library card. This table lists those forms.
234 * This program is free software; you can redistribute it and/or
235 * modify it under the terms of the GNU General Public License
236 * as published by the Free Software Foundation; either version 2
237 * of the License, or (at your option) any later version.
239 * This program is distributed in the hope that it will be useful,
240 * but WITHOUT ANY WARRANTY; without even the implied warranty of
241 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
242 * GNU General Public License for more details.
246 CREATE TABLE config.rule_circ_duration (
247 id SERIAL PRIMARY KEY,
248 name TEXT NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
249 extended INTERVAL NOT NULL,
250 normal INTERVAL NOT NULL,
251 shrt INTERVAL NOT NULL,
252 max_renewals INT NOT NULL
254 COMMENT ON TABLE config.rule_circ_duration IS $$
256 * Copyright (C) 2005 Georgia Public Library Service
257 * Mike Rylander <mrylander@gmail.com>
259 * Circulation Duration rules
261 * Each circulation is given a duration based on one of these rules.
266 * This program is free software; you can redistribute it and/or
267 * modify it under the terms of the GNU General Public License
268 * as published by the Free Software Foundation; either version 2
269 * of the License, or (at your option) any later version.
271 * This program is distributed in the hope that it will be useful,
272 * but WITHOUT ANY WARRANTY; without even the implied warranty of
273 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
274 * GNU General Public License for more details.
278 CREATE TABLE config.rule_max_fine (
279 id SERIAL PRIMARY KEY,
280 name TEXT NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
281 amount NUMERIC(6,2) NOT NULL,
282 is_percent BOOL NOT NULL DEFAULT FALSE
284 COMMENT ON TABLE config.rule_max_fine IS $$
286 * Copyright (C) 2005 Georgia Public Library Service
287 * Mike Rylander <mrylander@gmail.com>
289 * Circulation Max Fine rules
291 * Each circulation is given a maximum fine based on one of
297 * This program is free software; you can redistribute it and/or
298 * modify it under the terms of the GNU General Public License
299 * as published by the Free Software Foundation; either version 2
300 * of the License, or (at your option) any later version.
302 * This program is distributed in the hope that it will be useful,
303 * but WITHOUT ANY WARRANTY; without even the implied warranty of
304 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
305 * GNU General Public License for more details.
309 CREATE TABLE config.rule_recuring_fine (
310 id SERIAL PRIMARY KEY,
311 name TEXT NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
312 high NUMERIC(6,2) NOT NULL,
313 normal NUMERIC(6,2) NOT NULL,
314 low NUMERIC(6,2) NOT NULL,
315 recurance_interval INTERVAL NOT NULL DEFAULT '1 day'::INTERVAL
317 COMMENT ON TABLE config.rule_recuring_fine IS $$
319 * Copyright (C) 2005 Georgia Public Library Service
320 * Mike Rylander <mrylander@gmail.com>
322 * Circulation Recurring Fine rules
324 * Each circulation is given a recurring fine amount based on one of
325 * these rules. The recurance_interval should not be any shorter
326 * than the interval between runs of the fine_processor.pl script
327 * (which is run from CRON), or you could miss fines.
332 * This program is free software; you can redistribute it and/or
333 * modify it under the terms of the GNU General Public License
334 * as published by the Free Software Foundation; either version 2
335 * of the License, or (at your option) any later version.
337 * This program is distributed in the hope that it will be useful,
338 * but WITHOUT ANY WARRANTY; without even the implied warranty of
339 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
340 * GNU General Public License for more details.
345 CREATE TABLE config.rule_age_hold_protect (
346 id SERIAL PRIMARY KEY,
347 name TEXT NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
348 age INTERVAL NOT NULL,
351 COMMENT ON TABLE config.rule_age_hold_protect IS $$
353 * Copyright (C) 2005 Georgia Public Library Service
354 * Mike Rylander <mrylander@gmail.com>
356 * Hold Item Age Protection rules
358 * A hold request can only capture new(ish) items when they are
359 * within a particular proximity of the home_ou of the requesting
360 * user. The proximity ('prox' column) is calculated by counting
361 * the number of tree edges between the user's home_ou and the owning_lib
362 * of the copy that could fulfill the hold.
367 * This program is free software; you can redistribute it and/or
368 * modify it under the terms of the GNU General Public License
369 * as published by the Free Software Foundation; either version 2
370 * of the License, or (at your option) any later version.
372 * This program is distributed in the hope that it will be useful,
373 * but WITHOUT ANY WARRANTY; without even the implied warranty of
374 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
375 * GNU General Public License for more details.
379 CREATE TABLE config.copy_status (
380 id SERIAL PRIMARY KEY,
381 name TEXT NOT NULL UNIQUE,
382 holdable BOOL NOT NULL DEFAULT FALSE,
383 opac_visible BOOL NOT NULL DEFAULT FALSE
385 COMMENT ON TABLE config.copy_status IS $$
387 * Copyright (C) 2005 Georgia Public Library Service
388 * Mike Rylander <mrylander@gmail.com>
392 * The available copy statuses, and whether a copy in that
393 * status is available for hold request capture. 0 (zero) is
394 * the only special number in this set, meaning that the item
395 * is available for immediate checkout, and is counted as available
398 * Statuses with an ID below 100 are not removable, and have special
399 * meaning in the code. Do not change them except to translate the
402 * You may add and remove statuses above 100, and these can be used
403 * to remove items from normal circulation without affecting the rest
404 * of the copy's values or its location.
408 * This program is free software; you can redistribute it and/or
409 * modify it under the terms of the GNU General Public License
410 * as published by the Free Software Foundation; either version 2
411 * of the License, or (at your option) any later version.
413 * This program is distributed in the hope that it will be useful,
414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
415 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
416 * GNU General Public License for more details.
420 CREATE TABLE config.net_access_level (
421 id SERIAL PRIMARY KEY,
422 name TEXT NOT NULL UNIQUE
424 COMMENT ON TABLE config.net_access_level IS $$
426 * Copyright (C) 2005 Georgia Public Library Service
427 * Mike Rylander <mrylander@gmail.com>
429 * Patron Network Access level
431 * This will be used to inform the in-library firewall of how much
432 * internet access the using patron should be allowed.
436 * This program is free software; you can redistribute it and/or
437 * modify it under the terms of the GNU General Public License
438 * as published by the Free Software Foundation; either version 2
439 * of the License, or (at your option) any later version.
441 * This program is distributed in the hope that it will be useful,
442 * but WITHOUT ANY WARRANTY; without even the implied warranty of
443 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
444 * GNU General Public License for more details.
448 CREATE TABLE config.audience_map (
449 code TEXT PRIMARY KEY,
454 CREATE TABLE config.lit_form_map (
455 code TEXT PRIMARY KEY,
460 CREATE TABLE config.language_map (
461 code TEXT PRIMARY KEY,
465 CREATE TABLE config.item_form_map (
466 code TEXT PRIMARY KEY,
470 CREATE TABLE config.item_type_map (
471 code TEXT PRIMARY KEY,
475 CREATE TABLE config.bib_level_map (
476 code TEXT PRIMARY KEY,
480 CREATE TABLE config.z3950_source (
481 name TEXT PRIMARY KEY,
482 label TEXT NOT NULL UNIQUE,
486 record_format TEXT NOT NULL DEFAULT 'FI',
487 transmission_format TEXT NOT NULL DEFAULT 'usmarc',
488 auth BOOL NOT NULL DEFAULT TRUE
491 CREATE TABLE config.z3950_attr (
492 id SERIAL PRIMARY KEY,
493 source TEXT NOT NULL REFERENCES config.z3950_source (name) DEFERRABLE INITIALLY DEFERRED,
498 truncation INT NOT NULL DEFAULT 0,
499 CONSTRAINT z_code_format_once_per_source UNIQUE (code,format,source)
502 CREATE TABLE config.i18n_locale (
503 code TEXT PRIMARY KEY,
504 marc_code TEXT NOT NULL REFERENCES config.language_map (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
505 name TEXT UNIQUE NOT NULL,
509 CREATE TABLE config.i18n_core (
510 id BIGSERIAL PRIMARY KEY,
511 fq_field TEXT NOT NULL,
512 identity_value TEXT NOT NULL,
513 translation TEXT NOT NULL REFERENCES config.i18n_locale (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
517 CREATE UNIQUE INDEX i18n_identity ON config.i18n_core (fq_field,identity_value,translation);
519 CREATE TABLE config.billing_type (
520 id SERIAL PRIMARY KEY,
522 owner INT NOT NULL, -- REFERENCES actor.org_unit (id)
523 default_price NUMERIC(6,2),
524 CONSTRAINT billing_type_once_per_lib UNIQUE (name, owner)
527 CREATE TABLE config.org_unit_setting_type (
528 name TEXT PRIMARY KEY,
529 label TEXT UNIQUE NOT NULL,
531 datatype TEXT NOT NULL DEFAULT 'string',
534 -- define valid datatypes
536 CONSTRAINT coust_valid_datatype CHECK ( datatype IN
537 ( 'bool', 'integer', 'float', 'currency', 'interval',
538 'date', 'string', 'object', 'array', 'link' ) ),
540 -- fm_class is meaningful only for 'link' datatype
542 CONSTRAINT coust_no_empty_link CHECK
543 ( ( datatype = 'link' AND fm_class IS NOT NULL ) OR
544 ( datatype <> 'link' AND fm_class IS NULL ) )