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