]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/002.schema.config.sql
reporter stuff
[Evergreen.git] / Open-ILS / src / sql / Pg / 002.schema.config.sql
1
2 DROP SCHEMA stats CASCADE;
3 DROP SCHEMA config CASCADE;
4
5 BEGIN;
6 CREATE SCHEMA stats;
7
8 CREATE SCHEMA config;
9 COMMENT ON SCHEMA config IS $$
10 /*
11  * Copyright (C) 2005  Georgia Public Library Service 
12  * Mike Rylander <mrylander@gmail.com>
13  *
14  * The config schema holds static configuration data for the
15  * Open-ILS installation.
16  *
17  * ****
18  *
19  * This program is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU General Public License
21  * as published by the Free Software Foundation; either version 2
22  * of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  */
29 $$;
30
31
32 CREATE TABLE config.bib_source (
33         id      SERIAL  PRIMARY KEY,
34         quality INT     CHECK ( quality BETWEEN 0 AND 100 ),
35         source  TEXT    NOT NULL UNIQUE
36 );
37 COMMENT ON TABLE config.bib_source IS $$
38 /*
39  * Copyright (C) 2005  Georgia Public Library Service 
40  * Mike Rylander <mrylander@gmail.com>
41  *
42  * Valid sources of MARC records
43  *
44  * This is table is used to set up the relative "quality" of each
45  * MARC source, such as OCLC.
46  *
47  * ****
48  *
49  * This program is free software; you can redistribute it and/or
50  * modify it under the terms of the GNU General Public License
51  * as published by the Free Software Foundation; either version 2
52  * of the License, or (at your option) any later version.
53  *
54  * This program is distributed in the hope that it will be useful,
55  * but WITHOUT ANY WARRANTY; without even the implied warranty of
56  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57  * GNU General Public License for more details.
58  */
59 $$;
60
61
62 INSERT INTO config.bib_source (quality, source) VALUES (90, 'OcLC');
63 INSERT INTO config.bib_source (quality, source) VALUES (10, 'System Local');
64
65 CREATE TABLE config.standing (
66         id              SERIAL  PRIMARY KEY,
67         value           TEXT    NOT NULL UNIQUE
68 );
69 COMMENT ON TABLE config.standing IS $$
70 /*
71  * Copyright (C) 2005  Georgia Public Library Service 
72  * Mike Rylander <mrylander@gmail.com>
73  *
74  * Patron Standings
75  *
76  * This table contains the values that can be applied to a patron
77  * by a staff member.  These values should not be changed, other
78  * that for translation, as the ID column is currently a "magic
79  * number" in the source. :(
80  *
81  * ****
82  *
83  * This program is free software; you can redistribute it and/or
84  * modify it under the terms of the GNU General Public License
85  * as published by the Free Software Foundation; either version 2
86  * of the License, or (at your option) any later version.
87  *
88  * This program is distributed in the hope that it will be useful,
89  * but WITHOUT ANY WARRANTY; without even the implied warranty of
90  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91  * GNU General Public License for more details.
92  */
93 $$;
94
95 INSERT INTO config.standing (value) VALUES ('Good');
96 INSERT INTO config.standing (value) VALUES ('Barred');
97
98
99
100 CREATE TABLE config.metabib_field (
101         id              SERIAL  PRIMARY KEY,
102         field_class     TEXT    NOT NULL CHECK (lower(field_class) IN ('title','author','subject','keyword','series')),
103         name            TEXT    NOT NULL UNIQUE,
104         xpath           TEXT    NOT NULL
105 );
106 COMMENT ON TABLE config.metabib_field IS $$
107 /*
108  * Copyright (C) 2005  Georgia Public Library Service 
109  * Mike Rylander <mrylander@gmail.com>
110  *
111  * XPath used for WoRMing
112  *
113  * This table contains the XPath used to chop up MODS into it's
114  * indexable parts.  Each XPath entry is named and assigned to
115  * a "class" of either title, subject, author, keyword or series.
116  * 
117  *
118  * ****
119  *
120  * This program is free software; you can redistribute it and/or
121  * modify it under the terms of the GNU General Public License
122  * as published by the Free Software Foundation; either version 2
123  * of the License, or (at your option) any later version.
124  *
125  * This program is distributed in the hope that it will be useful,
126  * but WITHOUT ANY WARRANTY; without even the implied warranty of
127  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
128  * GNU General Public License for more details.
129  */
130 $$;
131
132
133 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'series', 'seriestitle', $$//mods:mods/mods:relatedItem[@type="series"]/mods:titleInfo$$ );
134 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'title', 'abbreviated', $$//mods:mods/mods:titleInfo[mods:title and (@type='abreviated')]$$ );
135 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'title', 'translated', $$//mods:mods/mods:titleInfo[mods:title and (@type='translated')]$$ );
136 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'title', 'uniform', $$//mods:mods/mods:titleInfo[mods:title and (@type='uniform')]$$ );
137 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'title', 'proper', $$//mods:mods/mods:titleInfo[mods:title and not (@type)]$$ );
138 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'author', 'corporate', $$//mods:mods/mods:name[@type='corporate']/mods:namePart[../mods:role/mods:text[text()='creator']]$$ );
139 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'author', 'personal', $$//mods:mods/mods:name[@type='personal']/mods:namePart[../mods:role/mods:text[text()='creator']]$$ );
140 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'author', 'conference', $$//mods:mods/mods:name[@type='conference']/mods:namePart[../mods:role/mods:text[text()='creator']]$$ );
141 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'author', 'other', $$//mods:mods/mods:name[@type='personal']/mods:namePart[not(../mods:role)]$$ );
142 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'subject', 'geographic', $$//mods:mods/mods:subject/mods:geographic$$ );
143 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'subject', 'name', $$//mods:mods/mods:subject/mods:name$$ );
144 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'subject', 'temporal', $$//mods:mods/mods:subject/mods:temporal$$ );
145 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'subject', 'topic', $$//mods:mods/mods:subject/mods:topic$$ );
146 -- INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'subject', 'genre', $$//mods:mods/mods:genre$$ );
147 INSERT INTO config.metabib_field ( field_class, name, xpath ) VALUES ( 'keyword', 'keyword', $$//mods:mods/*[not(local-name()='originInfo')]$$ ); -- /* to fool vim */
148
149 CREATE TABLE config.identification_type (
150         id              SERIAL  PRIMARY KEY,
151         name            TEXT    NOT NULL UNIQUE
152 );
153 COMMENT ON TABLE config.identification_type IS $$
154 /*
155  * Copyright (C) 2005  Georgia Public Library Service 
156  * Mike Rylander <mrylander@gmail.com>
157  *
158  * Types of valid patron identification.
159  *
160  * Each patron must display at least one valid form of identification
161  * in order to get a library card.  This table lists those forms.
162  * 
163  *
164  * ****
165  *
166  * This program is free software; you can redistribute it and/or
167  * modify it under the terms of the GNU General Public License
168  * as published by the Free Software Foundation; either version 2
169  * of the License, or (at your option) any later version.
170  *
171  * This program is distributed in the hope that it will be useful,
172  * but WITHOUT ANY WARRANTY; without even the implied warranty of
173  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174  * GNU General Public License for more details.
175  */
176 $$;
177
178
179 INSERT INTO config.identification_type ( name ) VALUES ( 'Drivers Licence' );
180 INSERT INTO config.identification_type ( name ) VALUES ( 'Voter Card' );
181 INSERT INTO config.identification_type ( name ) VALUES ( 'Two Utility Bills' );
182 INSERT INTO config.identification_type ( name ) VALUES ( 'State ID' );
183 INSERT INTO config.identification_type ( name ) VALUES ( 'SSN' );
184
185 CREATE TABLE config.rule_circ_duration (
186         id              SERIAL          PRIMARY KEY,
187         name            TEXT            NOT NULL UNIQUE CHECK ( name ~ '^\\w+$' ),
188         extended        INTERVAL        NOT NULL,
189         normal          INTERVAL        NOT NULL,
190         shrt            INTERVAL        NOT NULL,
191         max_renewals    INT             NOT NULL
192 );
193 COMMENT ON TABLE config.rule_circ_duration IS $$
194 /*
195  * Copyright (C) 2005  Georgia Public Library Service 
196  * Mike Rylander <mrylander@gmail.com>
197  *
198  * Circulation Duration rules
199  *
200  * Each circulation is given a duration based on one of these rules.
201  * 
202  *
203  * ****
204  *
205  * This program is free software; you can redistribute it and/or
206  * modify it under the terms of the GNU General Public License
207  * as published by the Free Software Foundation; either version 2
208  * of the License, or (at your option) any later version.
209  *
210  * This program is distributed in the hope that it will be useful,
211  * but WITHOUT ANY WARRANTY; without even the implied warranty of
212  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
213  * GNU General Public License for more details.
214  */
215 $$;
216
217 INSERT INTO config.rule_circ_duration VALUES (DEFAULT, '2wk_default', '21 days', '14 days', '7 days', 2);
218
219
220 CREATE TABLE config.rule_max_fine (
221         id      SERIAL          PRIMARY KEY,
222         name    TEXT            NOT NULL UNIQUE CHECK ( name ~ '^\\w+$' ),
223         amount  NUMERIC(6,2)    NOT NULL
224 );
225 COMMENT ON TABLE config.rule_max_fine IS $$
226 /*
227  * Copyright (C) 2005  Georgia Public Library Service 
228  * Mike Rylander <mrylander@gmail.com>
229  *
230  * Circulation Max Fine rules
231  *
232  * Each circulation is given a maximum fine based on one of
233  * these rules.
234  * 
235  *
236  * ****
237  *
238  * This program is free software; you can redistribute it and/or
239  * modify it under the terms of the GNU General Public License
240  * as published by the Free Software Foundation; either version 2
241  * of the License, or (at your option) any later version.
242  *
243  * This program is distributed in the hope that it will be useful,
244  * but WITHOUT ANY WARRANTY; without even the implied warranty of
245  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
246  * GNU General Public License for more details.
247  */
248 $$;
249
250 INSERT INTO config.rule_max_fine VALUES (DEFAULT, 'books', 50.00);
251
252
253 CREATE TABLE config.rule_recuring_fine (
254         id                      SERIAL          PRIMARY KEY,
255         name                    TEXT            NOT NULL UNIQUE CHECK ( name ~ '^\\w+$' ),
256         high                    NUMERIC(6,2)    NOT NULL,
257         normal                  NUMERIC(6,2)    NOT NULL,
258         low                     NUMERIC(6,2)    NOT NULL,
259         recurance_interval      INTERVAL        NOT NULL DEFAULT '1 day'::INTERVAL
260 );
261 COMMENT ON TABLE config.rule_recuring_fine IS $$
262 /*
263  * Copyright (C) 2005  Georgia Public Library Service 
264  * Mike Rylander <mrylander@gmail.com>
265  *
266  * Circulation Recuring Fine rules
267  *
268  * Each circulation is given a recuring fine amount based on one of
269  * these rules.  The recurance_interval should not be any shorter
270  * than the interval between runs of the fine_processor.pl script
271  * (which is run from CRON), or you could miss fines.
272  * 
273  *
274  * ****
275  *
276  * This program is free software; you can redistribute it and/or
277  * modify it under the terms of the GNU General Public License
278  * as published by the Free Software Foundation; either version 2
279  * of the License, or (at your option) any later version.
280  *
281  * This program is distributed in the hope that it will be useful,
282  * but WITHOUT ANY WARRANTY; without even the implied warranty of
283  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
284  * GNU General Public License for more details.
285  */
286 $$;
287
288 INSERT INTO config.rule_recuring_fine VALUES (1, 'books', 0.50, 0.10, 0.10, '1 day');
289
290
291 CREATE TABLE config.rule_age_hold_protect (
292         id      SERIAL          PRIMARY KEY,
293         name    TEXT            NOT NULL UNIQUE CHECK ( name ~ '^\\w+$' ),
294         age     INTERVAL        NOT NULL,
295         prox    INT             NOT NULL
296 );
297 COMMENT ON TABLE config.rule_age_hold_protect IS $$
298 /*
299  * Copyright (C) 2005  Georgia Public Library Service 
300  * Mike Rylander <mrylander@gmail.com>
301  *
302  * Hold Item Age Protection rules
303  *
304  * A hold request can only capture new(ish) items when they are
305  * within a particular proximity of the home_ou of the requesting
306  * user.  The proximity ('prox' column) is calculated by counting
307  * the number of tree edges beween the user's home_ou and the owning_lib
308  * of the copy that could fulfill the hold.
309  * 
310  *
311  * ****
312  *
313  * This program is free software; you can redistribute it and/or
314  * modify it under the terms of the GNU General Public License
315  * as published by the Free Software Foundation; either version 2
316  * of the License, or (at your option) any later version.
317  *
318  * This program is distributed in the hope that it will be useful,
319  * but WITHOUT ANY WARRANTY; without even the implied warranty of
320  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
321  * GNU General Public License for more details.
322  */
323 $$;
324
325 INSERT INTO config.rule_age_hold_protect VALUES (DEFAULT, '3month', '3 mons', 0);
326 INSERT INTO config.rule_age_hold_protect VALUES (DEFAULT, '6month', '6 mons', 2);
327
328
329 CREATE TABLE config.copy_status (
330         id              SERIAL  PRIMARY KEY,
331         name            TEXT    NOT NULL UNIQUE,
332         holdable        BOOL    NOT NULL DEFAULT FALSE
333 );
334 COMMENT ON TABLE config.copy_status IS $$
335 /*
336  * Copyright (C) 2005  Georgia Public Library Service 
337  * Mike Rylander <mrylander@gmail.com>
338  *
339  * Copy Statuses
340  *
341  * The available copy statuses, and whether a copy in that
342  * status is available for hold request capture.  0 (zero) is
343  * the only special number in this set, meaning that the item
344  * is available for imediate checkout, and is counted as available
345  * in the OPAC.
346  *
347  * Statuses with an ID below 100 are not removable, and have special
348  * meaning in the code.  Do not change them except to translate the
349  * textual name.
350  *
351  * You may add and remove statuses above 100, and these can be used
352  * to remove items from normal circulation without affecting the rest
353  * of the copy's values or it's location.
354  *
355  * ****
356  *
357  * This program is free software; you can redistribute it and/or
358  * modify it under the terms of the GNU General Public License
359  * as published by the Free Software Foundation; either version 2
360  * of the License, or (at your option) any later version.
361  *
362  * This program is distributed in the hope that it will be useful,
363  * but WITHOUT ANY WARRANTY; without even the implied warranty of
364  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
365  * GNU General Public License for more details.
366  */
367 $$;
368
369 INSERT INTO config.copy_status (id,name,holdable)       VALUES (0,'Available','t');
370 INSERT INTO config.copy_status (name,holdable)          VALUES ('Checked out','t');
371 INSERT INTO config.copy_status (name)                   VALUES ('Bindery');
372 INSERT INTO config.copy_status (name)                   VALUES ('Lost');
373 INSERT INTO config.copy_status (name)                   VALUES ('Missing');
374 INSERT INTO config.copy_status (name,holdable)          VALUES ('In process','t');
375 INSERT INTO config.copy_status (name,holdable)          VALUES ('In transit','t');
376 INSERT INTO config.copy_status (name,holdable)          VALUES ('Reshelving','t');
377 INSERT INTO config.copy_status (name)                   VALUES ('On holds shelf');
378 INSERT INTO config.copy_status (name,holdable)          VALUES ('On order','t');
379 INSERT INTO config.copy_status (name)                   VALUES ('ILL');
380 INSERT INTO config.copy_status (name)                   VALUES ('Cataloging');
381 INSERT INTO config.copy_status (name)                   VALUES ('Reserves');
382 INSERT INTO config.copy_status (name)                   VALUES ('Discard/Weed');
383
384 SELECT SETVAL('config.copy_status_id_seq'::TEXT, 100);
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 INSERT INTO config.net_access_level (name) VALUES ('Restricted');
416 INSERT INTO config.net_access_level (name) VALUES ('Full');
417 INSERT INTO config.net_access_level (name) VALUES ('None');
418
419
420 COMMIT;