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