]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/002.schema.config.sql
0cb2053cbddbabf40e619deb786906501b4fbfa7
[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.bib_source (
50         id              SERIAL  PRIMARY KEY,
51         quality         INT     CHECK ( quality BETWEEN 0 AND 100 ),
52         source          TEXT    NOT NULL UNIQUE,
53         transcendant    BOOL    NOT NULL DEFAULT FALSE
54 );
55 COMMENT ON TABLE config.bib_source IS $$
56 /*
57  * Copyright (C) 2005  Georgia Public Library Service 
58  * Mike Rylander <mrylander@gmail.com>
59  *
60  * Valid sources of MARC records
61  *
62  * This is table is used to set up the relative "quality" of each
63  * MARC source, such as OCLC.
64  *
65  * ****
66  *
67  * This program is free software; you can redistribute it and/or
68  * modify it under the terms of the GNU General Public License
69  * as published by the Free Software Foundation; either version 2
70  * of the License, or (at your option) any later version.
71  *
72  * This program is distributed in the hope that it will be useful,
73  * but WITHOUT ANY WARRANTY; without even the implied warranty of
74  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
75  * GNU General Public License for more details.
76  */
77 $$;
78
79 CREATE TABLE config.standing (
80         id              SERIAL  PRIMARY KEY,
81         value           TEXT    NOT NULL UNIQUE
82 );
83 COMMENT ON TABLE config.standing IS $$
84 /*
85  * Copyright (C) 2005  Georgia Public Library Service 
86  * Mike Rylander <mrylander@gmail.com>
87  *
88  * Patron Standings
89  *
90  * This table contains the values that can be applied to a patron
91  * by a staff member.  These values should not be changed, other
92  * than for translation, as the ID column is currently a "magic
93  * number" in the source. :(
94  *
95  * ****
96  *
97  * This program is free software; you can redistribute it and/or
98  * modify it under the terms of the GNU General Public License
99  * as published by the Free Software Foundation; either version 2
100  * of the License, or (at your option) any later version.
101  *
102  * This program is distributed in the hope that it will be useful,
103  * but WITHOUT ANY WARRANTY; without even the implied warranty of
104  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
105  * GNU General Public License for more details.
106  */
107 $$;
108
109 CREATE TABLE config.xml_transform (
110         name            TEXT    PRIMARY KEY,
111         namespace_uri   TEXT    NOT NULL,
112         prefix          TEXT    NOT NULL,
113         xslt            TEXT    NOT NULL
114 );
115
116 CREATE TABLE config.metabib_field (
117         id              SERIAL  PRIMARY KEY,
118         field_class     TEXT    NOT NULL CHECK (lower(field_class) IN ('title','author','subject','keyword','series')),
119         name            TEXT    NOT NULL,
120         xpath           TEXT    NOT NULL,
121         weight          INT     NOT NULL DEFAULT 1,
122         format          TEXT    NOT NULL DEFAULT 'mods',
123         search_field    BOOL    NOT NULL DEFAULT TRUE,
124         facet_field     BOOL    NOT NULL DEFAULT FALSE
125 );
126 COMMENT ON TABLE config.metabib_field IS $$
127 /*
128  * Copyright (C) 2005  Georgia Public Library Service 
129  * Mike Rylander <mrylander@gmail.com>
130  *
131  * XPath used for record indexing ingest
132  *
133  * This table contains the XPath used to chop up MODS into its
134  * indexable parts.  Each XPath entry is named and assigned to
135  * a "class" of either title, subject, author, keyword or series.
136  * 
137  *
138  * ****
139  *
140  * This program is free software; you can redistribute it and/or
141  * modify it under the terms of the GNU General Public License
142  * as published by the Free Software Foundation; either version 2
143  * of the License, or (at your option) any later version.
144  *
145  * This program is distributed in the hope that it will be useful,
146  * but WITHOUT ANY WARRANTY; without even the implied warranty of
147  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
148  * GNU General Public License for more details.
149  */
150 $$;
151
152 CREATE UNIQUE INDEX config_metabib_field_class_name_idx ON config.metabib_field (field_class, name);
153
154 CREATE TABLE config.non_cataloged_type (
155         id              SERIAL          PRIMARY KEY,
156         owning_lib      INT             NOT NULL, -- REFERENCES actor.org_unit (id),
157         name            TEXT            NOT NULL,
158         circ_duration   INTERVAL        NOT NULL DEFAULT '14 days'::INTERVAL,
159         in_house        BOOL            NOT NULL DEFAULT FALSE,
160         CONSTRAINT noncat_once_per_lib UNIQUE (owning_lib,name)
161 );
162 COMMENT ON TABLE config.non_cataloged_type IS $$
163 /*
164  * Copyright (C) 2005  Georgia Public Library Service 
165  * Mike Rylander <mrylander@gmail.com>
166  *
167  * Types of valid non-cataloged items.
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 TABLE config.identification_type (
185         id              SERIAL  PRIMARY KEY,
186         name            TEXT    NOT NULL UNIQUE
187 );
188 COMMENT ON TABLE config.identification_type IS $$
189 /*
190  * Copyright (C) 2005  Georgia Public Library Service 
191  * Mike Rylander <mrylander@gmail.com>
192  *
193  * Types of valid patron identification.
194  *
195  * Each patron must display at least one valid form of identification
196  * in order to get a library card.  This table lists those forms.
197  * 
198  *
199  * ****
200  *
201  * This program is free software; you can redistribute it and/or
202  * modify it under the terms of the GNU General Public License
203  * as published by the Free Software Foundation; either version 2
204  * of the License, or (at your option) any later version.
205  *
206  * This program is distributed in the hope that it will be useful,
207  * but WITHOUT ANY WARRANTY; without even the implied warranty of
208  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
209  * GNU General Public License for more details.
210  */
211 $$;
212
213 CREATE TABLE config.rule_circ_duration (
214         id              SERIAL          PRIMARY KEY,
215         name            TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
216         extended        INTERVAL        NOT NULL,
217         normal          INTERVAL        NOT NULL,
218         shrt            INTERVAL        NOT NULL,
219         max_renewals    INT             NOT NULL
220 );
221 COMMENT ON TABLE config.rule_circ_duration IS $$
222 /*
223  * Copyright (C) 2005  Georgia Public Library Service 
224  * Mike Rylander <mrylander@gmail.com>
225  *
226  * Circulation Duration rules
227  *
228  * Each circulation is given a duration based on one of these rules.
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_max_fine (
246         id      SERIAL          PRIMARY KEY,
247         name    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
248         amount  NUMERIC(6,2)    NOT NULL
249 );
250 COMMENT ON TABLE config.rule_max_fine IS $$
251 /*
252  * Copyright (C) 2005  Georgia Public Library Service 
253  * Mike Rylander <mrylander@gmail.com>
254  *
255  * Circulation Max Fine rules
256  *
257  * Each circulation is given a maximum fine based on one of
258  * these rules.
259  * 
260  *
261  * ****
262  *
263  * This program is free software; you can redistribute it and/or
264  * modify it under the terms of the GNU General Public License
265  * as published by the Free Software Foundation; either version 2
266  * of the License, or (at your option) any later version.
267  *
268  * This program is distributed in the hope that it will be useful,
269  * but WITHOUT ANY WARRANTY; without even the implied warranty of
270  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
271  * GNU General Public License for more details.
272  */
273 $$;
274
275 CREATE TABLE config.rule_recuring_fine (
276         id                      SERIAL          PRIMARY KEY,
277         name                    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
278         high                    NUMERIC(6,2)    NOT NULL,
279         normal                  NUMERIC(6,2)    NOT NULL,
280         low                     NUMERIC(6,2)    NOT NULL,
281         recurance_interval      INTERVAL        NOT NULL DEFAULT '1 day'::INTERVAL
282 );
283 COMMENT ON TABLE config.rule_recuring_fine IS $$
284 /*
285  * Copyright (C) 2005  Georgia Public Library Service 
286  * Mike Rylander <mrylander@gmail.com>
287  *
288  * Circulation Recurring Fine rules
289  *
290  * Each circulation is given a recurring fine amount based on one of
291  * these rules.  The recurance_interval should not be any shorter
292  * than the interval between runs of the fine_processor.pl script
293  * (which is run from CRON), or you could miss fines.
294  * 
295  *
296  * ****
297  *
298  * This program is free software; you can redistribute it and/or
299  * modify it under the terms of the GNU General Public License
300  * as published by the Free Software Foundation; either version 2
301  * of the License, or (at your option) any later version.
302  *
303  * This program is distributed in the hope that it will be useful,
304  * but WITHOUT ANY WARRANTY; without even the implied warranty of
305  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
306  * GNU General Public License for more details.
307  */
308 $$;
309
310
311 CREATE TABLE config.rule_age_hold_protect (
312         id      SERIAL          PRIMARY KEY,
313         name    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
314         age     INTERVAL        NOT NULL,
315         prox    INT             NOT NULL
316 );
317 COMMENT ON TABLE config.rule_age_hold_protect IS $$
318 /*
319  * Copyright (C) 2005  Georgia Public Library Service 
320  * Mike Rylander <mrylander@gmail.com>
321  *
322  * Hold Item Age Protection rules
323  *
324  * A hold request can only capture new(ish) items when they are
325  * within a particular proximity of the home_ou of the requesting
326  * user.  The proximity ('prox' column) is calculated by counting
327  * the number of tree edges between the user's home_ou and the owning_lib
328  * of the copy that could fulfill the hold.
329  * 
330  *
331  * ****
332  *
333  * This program is free software; you can redistribute it and/or
334  * modify it under the terms of the GNU General Public License
335  * as published by the Free Software Foundation; either version 2
336  * of the License, or (at your option) any later version.
337  *
338  * This program is distributed in the hope that it will be useful,
339  * but WITHOUT ANY WARRANTY; without even the implied warranty of
340  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
341  * GNU General Public License for more details.
342  */
343 $$;
344
345 CREATE TABLE config.copy_status (
346         id              SERIAL  PRIMARY KEY,
347         name            TEXT    NOT NULL UNIQUE,
348         holdable        BOOL    NOT NULL DEFAULT FALSE,
349         opac_visible    BOOL    NOT NULL DEFAULT FALSE
350 );
351 COMMENT ON TABLE config.copy_status IS $$
352 /*
353  * Copyright (C) 2005  Georgia Public Library Service 
354  * Mike Rylander <mrylander@gmail.com>
355  *
356  * Copy Statuses
357  *
358  * The available copy statuses, and whether a copy in that
359  * status is available for hold request capture.  0 (zero) is
360  * the only special number in this set, meaning that the item
361  * is available for immediate checkout, and is counted as available
362  * in the OPAC.
363  *
364  * Statuses with an ID below 100 are not removable, and have special
365  * meaning in the code.  Do not change them except to translate the
366  * textual name.
367  *
368  * You may add and remove statuses above 100, and these can be used
369  * to remove items from normal circulation without affecting the rest
370  * of the copy's values or its location.
371  *
372  * ****
373  *
374  * This program is free software; you can redistribute it and/or
375  * modify it under the terms of the GNU General Public License
376  * as published by the Free Software Foundation; either version 2
377  * of the License, or (at your option) any later version.
378  *
379  * This program is distributed in the hope that it will be useful,
380  * but WITHOUT ANY WARRANTY; without even the implied warranty of
381  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
382  * GNU General Public License for more details.
383  */
384 $$;
385
386 CREATE TABLE config.net_access_level (
387         id      SERIAL          PRIMARY KEY,
388         name    TEXT            NOT NULL UNIQUE
389 );
390 COMMENT ON TABLE config.net_access_level IS $$
391 /*
392  * Copyright (C) 2005  Georgia Public Library Service 
393  * Mike Rylander <mrylander@gmail.com>
394  *
395  * Patron Network Access level
396  *
397  * This will be used to inform the in-library firewall of how much
398  * internet access the using patron should be allowed.
399  *
400  * ****
401  *
402  * This program is free software; you can redistribute it and/or
403  * modify it under the terms of the GNU General Public License
404  * as published by the Free Software Foundation; either version 2
405  * of the License, or (at your option) any later version.
406  *
407  * This program is distributed in the hope that it will be useful,
408  * but WITHOUT ANY WARRANTY; without even the implied warranty of
409  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
410  * GNU General Public License for more details.
411  */
412 $$;
413
414 CREATE TABLE config.audience_map (
415         code            TEXT    PRIMARY KEY,
416         value           TEXT    NOT NULL,
417         description     TEXT
418 );
419
420 CREATE TABLE config.lit_form_map (
421         code            TEXT    PRIMARY KEY,
422         value           TEXT    NOT NULL,
423         description     TEXT
424 );
425
426 CREATE TABLE config.language_map (
427         code    TEXT    PRIMARY KEY,
428         value   TEXT    NOT NULL
429 );
430
431 CREATE TABLE config.item_form_map (
432         code    TEXT    PRIMARY KEY,
433         value   TEXT    NOT NULL
434 );
435
436 CREATE TABLE config.item_type_map (
437         code    TEXT    PRIMARY KEY,
438         value   TEXT    NOT NULL
439 );
440
441 CREATE TABLE config.bib_level_map (
442         code    TEXT    PRIMARY KEY,
443         value   TEXT    NOT NULL
444 );
445
446 CREATE TABLE config.i18n_locale (
447     code        TEXT    PRIMARY KEY,
448     marc_code   TEXT    NOT NULL REFERENCES config.language_map (code),
449     name        TEXT    UNIQUE NOT NULL,
450     description TEXT
451 );
452
453 CREATE TABLE config.i18n_core (
454     id              BIGSERIAL   PRIMARY KEY,
455     fq_field        TEXT        NOT NULL,
456     identity_value  TEXT        NOT NULL,
457     translation     TEXT        NOT NULL    REFERENCES config.i18n_locale (code),
458     string          TEXT        NOT NULL
459 );
460
461 CREATE UNIQUE INDEX i18n_identity ON config.i18n_core (fq_field,identity_value,translation);
462
463 COMMIT;
464