]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/002.schema.config.sql
i18n-ize the default in-db Z39.50 servers (and fix a missing column value for OCLC...
[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 'mods32',
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     is_percent  BOOL            NOT NULL DEFAULT FALSE
250 );
251 COMMENT ON TABLE config.rule_max_fine IS $$
252 /*
253  * Copyright (C) 2005  Georgia Public Library Service 
254  * Mike Rylander <mrylander@gmail.com>
255  *
256  * Circulation Max Fine rules
257  *
258  * Each circulation is given a maximum fine based on one of
259  * these rules.
260  * 
261  *
262  * ****
263  *
264  * This program is free software; you can redistribute it and/or
265  * modify it under the terms of the GNU General Public License
266  * as published by the Free Software Foundation; either version 2
267  * of the License, or (at your option) any later version.
268  *
269  * This program is distributed in the hope that it will be useful,
270  * but WITHOUT ANY WARRANTY; without even the implied warranty of
271  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
272  * GNU General Public License for more details.
273  */
274 $$;
275
276 CREATE TABLE config.rule_recuring_fine (
277         id                      SERIAL          PRIMARY KEY,
278         name                    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
279         high                    NUMERIC(6,2)    NOT NULL,
280         normal                  NUMERIC(6,2)    NOT NULL,
281         low                     NUMERIC(6,2)    NOT NULL,
282         recurance_interval      INTERVAL        NOT NULL DEFAULT '1 day'::INTERVAL
283 );
284 COMMENT ON TABLE config.rule_recuring_fine IS $$
285 /*
286  * Copyright (C) 2005  Georgia Public Library Service 
287  * Mike Rylander <mrylander@gmail.com>
288  *
289  * Circulation Recurring Fine rules
290  *
291  * Each circulation is given a recurring fine amount based on one of
292  * these rules.  The recurance_interval should not be any shorter
293  * than the interval between runs of the fine_processor.pl script
294  * (which is run from CRON), or you could miss fines.
295  * 
296  *
297  * ****
298  *
299  * This program is free software; you can redistribute it and/or
300  * modify it under the terms of the GNU General Public License
301  * as published by the Free Software Foundation; either version 2
302  * of the License, or (at your option) any later version.
303  *
304  * This program is distributed in the hope that it will be useful,
305  * but WITHOUT ANY WARRANTY; without even the implied warranty of
306  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
307  * GNU General Public License for more details.
308  */
309 $$;
310
311
312 CREATE TABLE config.rule_age_hold_protect (
313         id      SERIAL          PRIMARY KEY,
314         name    TEXT            NOT NULL UNIQUE CHECK ( name ~ E'^\\w+$' ),
315         age     INTERVAL        NOT NULL,
316         prox    INT             NOT NULL
317 );
318 COMMENT ON TABLE config.rule_age_hold_protect IS $$
319 /*
320  * Copyright (C) 2005  Georgia Public Library Service 
321  * Mike Rylander <mrylander@gmail.com>
322  *
323  * Hold Item Age Protection rules
324  *
325  * A hold request can only capture new(ish) items when they are
326  * within a particular proximity of the home_ou of the requesting
327  * user.  The proximity ('prox' column) is calculated by counting
328  * the number of tree edges between the user's home_ou and the owning_lib
329  * of the copy that could fulfill the hold.
330  * 
331  *
332  * ****
333  *
334  * This program is free software; you can redistribute it and/or
335  * modify it under the terms of the GNU General Public License
336  * as published by the Free Software Foundation; either version 2
337  * of the License, or (at your option) any later version.
338  *
339  * This program is distributed in the hope that it will be useful,
340  * but WITHOUT ANY WARRANTY; without even the implied warranty of
341  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
342  * GNU General Public License for more details.
343  */
344 $$;
345
346 CREATE TABLE config.copy_status (
347         id              SERIAL  PRIMARY KEY,
348         name            TEXT    NOT NULL UNIQUE,
349         holdable        BOOL    NOT NULL DEFAULT FALSE,
350         opac_visible    BOOL    NOT NULL DEFAULT FALSE
351 );
352 COMMENT ON TABLE config.copy_status IS $$
353 /*
354  * Copyright (C) 2005  Georgia Public Library Service 
355  * Mike Rylander <mrylander@gmail.com>
356  *
357  * Copy Statuses
358  *
359  * The available copy statuses, and whether a copy in that
360  * status is available for hold request capture.  0 (zero) is
361  * the only special number in this set, meaning that the item
362  * is available for immediate checkout, and is counted as available
363  * in the OPAC.
364  *
365  * Statuses with an ID below 100 are not removable, and have special
366  * meaning in the code.  Do not change them except to translate the
367  * textual name.
368  *
369  * You may add and remove statuses above 100, and these can be used
370  * to remove items from normal circulation without affecting the rest
371  * of the copy's values or its location.
372  *
373  * ****
374  *
375  * This program is free software; you can redistribute it and/or
376  * modify it under the terms of the GNU General Public License
377  * as published by the Free Software Foundation; either version 2
378  * of the License, or (at your option) any later version.
379  *
380  * This program is distributed in the hope that it will be useful,
381  * but WITHOUT ANY WARRANTY; without even the implied warranty of
382  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
383  * GNU General Public License for more details.
384  */
385 $$;
386
387 CREATE TABLE config.net_access_level (
388         id      SERIAL          PRIMARY KEY,
389         name    TEXT            NOT NULL UNIQUE
390 );
391 COMMENT ON TABLE config.net_access_level IS $$
392 /*
393  * Copyright (C) 2005  Georgia Public Library Service 
394  * Mike Rylander <mrylander@gmail.com>
395  *
396  * Patron Network Access level
397  *
398  * This will be used to inform the in-library firewall of how much
399  * internet access the using patron should be allowed.
400  *
401  * ****
402  *
403  * This program is free software; you can redistribute it and/or
404  * modify it under the terms of the GNU General Public License
405  * as published by the Free Software Foundation; either version 2
406  * of the License, or (at your option) any later version.
407  *
408  * This program is distributed in the hope that it will be useful,
409  * but WITHOUT ANY WARRANTY; without even the implied warranty of
410  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
411  * GNU General Public License for more details.
412  */
413 $$;
414
415 CREATE TABLE config.audience_map (
416         code            TEXT    PRIMARY KEY,
417         value           TEXT    NOT NULL,
418         description     TEXT
419 );
420
421 CREATE TABLE config.lit_form_map (
422         code            TEXT    PRIMARY KEY,
423         value           TEXT    NOT NULL,
424         description     TEXT
425 );
426
427 CREATE TABLE config.language_map (
428         code    TEXT    PRIMARY KEY,
429         value   TEXT    NOT NULL
430 );
431
432 CREATE TABLE config.item_form_map (
433         code    TEXT    PRIMARY KEY,
434         value   TEXT    NOT NULL
435 );
436
437 CREATE TABLE config.item_type_map (
438         code    TEXT    PRIMARY KEY,
439         value   TEXT    NOT NULL
440 );
441
442 CREATE TABLE config.bib_level_map (
443         code    TEXT    PRIMARY KEY,
444         value   TEXT    NOT NULL
445 );
446
447 CREATE TABLE config.z3950_source (
448     name                TEXT    PRIMARY KEY,
449     label               TEXT    NOT NULL UNIQUE,
450     host                TEXT    NOT NULL,
451     port                INT     NOT NULL,
452     db                  TEXT    NOT NULL,
453     record_format       TEXT    NOT NULL DEFAULT 'FI',
454     transmission_format TEXT    NOT NULL DEFAULT 'usmarc',
455     auth                BOOL    NOT NULL DEFAULT TRUE
456 );
457
458 CREATE TABLE config.z3950_attr (
459     id          SERIAL  PRIMARY KEY,
460     source      TEXT    NOT NULL REFERENCES config.z3950_source (name),
461     name        TEXT    NOT NULL,
462     label       TEXT    NOT NULL,
463     code        INT     NOT NULL,
464     format      INT     NOT NULL,
465     truncation  INT     NOT NULL DEFAULT 0,
466     CONSTRAINT z_code_format_once_per_source UNIQUE (code,format,source)
467 );
468
469 CREATE TABLE config.i18n_locale (
470     code        TEXT    PRIMARY KEY,
471     marc_code   TEXT    NOT NULL REFERENCES config.language_map (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
472     name        TEXT    UNIQUE NOT NULL,
473     description TEXT
474 );
475
476 CREATE TABLE config.i18n_core (
477     id              BIGSERIAL   PRIMARY KEY,
478     fq_field        TEXT        NOT NULL,
479     identity_value  TEXT        NOT NULL,
480     translation     TEXT        NOT NULL    REFERENCES config.i18n_locale (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
481     string          TEXT        NOT NULL
482 );
483
484 CREATE UNIQUE INDEX i18n_identity ON config.i18n_core (fq_field,identity_value,translation);
485
486 COMMIT;
487