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
28 CREATE TABLE container.copy_bucket (
29 id SERIAL PRIMARY KEY,
31 REFERENCES actor.usr (id)
37 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.copy_bucket_type (code),
38 pub BOOL NOT NULL DEFAULT FALSE,
39 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
40 CONSTRAINT cb_name_once_per_owner UNIQUE (owner,name,btype)
43 CREATE TABLE container.copy_bucket_item (
44 id SERIAL PRIMARY KEY,
46 REFERENCES container.copy_bucket (id)
51 target_copy INT NOT NULL
52 REFERENCES asset."copy" (id)
57 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
63 CREATE TABLE container.call_number_bucket_type (
64 code TEXT PRIMARY KEY,
65 label TEXT NOT NULL UNIQUE
68 CREATE TABLE container.call_number_bucket (
69 id SERIAL PRIMARY KEY,
71 REFERENCES actor.usr (id)
77 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.call_number_bucket_type (code),
78 pub BOOL NOT NULL DEFAULT FALSE,
79 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
80 CONSTRAINT cnb_name_once_per_owner UNIQUE (owner,name,btype)
83 CREATE TABLE container.call_number_bucket_item (
84 id SERIAL PRIMARY KEY,
86 REFERENCES container.call_number_bucket (id)
91 target_call_number INT NOT NULL
92 REFERENCES asset.call_number (id)
97 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
102 CREATE TABLE container.biblio_record_entry_bucket_type (
103 code TEXT PRIMARY KEY,
104 label TEXT NOT NULL UNIQUE
108 CREATE TABLE container.biblio_record_entry_bucket (
109 id SERIAL PRIMARY KEY,
111 REFERENCES actor.usr (id)
117 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.biblio_record_entry_bucket_type (code),
118 pub BOOL NOT NULL DEFAULT FALSE,
119 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
120 CONSTRAINT breb_name_once_per_owner UNIQUE (owner,name,btype)
123 CREATE TABLE container.biblio_record_entry_bucket_item (
124 id SERIAL PRIMARY KEY,
126 REFERENCES container.biblio_record_entry_bucket (id)
131 target_biblio_record_entry INT NOT NULL
132 REFERENCES biblio.record_entry (id)
137 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
142 CREATE TABLE container.user_bucket_type (
143 code TEXT PRIMARY KEY,
144 label TEXT NOT NULL UNIQUE
147 CREATE TABLE container.user_bucket (
148 id SERIAL PRIMARY KEY,
150 REFERENCES actor.usr (id)
156 btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.user_bucket_type (code),
157 pub BOOL NOT NULL DEFAULT FALSE,
158 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
159 CONSTRAINT ub_name_once_per_owner UNIQUE (owner,name,btype)
162 CREATE TABLE container.user_bucket_item (
163 id SERIAL PRIMARY KEY,
165 REFERENCES container.user_bucket (id)
170 target_user INT NOT NULL
171 REFERENCES actor.usr (id)
176 create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()