2 * Copyright (C) 2004-2008 Georgia Public Library Service
3 * Copyright (C) 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 biblio CASCADE;
23 CREATE SEQUENCE biblio.autogen_tcn_value_seq;
24 CREATE FUNCTION biblio.next_autogen_tcn_value () RETURNS TEXT AS $$
25 BEGIN RETURN nextval('biblio.autogen_tcn_value_seq'::TEXT); END;
28 CREATE TABLE biblio.record_entry (
29 id BIGSERIAL PRIMARY KEY,
30 creator INT NOT NULL DEFAULT 1,
31 editor INT NOT NULL DEFAULT 1,
34 create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
35 edit_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
36 active BOOL NOT NULL DEFAULT TRUE,
37 deleted BOOL NOT NULL DEFAULT FALSE,
39 tcn_source TEXT NOT NULL DEFAULT 'AUTOGEN',
40 tcn_value TEXT NOT NULL DEFAULT biblio.next_autogen_tcn_value(),
42 last_xact_id TEXT NOT NULL
44 CREATE INDEX biblio_record_entry_creator_idx ON biblio.record_entry ( creator );
45 CREATE INDEX biblio_record_entry_editor_idx ON biblio.record_entry ( editor );
46 CREATE INDEX biblio_record_entry_fp_idx ON biblio.record_entry ( fingerprint );
47 CREATE UNIQUE INDEX biblio_record_unique_tcn ON biblio.record_entry (tcn_value) WHERE deleted IS FALSE;
49 CREATE RULE protect_bib_rec_delete AS ON DELETE TO biblio.record_entry DO INSTEAD UPDATE biblio.record_entry SET deleted = TRUE WHERE OLD.id = biblio.record_entry.id;
52 CREATE TABLE biblio.record_note (
53 id BIGSERIAL PRIMARY KEY,
54 record BIGINT NOT NULL,
56 creator INT NOT NULL DEFAULT 1,
57 editor INT NOT NULL DEFAULT 1,
58 pub BOOL NOT NULL DEFAULT FALSE,
59 create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
60 edit_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
62 CREATE INDEX biblio_record_note_record_idx ON biblio.record_note ( record );
63 CREATE INDEX biblio_record_note_creator_idx ON biblio.record_note ( creator );
64 CREATE INDEX biblio_record_note_editor_idx ON biblio.record_note ( editor );