action.reservation_transit_copy

Cascading Deletes: Deleting rows from this table will cascade to: booking.resource.

Deferrable Constraints: The following FK constraints are deferrable — they are checked at transaction end, not statement end: artc_tc_fkey, reservation_transit_copy_reservation_fkey.

Columns

Column Type Nullable Default Notes

id PK

integer

No

nextval('action.transit_copy_id_seq'::regclass)

source_send_time

timestamp with time zone

Yes

dest_recv_time

timestamp with time zone

Yes

target_copy FK

bigint

No

booking.resource(id)

source

integer

No

dest

integer

No

prev_hop

integer

Yes

copy_status

integer

No

persistant_transfer

boolean

No

false

prev_dest

integer

Yes

cancel_time

timestamp with time zone

Yes

reservation FK

integer

Yes

booking.reservation(id)

Primary Key

(id)

Foreign Keys

Column(s) References On Delete On Update Deferrable Constraint

target_copy

booking.resource(id)

CASCADE

NO ACTION

DEFERRED

artc_tc_fkey

reservation

booking.reservation(id)

SET NULL

NO ACTION

DEFERRED

reservation_transit_copy_reservation_fkey

Indexes

Index Method Definition

reservation_transit_copy_pkey PK

btree

CREATE UNIQUE INDEX reservation_transit_copy_pkey ON action.reservation_transit_copy USING btree (id)

active_reservation_transit_cp_idx

btree

CREATE INDEX active_reservation_transit_cp_idx ON action.reservation_transit_copy USING btree (target_copy)

active_reservation_transit_dest_idx

btree

CREATE INDEX active_reservation_transit_dest_idx ON action.reservation_transit_copy USING btree (dest)

active_reservation_transit_source_idx

btree

CREATE INDEX active_reservation_transit_source_idx ON action.reservation_transit_copy USING btree (source)

Triggers

Trigger Timing Event Level Function

reservation_transit_copy_is_unique_check

AFTER

INSERT

ROW

action.copy_transit_is_unique()

Trigger Bodies

reservation_transit_copy_is_unique_check

Function: action.copy_transit_is_unique()
Timing: AFTER INSERT ROW

BEGIN
    PERFORM * FROM action.transit_copy
        WHERE target_copy = NEW.target_copy
              AND dest_recv_time IS NULL
              AND cancel_time IS NULL;

    IF FOUND THEN
        RAISE EXCEPTION 'Copy id=% is already in transit', NEW.target_copy;
    END IF;
    RETURN NULL;
END;