Show
Ignore:
Timestamp:
05/09/08 12:34:30 (5 months ago)
Author:
dbs
Message:

Merge rev. 9542 from trunk: add deferrable to all FKs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/rel_1_2/Open-ILS/src/sql/Pg/090.schema.action.sql

    r8908 r9543  
    77CREATE TABLE action.in_house_use ( 
    88        id              SERIAL                          PRIMARY KEY, 
    9         item            BIGINT                          NOT NULL REFERENCES asset.copy (id), 
    10         staff           INT                             NOT NULL REFERENCES actor.usr (id), 
    11         org_unit        INT                             NOT NULL REFERENCES actor.org_unit (id), 
     9        item            BIGINT                          NOT NULL REFERENCES asset.copy (id) DEFERRABLE INITIALLY DEFERRED, 
     10        staff           INT                             NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
     11        org_unit        INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
    1212        use_time        TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW() 
    1313); 
     
    1515CREATE TABLE action.non_cataloged_circulation ( 
    1616        id              SERIAL                          PRIMARY KEY, 
    17         patron          INT                             NOT NULL REFERENCES actor.usr (id), 
    18         staff           INT                             NOT NULL REFERENCES actor.usr (id), 
    19         circ_lib        INT                             NOT NULL REFERENCES actor.org_unit (id), 
    20         item_type       INT                             NOT NULL REFERENCES config.non_cataloged_type (id), 
     17        patron          INT                             NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
     18        staff           INT                             NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
     19        circ_lib        INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
     20        item_type       INT                             NOT NULL REFERENCES config.non_cataloged_type (id) DEFERRABLE INITIALLY DEFERRED, 
    2121        circ_time       TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW() 
    2222); 
     
    2424CREATE TABLE action.non_cat_in_house_use ( 
    2525        id              SERIAL                          PRIMARY KEY, 
    26         item_type       BIGINT                          NOT NULL REFERENCES config.non_cataloged_type(id), 
    27         staff           INT                             NOT NULL REFERENCES actor.usr (id), 
    28         org_unit        INT                             NOT NULL REFERENCES actor.org_unit (id), 
     26        item_type       BIGINT                          NOT NULL REFERENCES config.non_cataloged_type(id) DEFERRABLE INITIALLY DEFERRED, 
     27        staff           INT                             NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
     28        org_unit        INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
    2929        use_time        TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW() 
    3030); 
     
    3232CREATE TABLE action.survey ( 
    3333        id              SERIAL                          PRIMARY KEY, 
    34         owner           INT                             NOT NULL REFERENCES actor.org_unit (id), 
     34        owner           INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
    3535        start_date      TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW(), 
    3636        end_date        TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW() + '10 years'::INTERVAL, 
     
    4646CREATE TABLE action.survey_question ( 
    4747        id              SERIAL  PRIMARY KEY, 
    48         survey          INT     NOT NULL REFERENCES action.survey, 
     48        survey          INT     NOT NULL REFERENCES action.survey DEFERRABLE INITIALLY DEFERRED, 
    4949        question        TEXT    NOT NULL 
    5050); 
     
    5252CREATE TABLE action.survey_answer ( 
    5353        id              SERIAL  PRIMARY KEY, 
    54         question        INT     NOT NULL REFERENCES action.survey_question, 
     54        question        INT     NOT NULL REFERENCES action.survey_question DEFERRABLE INITIALLY DEFERRED, 
    5555        answer          TEXT    NOT NULL 
    5656); 
     
    6262        response_group_id       INT, 
    6363        usr                     INT, -- REFERENCES actor.usr 
    64         survey                  INT                             NOT NULL REFERENCES action.survey, 
    65         question                INT                             NOT NULL REFERENCES action.survey_question, 
    66         answer                  INT                             NOT NULL REFERENCES action.survey_answer, 
     64        survey                  INT                             NOT NULL REFERENCES action.survey DEFERRABLE INITIALLY DEFERRED, 
     65        question                INT                             NOT NULL REFERENCES action.survey_question DEFERRABLE INITIALLY DEFERRED, 
     66        answer                  INT                             NOT NULL REFERENCES action.survey_answer DEFERRABLE INITIALLY DEFERRED, 
    6767        answer_date             TIMESTAMP WITH TIME ZONE, 
    6868        effective_date          TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW() 
     
    176176        cancel_time             TIMESTAMP WITH TIME ZONE, 
    177177        target                  BIGINT                          NOT NULL, -- see hold_type 
    178         current_copy            BIGINT                          REFERENCES asset.copy (id) ON DELETE SET NULL, 
    179         fulfillment_staff       INT                             REFERENCES actor.usr (id), 
    180         fulfillment_lib         INT                             REFERENCES actor.org_unit (id), 
    181         request_lib             INT                             NOT NULL REFERENCES actor.org_unit (id), 
    182         requestor               INT                             NOT NULL REFERENCES actor.usr (id), 
    183         usr                     INT                             NOT NULL REFERENCES actor.usr (id), 
     178        current_copy            BIGINT                          REFERENCES asset.copy (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, 
     179        fulfillment_staff       INT                             REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
     180        fulfillment_lib         INT                             REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
     181        request_lib             INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
     182        requestor               INT                             NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
     183        usr                     INT                             NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
    184184        selection_ou            INT                             NOT NULL, 
    185185        selection_depth         INT                             NOT NULL DEFAULT 0, 
    186         pickup_lib              INT                             NOT NULL REFERENCES actor.org_unit, 
     186        pickup_lib              INT                             NOT NULL REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED, 
    187187        hold_type               TEXT                            NOT NULL CHECK (hold_type IN ('M','T','V','C')), 
    188188        holdable_formats        TEXT, 
     
    202202CREATE TABLE action.hold_notification ( 
    203203        id              SERIAL                          PRIMARY KEY, 
    204         hold            INT                             NOT NULL REFERENCES action.hold_request (id), 
    205         notify_staff    INT                             REFERENCES actor.usr (id), 
     204        hold            INT                             NOT NULL REFERENCES action.hold_request (id) DEFERRABLE INITIALLY DEFERRED, 
     205        notify_staff    INT                             REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, 
    206206        notify_time     TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW(), 
    207207        method          TEXT                            NOT NULL, -- email address or phone number 
     
    212212CREATE TABLE action.hold_copy_map ( 
    213213        id              SERIAL  PRIMARY KEY, 
    214         hold            INT     NOT NULL REFERENCES action.hold_request (id) ON DELETE CASCADE, 
    215         target_copy     BIGINT  NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE, 
     214        hold            INT     NOT NULL REFERENCES action.hold_request (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, 
     215        target_copy     BIGINT  NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, 
    216216        CONSTRAINT copy_once_per_hold UNIQUE (hold,target_copy) 
    217217); 
     
    223223        source_send_time        TIMESTAMP WITH TIME ZONE, 
    224224        dest_recv_time          TIMESTAMP WITH TIME ZONE, 
    225         target_copy             BIGINT                          NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE, 
    226         source                  INT                             NOT NULL REFERENCES actor.org_unit (id), 
    227         dest                    INT                             NOT NULL REFERENCES actor.org_unit (id), 
    228         prev_hop                INT                             REFERENCES action.transit_copy (id), 
    229         copy_status             INT                             NOT NULL REFERENCES config.copy_status (id), 
     225        target_copy             BIGINT                          NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, 
     226        source                  INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
     227        dest                    INT                             NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, 
     228        prev_hop                INT                             REFERENCES action.transit_copy (id) DEFERRABLE INITIALLY DEFERRED, 
     229        copy_status             INT                             NOT NULL REFERENCES config.copy_status (id) DEFERRABLE INITIALLY DEFERRED, 
    230230        persistant_transfer     BOOL                            NOT NULL DEFAULT FALSE 
    231231); 
     
    239239) INHERITS (action.transit_copy); 
    240240ALTER TABLE action.hold_transit_copy ADD PRIMARY KEY (id); 
    241 ALTER TABLE action.hold_transit_copy ADD CONSTRAINT ahtc_tc_fkey FOREIGN KEY (target_copy) REFERENCES asset.copy (id) ON DELETE CASCADE; 
     241ALTER TABLE action.hold_transit_copy ADD CONSTRAINT ahtc_tc_fkey FOREIGN KEY (target_copy) REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; 
    242242CREATE INDEX active_hold_transit_dest_idx ON "action".hold_transit_copy (dest); 
    243243CREATE INDEX active_hold_transit_source_idx ON "action".hold_transit_copy (source);