2 * Copyright (C) 2004-2008 Georgia Public Library Service
3 * Copyright (C) 2007-2008 Equinox Software, Inc.
4 * Mike Rylander <miker@esilibrary.com>
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.
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.
18 DROP SCHEMA container CASCADE;
21 CREATE SCHEMA container;
23 CREATE TABLE container.copy_bucket_type (
24 code TEXT PRIMARY KEY,
25 label TEXT NOT NULL UNIQUE
27 INSERT INTO container.copy_bucket_type (code,label) VALUES ('misc','Miscellaneous');
28 INSERT INTO container.copy_bucket_type (code,label) VALUES ('staff_client','General Staff Client container');
30 CREATE TABLE container.copy_bucket (
31 id SERIAL PRIMARY KEY,
33 REFERENCES actor.usr (id)
39 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.copy_bucket_type (code),
40 pub BOOL NOT NULL DEFAULT FALSE,
41 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
42 CONSTRAINT cb_name_once_per_owner UNIQUE (owner,name,btype)
45 CREATE TABLE container.copy_bucket_item (
46 id SERIAL PRIMARY KEY,
48 REFERENCES container.copy_bucket (id)
53 target_copy INT NOT NULL
54 REFERENCES asset."copy" (id)
59 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
65 CREATE TABLE container.call_number_bucket_type (
66 code TEXT PRIMARY KEY,
67 label TEXT NOT NULL UNIQUE
69 INSERT INTO container.call_number_bucket_type (code,label) VALUES ('misc','Miscellaneous');
71 CREATE TABLE container.call_number_bucket (
72 id SERIAL PRIMARY KEY,
74 REFERENCES actor.usr (id)
80 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.call_number_bucket_type (code),
81 pub BOOL NOT NULL DEFAULT FALSE,
82 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
83 CONSTRAINT cnb_name_once_per_owner UNIQUE (owner,name,btype)
86 CREATE TABLE container.call_number_bucket_item (
87 id SERIAL PRIMARY KEY,
89 REFERENCES container.call_number_bucket (id)
94 target_call_number INT NOT NULL
95 REFERENCES asset.call_number (id)
100 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
105 CREATE TABLE container.biblio_record_entry_bucket_type (
106 code TEXT PRIMARY KEY,
107 label TEXT NOT NULL UNIQUE
109 INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('misc','Miscellaneous');
110 INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('staff_client','General Staff Client container');
111 INSERT INTO container.biblio_record_entry_bucket_type (code,label) VALUES ('bookbag','Book Bag');
114 CREATE TABLE container.biblio_record_entry_bucket (
115 id SERIAL PRIMARY KEY,
117 REFERENCES actor.usr (id)
123 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.biblio_record_entry_bucket_type (code),
124 pub BOOL NOT NULL DEFAULT FALSE,
125 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
126 CONSTRAINT breb_name_once_per_owner UNIQUE (owner,name,btype)
129 CREATE TABLE container.biblio_record_entry_bucket_item (
130 id SERIAL PRIMARY KEY,
132 REFERENCES container.biblio_record_entry_bucket (id)
137 target_biblio_record_entry INT NOT NULL
138 REFERENCES biblio.record_entry (id)
143 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
148 CREATE TABLE container.user_bucket_type (
149 code TEXT PRIMARY KEY,
150 label TEXT NOT NULL UNIQUE
152 INSERT INTO container.user_bucket_type (code,label) VALUES ('misc','Miscellaneous');
153 INSERT INTO container.user_bucket_type (code,label) VALUES ('folks','Friends');
154 INSERT INTO container.user_bucket_type (code,label) VALUES ('folks:pub_book_bags.view','List Published Book Bags');
155 INSERT INTO container.user_bucket_type (code,label) VALUES ('folks:pub_book_bags.add','Add to Published Book Bags');
157 CREATE TABLE container.user_bucket (
158 id SERIAL PRIMARY KEY,
160 REFERENCES actor.usr (id)
166 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.user_bucket_type (code),
167 pub BOOL NOT NULL DEFAULT FALSE,
168 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
169 CONSTRAINT ub_name_once_per_owner UNIQUE (owner,name,btype)
172 CREATE TABLE container.user_bucket_item (
173 id SERIAL PRIMARY KEY,
175 REFERENCES container.user_bucket (id)
180 target_user INT NOT NULL
181 REFERENCES actor.usr (id)
186 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()