]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/002.schema.config.sql
Upgrade to MODS 3.3 for ingest and ModsParser.pm; use an explicit format for config...
[working/Evergreen.git] / Open-ILS / src / sql / Pg / 002.schema.config.sql
1 /*
2  * Copyright (C) 2004-2008  Georgia Public Library Service
3  * Copyright (C) 2008  Equinox Software, Inc.
4  * Mike Rylander <miker@esilibrary.com>
5  *
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.
10  *
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.
15  *
16  */
17
18
19
20 DROP SCHEMA stats CASCADE;
21 DROP SCHEMA config CASCADE;
22
23 BEGIN;
24 CREATE SCHEMA stats;
25
26 CREATE SCHEMA config;
27 COMMENT ON SCHEMA config IS $$
28 /*
29  * Copyright (C) 2005  Georgia Public Library Service 
30  * Mike Rylander <mrylander@gmail.com>
31  *
32  * The config schema holds static configuration data for the
33  * Open-ILS installation.
34  *
35  * ****
36  *
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.
41  *
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.
46  */
47 $$;
48
49 CREATE TABLE config.upgrade_log (
50     version         TEXT    PRIMARY KEY,
51     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
52 );
53
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
59 );
60 COMMENT ON TABLE config.bib_source IS $$
61 /*
62  * Copyright (C) 2005  Georgia Public Library Service 
63  * Mike Rylander <mrylander@gmail.com>
64  *
65  * Valid sources of MARC records
66  *
67  * This is table is used to set up the relative "quality" of each
68  * MARC source, such as OCLC.
69  *
70  * ****
71  *
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.
76  *
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.
81  */
82 $$;
83
84 CREATE TABLE config.standing (
85         id              SERIAL  PRIMARY KEY,
86         value           TEXT    NOT NULL UNIQUE
87 );
88 COMMENT ON TABLE config.standing IS $$
89 /*
90  * Copyright (C) 2005  Georgia Public Library Service 
91  * Mike Rylander <mrylander@gmail.com>
92  *
93  * Patron Standings
94  *
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. :(
99  *
100  * ****
101  *
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.
106  *
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.
111  */
112 $$;
113
114 CREATE TABLE config.standing_penalty (
115         id              SERIAL  PRIMARY KEY,
116         name            TEXT    NOT NULL UNIQUE,
117         label           TEXT    NOT NULL,
118         block_list      TEXT
119 );
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 SELECT SETVAL('config.standing_penalty_id_seq', 100);
127
128 CREATE TABLE config.xml_transform (
129         name            TEXT    PRIMARY KEY,
130         namespace_uri   TEXT    NOT NULL,
131         prefix          TEXT    NOT NULL,
132         xslt            TEXT    NOT NULL
133 );
134
135 CREATE TABLE config.metabib_field (
136         id              SERIAL  PRIMARY KEY,
137         field_class     TEXT    NOT NULL CHECK (lower(field_class) IN ('title','author','subject','keyword','series')),
138         name            TEXT    NOT NULL,
139         xpath           TEXT    NOT NULL,
140         weight          INT     NOT NULL DEFAULT 1,
141         format          TEXT    NOT NULL DEFAULT 'mods33',
142         search_field    BOOL    NOT NULL DEFAULT TRUE,
143         facet_field     BOOL    NOT NULL DEFAULT FALSE
144 );
145 COMMENT ON TABLE config.metabib_field IS $$
146 /*
147  * Copyright (C) 2005  Georgia Public Library Service 
148  * Mike Rylander <mrylander@gmail.com>
149  *
150  * XPath used for record indexing ingest
151  *
152  * This table contains the XPath used to chop up MODS into its
153  * indexable parts.  Each XPath entry is named and assigned to
154  * a "class" of either title, subject, author, keyword or series.
155  * 
156  *
157  * ****
158  *
159  * This program is free software; you can redistribute it and/or
160  * modify it under the terms of the GNU General Public License
161  * as published by the Free Software Foundation; either version 2
162  * of the License, or (at your option) any later version.
163  *
164  * This program is distributed in the hope that it will be useful,
165  * but WITHOUT ANY WARRANTY; without even the implied warranty of
166  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
167  * GNU General Public License for more details.
168  */
169 $$;
170
171 CREATE UNIQUE INDEX config_metabib_field_class_name_idx ON config.metabib_field (field_class, name);
172
173 CREATE TABLE config.non_cataloged_type (
174         id              SERIAL          PRIMARY KEY,
175         owning_lib      INT             NOT NULL, -- REFERENCES actor.org_unit (id),
176         name            TEXT            NOT NULL,
177         circ_duration   INTERVAL        NOT NULL DEFAULT '14 days'::INTERVAL,
178         in_house        BOOL            NOT NULL DEFAULT FALSE,
179         CONSTRAINT noncat_once_per_lib UNIQUE (owning_lib,name)
180 );
181 COMMENT ON TABLE config.non_cataloged_type IS $$
182 /*
183  * Copyright (C) 2005  Georgia Public Library Service 
184  * Mike Rylander <mrylander@gmail.com>
185  *
186  * Types of valid non-cataloged items.
187  *
188  *
189  * ****
190  *
191  * This program is free software; you can redistribute it and/or
192  * modify it under the terms of the GNU General Public License
193  * as published by the Free Software Foundation; either version 2
194  * of the License, or (at your option) any later version.
195  *
196  * This program is distributed in the hope that it will be useful,
197  * but WITHOUT ANY WARRANTY; without even the implied warranty of
198  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
199  * GNU General Public License for more details.
200  */
201 $$;
202
203 CREATE TABLE config.identification_type (
204         id              SERIAL  PRIMARY KEY,
205         name            TEXT    NOT NULL UNIQUE
206 );
207 COMMENT ON TABLE config.identification_type IS $$
208 /*
209  * Copyright (C) 2005  Georgia Public Library Service 
210  * Mike Rylander <mrylander@gmail.com>
211  *
212  * Types of valid patron identification.
213  *
214  * Each patron must display at least one valid form of identification
215  * in order to get a library card.  This table lists those forms.
216  * 
217  *
218  * ****
219  *
220  * This program is free software; you can redistribute it and/or
221  * modify it under the terms of the GNU General Public License
222  * as published by the Free Software Foundation; either version 2
223  * of the License, or (at your option) any later version.
224  *
225  * This program is distributed in the hope that it will be useful,
226  * but WITHOUT ANY WARRANTY; without even the implied warranty of
227  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
228  * GNU General Public License for more details.
229  */
230 $$;
231
232 CREATE TABLE config.rule_circ_duration (
233         id              SERIAL          PRIMARY KEY,
234         name            TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
235         extended        INTERVAL        NOT NULL,
236         normal          INTERVAL        NOT NULL,
237         shrt            INTERVAL        NOT NULL,
238         max_renewals    INT             NOT NULL
239 );
240 COMMENT ON TABLE config.rule_circ_duration IS $$
241 /*
242  * Copyright (C) 2005  Georgia Public Library Service 
243  * Mike Rylander <mrylander@gmail.com>
244  *
245  * Circulation Duration rules
246  *
247  * Each circulation is given a duration based on one of these rules.
248  * 
249  *
250  * ****
251  *
252  * This program is free software; you can redistribute it and/or
253  * modify it under the terms of the GNU General Public License
254  * as published by the Free Software Foundation; either version 2
255  * of the License, or (at your option) any later version.
256  *
257  * This program is distributed in the hope that it will be useful,
258  * but WITHOUT ANY WARRANTY; without even the implied warranty of
259  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
260  * GNU General Public License for more details.
261  */
262 $$;
263
264 CREATE TABLE config.rule_max_fine (
265     id          SERIAL          PRIMARY KEY,
266     name        TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
267     amount      NUMERIC(6,2)    NOT NULL,
268     is_percent  BOOL            NOT NULL DEFAULT FALSE
269 );
270 COMMENT ON TABLE config.rule_max_fine IS $$
271 /*
272  * Copyright (C) 2005  Georgia Public Library Service 
273  * Mike Rylander <mrylander@gmail.com>
274  *
275  * Circulation Max Fine rules
276  *
277  * Each circulation is given a maximum fine based on one of
278  * these rules.
279  * 
280  *
281  * ****
282  *
283  * This program is free software; you can redistribute it and/or
284  * modify it under the terms of the GNU General Public License
285  * as published by the Free Software Foundation; either version 2
286  * of the License, or (at your option) any later version.
287  *
288  * This program is distributed in the hope that it will be useful,
289  * but WITHOUT ANY WARRANTY; without even the implied warranty of
290  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
291  * GNU General Public License for more details.
292  */
293 $$;
294
295 CREATE TABLE config.rule_recuring_fine (
296         id                      SERIAL          PRIMARY KEY,
297         name                    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
298         high                    NUMERIC(6,2)    NOT NULL,
299         normal                  NUMERIC(6,2)    NOT NULL,
300         low                     NUMERIC(6,2)    NOT NULL,
301         recurance_interval      INTERVAL        NOT NULL DEFAULT '1 day'::INTERVAL
302 );
303 COMMENT ON TABLE config.rule_recuring_fine IS $$
304 /*
305  * Copyright (C) 2005  Georgia Public Library Service 
306  * Mike Rylander <mrylander@gmail.com>
307  *
308  * Circulation Recurring Fine rules
309  *
310  * Each circulation is given a recurring fine amount based on one of
311  * these rules.  The recurance_interval should not be any shorter
312  * than the interval between runs of the fine_processor.pl script
313  * (which is run from CRON), or you could miss fines.
314  * 
315  *
316  * ****
317  *
318  * This program is free software; you can redistribute it and/or
319  * modify it under the terms of the GNU General Public License
320  * as published by the Free Software Foundation; either version 2
321  * of the License, or (at your option) any later version.
322  *
323  * This program is distributed in the hope that it will be useful,
324  * but WITHOUT ANY WARRANTY; without even the implied warranty of
325  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
326  * GNU General Public License for more details.
327  */
328 $$;
329
330
331 CREATE TABLE config.rule_age_hold_protect (
332         id      SERIAL          PRIMARY KEY,
333         name    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
334         age     INTERVAL        NOT NULL,
335         prox    INT             NOT NULL
336 );
337 COMMENT ON TABLE config.rule_age_hold_protect IS $$
338 /*
339  * Copyright (C) 2005  Georgia Public Library Service 
340  * Mike Rylander <mrylander@gmail.com>
341  *
342  * Hold Item Age Protection rules
343  *
344  * A hold request can only capture new(ish) items when they are
345  * within a particular proximity of the home_ou of the requesting
346  * user.  The proximity ('prox' column) is calculated by counting
347  * the number of tree edges between the user's home_ou and the owning_lib
348  * of the copy that could fulfill the hold.
349  * 
350  *
351  * ****
352  *
353  * This program is free software; you can redistribute it and/or
354  * modify it under the terms of the GNU General Public License
355  * as published by the Free Software Foundation; either version 2
356  * of the License, or (at your option) any later version.
357  *
358  * This program is distributed in the hope that it will be useful,
359  * but WITHOUT ANY WARRANTY; without even the implied warranty of
360  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
361  * GNU General Public License for more details.
362  */
363 $$;
364
365 CREATE TABLE config.copy_status (
366         id              SERIAL  PRIMARY KEY,
367         name            TEXT    NOT NULL UNIQUE,
368         holdable        BOOL    NOT NULL DEFAULT FALSE,
369         opac_visible    BOOL    NOT NULL DEFAULT FALSE
370 );
371 COMMENT ON TABLE config.copy_status IS $$
372 /*
373  * Copyright (C) 2005  Georgia Public Library Service 
374  * Mike Rylander <mrylander@gmail.com>
375  *
376  * Copy Statuses
377  *
378  * The available copy statuses, and whether a copy in that
379  * status is available for hold request capture.  0 (zero) is
380  * the only special number in this set, meaning that the item
381  * is available for immediate checkout, and is counted as available
382  * in the OPAC.
383  *
384  * Statuses with an ID below 100 are not removable, and have special
385  * meaning in the code.  Do not change them except to translate the
386  * textual name.
387  *
388  * You may add and remove statuses above 100, and these can be used
389  * to remove items from normal circulation without affecting the rest
390  * of the copy's values or its location.
391  *
392  * ****
393  *
394  * This program is free software; you can redistribute it and/or
395  * modify it under the terms of the GNU General Public License
396  * as published by the Free Software Foundation; either version 2
397  * of the License, or (at your option) any later version.
398  *
399  * This program is distributed in the hope that it will be useful,
400  * but WITHOUT ANY WARRANTY; without even the implied warranty of
401  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
402  * GNU General Public License for more details.
403  */
404 $$;
405
406 CREATE TABLE config.net_access_level (
407         id      SERIAL          PRIMARY KEY,
408         name    TEXT            NOT NULL UNIQUE
409 );
410 COMMENT ON TABLE config.net_access_level IS $$
411 /*
412  * Copyright (C) 2005  Georgia Public Library Service 
413  * Mike Rylander <mrylander@gmail.com>
414  *
415  * Patron Network Access level
416  *
417  * This will be used to inform the in-library firewall of how much
418  * internet access the using patron should be allowed.
419  *
420  * ****
421  *
422  * This program is free software; you can redistribute it and/or
423  * modify it under the terms of the GNU General Public License
424  * as published by the Free Software Foundation; either version 2
425  * of the License, or (at your option) any later version.
426  *
427  * This program is distributed in the hope that it will be useful,
428  * but WITHOUT ANY WARRANTY; without even the implied warranty of
429  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
430  * GNU General Public License for more details.
431  */
432 $$;
433
434 CREATE TABLE config.audience_map (
435         code            TEXT    PRIMARY KEY,
436         value           TEXT    NOT NULL,
437         description     TEXT
438 );
439
440 CREATE TABLE config.lit_form_map (
441         code            TEXT    PRIMARY KEY,
442         value           TEXT    NOT NULL,
443         description     TEXT
444 );
445
446 CREATE TABLE config.language_map (
447         code    TEXT    PRIMARY KEY,
448         value   TEXT    NOT NULL
449 );
450
451 CREATE TABLE config.item_form_map (
452         code    TEXT    PRIMARY KEY,
453         value   TEXT    NOT NULL
454 );
455
456 CREATE TABLE config.item_type_map (
457         code    TEXT    PRIMARY KEY,
458         value   TEXT    NOT NULL
459 );
460
461 CREATE TABLE config.bib_level_map (
462         code    TEXT    PRIMARY KEY,
463         value   TEXT    NOT NULL
464 );
465
466 CREATE TABLE config.z3950_source (
467     name                TEXT    PRIMARY KEY,
468     label               TEXT    NOT NULL UNIQUE,
469     host                TEXT    NOT NULL,
470     port                INT     NOT NULL,
471     db                  TEXT    NOT NULL,
472     record_format       TEXT    NOT NULL DEFAULT 'FI',
473     transmission_format TEXT    NOT NULL DEFAULT 'usmarc',
474     auth                BOOL    NOT NULL DEFAULT TRUE
475 );
476
477 CREATE TABLE config.z3950_attr (
478     id          SERIAL  PRIMARY KEY,
479     source      TEXT    NOT NULL REFERENCES config.z3950_source (name) DEFERRABLE INITIALLY DEFERRED,
480     name        TEXT    NOT NULL,
481     label       TEXT    NOT NULL,
482     code        INT     NOT NULL,
483     format      INT     NOT NULL,
484     truncation  INT     NOT NULL DEFAULT 0,
485     CONSTRAINT z_code_format_once_per_source UNIQUE (code,format,source)
486 );
487
488 CREATE TABLE config.i18n_locale (
489     code        TEXT    PRIMARY KEY,
490     marc_code   TEXT    NOT NULL REFERENCES config.language_map (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
491     name        TEXT    UNIQUE NOT NULL,
492     description TEXT
493 );
494
495 CREATE TABLE config.i18n_core (
496     id              BIGSERIAL   PRIMARY KEY,
497     fq_field        TEXT        NOT NULL,
498     identity_value  TEXT        NOT NULL,
499     translation     TEXT        NOT NULL    REFERENCES config.i18n_locale (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
500     string          TEXT        NOT NULL
501 );
502
503 CREATE UNIQUE INDEX i18n_identity ON config.i18n_core (fq_field,identity_value,translation);
504
505 CREATE TABLE config.billing_type (
506     id              SERIAL  PRIMARY KEY,
507     name            TEXT    NOT NULL,
508     owner           INT     NOT NULL, -- REFERENCES actor.org_unit (id)
509     default_price   NUMERIC(6,2),
510     CONSTRAINT billing_type_once_per_lib UNIQUE (name, owner)
511 );
512
513
514 COMMIT;
515