[open-ils-commits] r19667 - branches/rel_2_0/Open-ILS/src/sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 9 16:54:46 EST 2011
Author: miker
Date: 2011-03-09 16:54:40 -0500 (Wed, 09 Mar 2011)
New Revision: 19667
Modified:
branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Log:
We should not be dropping and recreating the booking schema -- it was installed in 1.6.1
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2011-03-09 19:34:29 UTC (rev 19666)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql 2011-03-09 21:54:40 UTC (rev 19667)
@@ -110,6 +110,9 @@
-- under a different name:
ALTER TABLE booking.resource_type
+ ALTER COLUMN record TYPE BIGINT;
+
+ALTER TABLE booking.resource_type
ADD CONSTRAINT brt_name_and_record_once_per_owner UNIQUE(owner, name, record);
-- Now upgrade permission.perm_list. This is fairly complicated.
@@ -8355,138 +8358,6 @@
ADD COLUMN prev_dest INTEGER REFERENCES actor.org_unit( id )
DEFERRABLE INITIALLY DEFERRED;
-DROP SCHEMA IF EXISTS booking CASCADE;
-
-CREATE SCHEMA booking;
-
-CREATE TABLE booking.resource_type (
- id SERIAL PRIMARY KEY,
- name TEXT NOT NULL,
- fine_interval INTERVAL,
- fine_amount DECIMAL(8,2) NOT NULL DEFAULT 0,
- owner INT NOT NULL
- REFERENCES actor.org_unit( id )
- DEFERRABLE INITIALLY DEFERRED,
- catalog_item BOOLEAN NOT NULL DEFAULT FALSE,
- transferable BOOLEAN NOT NULL DEFAULT FALSE,
- record BIGINT REFERENCES biblio.record_entry (id)
- DEFERRABLE INITIALLY DEFERRED,
- max_fine NUMERIC(8,2),
- elbow_room INTERVAL,
- CONSTRAINT brt_name_and_record_once_per_owner UNIQUE(owner, name, record)
-);
-
-CREATE TABLE booking.resource (
- id SERIAL PRIMARY KEY,
- owner INT NOT NULL
- REFERENCES actor.org_unit(id)
- DEFERRABLE INITIALLY DEFERRED,
- type INT NOT NULL
- REFERENCES booking.resource_type(id)
- DEFERRABLE INITIALLY DEFERRED,
- overbook BOOLEAN NOT NULL DEFAULT FALSE,
- barcode TEXT NOT NULL,
- deposit BOOLEAN NOT NULL DEFAULT FALSE,
- deposit_amount DECIMAL(8,2) NOT NULL DEFAULT 0.00,
- user_fee DECIMAL(8,2) NOT NULL DEFAULT 0.00,
- CONSTRAINT br_unique UNIQUE (owner, barcode)
-);
-
--- For non-catalog items: hijack barcode for name/description
-
-CREATE TABLE booking.resource_attr (
- id SERIAL PRIMARY KEY,
- owner INT NOT NULL
- REFERENCES actor.org_unit(id)
- DEFERRABLE INITIALLY DEFERRED,
- name TEXT NOT NULL,
- resource_type INT NOT NULL
- REFERENCES booking.resource_type(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- required BOOLEAN NOT NULL DEFAULT FALSE,
- CONSTRAINT bra_name_once_per_type UNIQUE(resource_type, name)
-);
-
-CREATE TABLE booking.resource_attr_value (
- id SERIAL PRIMARY KEY,
- owner INT NOT NULL
- REFERENCES actor.org_unit(id)
- DEFERRABLE INITIALLY DEFERRED,
- attr INT NOT NULL
- REFERENCES booking.resource_attr(id)
- DEFERRABLE INITIALLY DEFERRED,
- valid_value TEXT NOT NULL,
- CONSTRAINT brav_logical_key UNIQUE(owner, attr, valid_value)
-);
-
-CREATE TABLE booking.resource_attr_map (
- id SERIAL PRIMARY KEY,
- resource INT NOT NULL
- REFERENCES booking.resource(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- resource_attr INT NOT NULL
- REFERENCES booking.resource_attr(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- value INT NOT NULL
- REFERENCES booking.resource_attr_value(id)
- DEFERRABLE INITIALLY DEFERRED,
- CONSTRAINT bram_one_value_per_attr UNIQUE(resource, resource_attr)
-);
-
-CREATE TABLE booking.reservation (
- request_time TIMESTAMPTZ NOT NULL DEFAULT now(),
- start_time TIMESTAMPTZ,
- end_time TIMESTAMPTZ,
- capture_time TIMESTAMPTZ,
- cancel_time TIMESTAMPTZ,
- pickup_time TIMESTAMPTZ,
- return_time TIMESTAMPTZ,
- booking_interval INTERVAL,
- fine_interval INTERVAL,
- fine_amount DECIMAL(8,2),
- target_resource_type INT NOT NULL
- REFERENCES booking.resource_type(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- target_resource INT REFERENCES booking.resource(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- current_resource INT REFERENCES booking.resource(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- request_lib INT NOT NULL
- REFERENCES actor.org_unit(id)
- DEFERRABLE INITIALLY DEFERRED,
- pickup_lib INT REFERENCES actor.org_unit(id)
- DEFERRABLE INITIALLY DEFERRED,
- capture_staff INT REFERENCES actor.usr(id)
- DEFERRABLE INITIALLY DEFERRED,
- max_fine NUMERIC(8,2)
-) INHERITS (money.billable_xact);
-
-ALTER TABLE booking.reservation ADD PRIMARY KEY (id);
-
-ALTER TABLE booking.reservation
- ADD CONSTRAINT booking_reservation_usr_fkey
- FOREIGN KEY (usr) REFERENCES actor.usr (id)
- DEFERRABLE INITIALLY DEFERRED;
-
-CREATE TABLE booking.reservation_attr_value_map (
- id SERIAL PRIMARY KEY,
- reservation INT NOT NULL
- REFERENCES booking.reservation(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- attr_value INT NOT NULL
- REFERENCES booking.resource_attr_value(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- CONSTRAINT bravm_logical_key UNIQUE(reservation, attr_value)
-);
-
-- represents a circ chain summary
CREATE TYPE action.circ_chain_summary AS (
num_circs INTEGER,
@@ -8581,8 +8452,11 @@
END;
$$ LANGUAGE 'plpgsql';
+DROP TRIGGER IF EXISTS mat_summary_create_tgr ON booking.reservation;
CREATE TRIGGER mat_summary_create_tgr AFTER INSERT ON booking.reservation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_create ('reservation');
+DROP TRIGGER IF EXISTS mat_summary_change_tgr ON booking.reservation;
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON booking.reservation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
+DROP TRIGGER IF EXISTS mat_summary_remove_tgr ON booking.reservation;
CREATE TRIGGER mat_summary_remove_tgr AFTER DELETE ON booking.reservation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_delete ();
ALTER TABLE config.standing_penalty
@@ -18807,16 +18681,6 @@
-- Recreate some foreign keys that were somehow dropped, probably
-- by some kind of cascade from an inherited table:
-ALTER TABLE action.reservation_transit_copy
- ADD CONSTRAINT artc_tc_fkey FOREIGN KEY (target_copy)
- REFERENCES booking.resource(id)
- ON DELETE CASCADE
- DEFERRABLE INITIALLY DEFERRED,
- ADD CONSTRAINT reservation_transit_copy_reservation_fkey FOREIGN KEY (reservation)
- REFERENCES booking.reservation(id)
- ON DELETE SET NULL
- DEFERRABLE INITIALLY DEFERRED;
-
CREATE INDEX user_bucket_item_target_user_idx
ON container.user_bucket_item ( target_user );
@@ -19067,6 +18931,17 @@
-- Some operations go outside of the transaction, because they may
-- legitimately fail.
+ALTER TABLE action.reservation_transit_copy
+ ADD CONSTRAINT artc_tc_fkey FOREIGN KEY (target_copy)
+ REFERENCES booking.resource(id)
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED,
+ ADD CONSTRAINT reservation_transit_copy_reservation_fkey FOREIGN KEY (reservation)
+ REFERENCES booking.reservation(id)
+ ON DELETE SET NULL
+ DEFERRABLE INITIALLY DEFERRED;
+
+
\qecho ALTERs of auditor.action_hold_request_history will fail if the table
\qecho doesn't exist; ignore those errors if they occur.
More information about the open-ils-commits
mailing list