actor.org_unit

Hub Table: This table is referenced by 137 foreign keys across the database. It is a central structural table — changes to rows here have wide-reaching effects. Consider all dependent schemas before deleting or modifying rows.

Data-Modifying Triggers: This table has BEFORE ROW trigger(s) that modify row data before write. Values you INSERT or UPDATE may differ from what is actually stored. See the Triggers section below.

Deferrable Constraints: The following FK constraints are deferrable — they are checked at transaction end, not statement end: actor_org_unit_billing_address_fkey, actor_org_unit_holds_address_fkey, actor_org_unit_ill_address_fkey, actor_org_unit_mailing_address_fkey, org_unit_fiscal_calendar_fkey, org_unit_ou_type_fkey, org_unit_parent_ou_fkey.

Trigger Side Effects: Writing to this table automatically triggers writes to other tables:

Columns

Column Type Nullable Default Notes

id PK

integer

No

nextval('actor.org_unit_id_seq'::regclass)

parent_ou FK

integer

Yes

actor.org_unit(id)

ou_type FK

integer

No

actor.org_unit_type(id)

ill_address FK

integer

Yes

actor.org_address(id)

holds_address FK

integer

Yes

actor.org_address(id)

mailing_address FK

integer

Yes

actor.org_address(id)

billing_address FK

integer

Yes

actor.org_address(id)

shortname

text

No

name

text

No

email

text

Yes

phone

text

Yes

opac_visible

boolean

No

true

fiscal_calendar FK

integer

No

1

acq.fiscal_calendar(id)

Primary Key

(id)

Foreign Keys

Column(s) References On Delete On Update Deferrable Constraint

billing_address

actor.org_address(id)

NO ACTION

NO ACTION

DEFERRED

actor_org_unit_billing_address_fkey

holds_address

actor.org_address(id)

NO ACTION

NO ACTION

DEFERRED

actor_org_unit_holds_address_fkey

ill_address

actor.org_address(id)

NO ACTION

NO ACTION

DEFERRED

actor_org_unit_ill_address_fkey

mailing_address

actor.org_address(id)

NO ACTION

NO ACTION

DEFERRED

actor_org_unit_mailing_address_fkey

fiscal_calendar

acq.fiscal_calendar(id)

NO ACTION

NO ACTION

DEFERRED

org_unit_fiscal_calendar_fkey

ou_type

actor.org_unit_type(id)

NO ACTION

NO ACTION

DEFERRED

org_unit_ou_type_fkey

parent_ou

actor.org_unit(id)

NO ACTION

NO ACTION

DEFERRED

org_unit_parent_ou_fkey

Unique Constraints

  • org_unit_name_key: (name)

  • org_unit_shortname_key: (shortname)

Indexes

Index Method Definition

org_unit_pkey PK

btree

CREATE UNIQUE INDEX org_unit_pkey ON actor.org_unit USING btree (id)

org_unit_name_key UNIQUE

btree

CREATE UNIQUE INDEX org_unit_name_key ON actor.org_unit USING btree (name)

org_unit_shortname_key UNIQUE

btree

CREATE UNIQUE INDEX org_unit_shortname_key ON actor.org_unit USING btree (shortname)

actor_org_unit_billing_address_idx

btree

CREATE INDEX actor_org_unit_billing_address_idx ON actor.org_unit USING btree (billing_address)

actor_org_unit_holds_address_idx

btree

CREATE INDEX actor_org_unit_holds_address_idx ON actor.org_unit USING btree (holds_address)

actor_org_unit_ill_address_idx

btree

CREATE INDEX actor_org_unit_ill_address_idx ON actor.org_unit USING btree (ill_address)

actor_org_unit_mailing_address_idx

btree

CREATE INDEX actor_org_unit_mailing_address_idx ON actor.org_unit USING btree (mailing_address)

actor_org_unit_ou_type_idx

btree

CREATE INDEX actor_org_unit_ou_type_idx ON actor.org_unit USING btree (ou_type)

actor_org_unit_parent_ou_idx

btree

CREATE INDEX actor_org_unit_parent_ou_idx ON actor.org_unit USING btree (parent_ou)

Triggers

Trigger Timing Event Level Function

actor_org_unit_parent_protect_trigger

BEFORE

INSERT OR UPDATE

ROW

actor.org_unit_parent_protect()

audit_actor_org_unit_update_trigger

AFTER

DELETE OR UPDATE

ROW

auditor.audit_actor_org_unit_func()

proximity_update_tgr

AFTER

INSERT OR DELETE OR UPDATE

ROW

actor.org_unit_prox_update()

Trigger Bodies

actor_org_unit_parent_protect_trigger

Function: actor.org_unit_parent_protect()
Timing: BEFORE INSERT OR UPDATE ROW

This trigger modifies the row before it is written (returns a modified NEW).

	DECLARE
		current_aou actor.org_unit%ROWTYPE;
		seen_ous    INT[];
		depth_count INT;
	BEGIN
		current_aou := NEW;
		depth_count := 0;
		seen_ous := ARRAY[NEW.id];

		IF (TG_OP = 'UPDATE') THEN
			IF (NEW.parent_ou IS NOT DISTINCT FROM OLD.parent_ou) THEN
				RETURN NEW; -- Doing an UPDATE with no change, just return it
			END IF;
		END IF;

		LOOP
			IF current_aou.parent_ou IS NULL THEN -- Top of the org tree?
				RETURN NEW; -- No loop. Carry on.
			END IF;
			IF current_aou.parent_ou = ANY(seen_ous) THEN -- Parent is one we have seen?
				RAISE 'OU LOOP: Saw % twice', current_aou.parent_ou; -- LOOP! ABORT!
			END IF;
			-- Get the next one!
			SELECT INTO current_aou * FROM actor.org_unit WHERE id = current_aou.parent_ou;
			seen_ous := seen_ous || current_aou.id;
			depth_count := depth_count + 1;
			IF depth_count = 100 THEN
				RAISE 'OU CHECK TOO DEEP';
			END IF;
		END LOOP;

		RETURN NEW;
	END;

audit_actor_org_unit_update_trigger

Function: auditor.audit_actor_org_unit_func()
Timing: AFTER DELETE OR UPDATE ROW

        BEGIN
            INSERT INTO auditor.actor_org_unit_history ( audit_id, audit_time, audit_action, audit_user, audit_ws, id, parent_ou, ou_type, ill_address, holds_address, mailing_address, billing_address, shortname, name, email, phone, opac_visible, fiscal_calendar )
                SELECT  nextval('auditor.actor_org_unit_pkey_seq'),
                    now(),
                    SUBSTR(TG_OP,1,1),
                    eg_user,
                    eg_ws,
                    OLD.id, OLD.parent_ou, OLD.ou_type, OLD.ill_address, OLD.holds_address, OLD.mailing_address, OLD.billing_address, OLD.shortname, OLD.name, OLD.email, OLD.phone, OLD.opac_visible, OLD.fiscal_calendar
                FROM auditor.get_audit_info();
            RETURN NULL;
        END;

proximity_update_tgr

Function: actor.org_unit_prox_update()
Timing: AFTER INSERT OR DELETE OR UPDATE ROW

BEGIN


IF TG_OP = 'DELETE' THEN

    DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);

END IF;

IF TG_OP = 'UPDATE' THEN

    IF NEW.parent_ou <> OLD.parent_ou THEN

        DELETE FROM actor.org_unit_proximity WHERE (from_org = OLD.id or to_org= OLD.id);
            INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
            SELECT  l.id, r.id, actor.org_unit_proximity(l.id,r.id)
                FROM  actor.org_unit l, actor.org_unit r
                WHERE (l.id = NEW.id or r.id = NEW.id);

    END IF;

END IF;

IF TG_OP = 'INSERT' THEN

     INSERT INTO actor.org_unit_proximity (from_org, to_org, prox)
     SELECT  l.id, r.id, actor.org_unit_proximity(l.id,r.id)
         FROM  actor.org_unit l, actor.org_unit r
         WHERE (l.id = NEW.id or r.id = NEW.id);

END IF;

RETURN null;

END;

Referenced By

The following tables have foreign keys pointing to actor.org_unit (137 referencing table(s)):

Table Referencing Column(s) Referenced Column(s) Constraint

acq.cancel_reason

org_unit

id

cancel_reason_org_unit_fkey

acq.claim_event_type

org_unit

id

claim_event_type_org_unit_fkey

acq.claim_policy

org_unit

id

claim_policy_org_unit_fkey

acq.claim_type

org_unit

id

claim_type_org_unit_fkey

acq.distribution_formula

owner

id

distribution_formula_owner_fkey

acq.distribution_formula_entry

owning_lib

id

distribution_formula_entry_owning_lib_fkey

acq.fund

org

id

fund_org_fkey

acq.fund_allocation_percent

org

id

fund_allocation_percent_org_fkey

acq.fund_tag

owner

id

fund_tag_owner_fkey

acq.funding_source

owner

id

funding_source_owner_fkey

acq.invoice

receiver

id

invoice_receiver_fkey

acq.lineitem_alert_text

owning_lib

id

lineitem_alert_text_owning_lib_fkey

acq.lineitem_detail

owning_lib

id

lineitem_detail_owning_lib_fkey

acq.picklist

org_unit

id

picklist_org_unit_fkey

acq.provider

owner

id

provider_owner_fkey

acq.purchase_order

ordering_agency

id

purchase_order_ordering_agency_fkey

acq.shipment_notification

receiver

id

shipment_notification_receiver_fkey

acq.user_request

pickup_lib

id

user_request_pickup_lib_fkey

action.circulation

circ_lib

id

action_circulation_circ_lib_fkey

action.curbside

org

id

curbside_org_fkey

action.fieldset

owning_lib

id

fieldset_owning_lib_fkey

action.fieldset_group

owning_lib

id

fieldset_group_owning_lib_fkey

action.hold_request

current_shelf_lib

id

hold_request_current_shelf_lib_fkey

action.hold_request

fulfillment_lib

id

hold_request_fulfillment_lib_fkey

action.hold_request

pickup_lib

id

hold_request_pickup_lib_fkey

action.hold_request

request_lib

id

hold_request_request_lib_fkey

action.hold_request

selection_ou

id

hold_request_selection_ou_fkey

action.in_house_use

org_unit

id

in_house_use_org_unit_fkey

action.non_cat_in_house_use

org_unit

id

non_cat_in_house_use_org_unit_fkey

action.non_cataloged_circulation

circ_lib

id

non_cataloged_circulation_circ_lib_fkey

action.survey

owner

id

survey_owner_fkey

action.transit_copy

dest

id

transit_copy_dest_fkey

action.transit_copy

prev_dest

id

transit_copy_prev_dest_fkey

action.transit_copy

source

id

transit_copy_source_fkey

action_trigger.event

context_library

id

event_context_library_fkey

action_trigger.event_def_group

owner

id

event_def_group_owner_fkey

action_trigger.event_definition

owner

id

event_definition_owner_fkey

actor.address_alert

owner

id

address_alert_owner_fkey

actor.copy_alert_suppress

org

id

copy_alert_suppress_org_fkey

actor.hours_of_operation

id

id

hours_of_operation_id_fkey

actor.org_address

org_unit

id

org_address_org_unit_fkey

actor.org_lasso_map

org_unit

id

org_lasso_map_org_unit_fkey

actor.org_unit

parent_ou

id

org_unit_parent_ou_fkey

actor.org_unit_closed

org_unit

id

org_unit_closed_org_unit_fkey

actor.org_unit_custom_tree_node

org_unit

id

org_unit_custom_tree_node_org_unit_fkey

actor.org_unit_proximity_adjustment

hold_pickup_lib

id

org_unit_proximity_adjustment_hold_pickup_lib_fkey

actor.org_unit_proximity_adjustment

hold_request_lib

id

org_unit_proximity_adjustment_hold_request_lib_fkey

actor.org_unit_proximity_adjustment

item_circ_lib

id

org_unit_proximity_adjustment_item_circ_lib_fkey

actor.org_unit_proximity_adjustment

item_owning_lib

id

org_unit_proximity_adjustment_item_owning_lib_fkey

actor.org_unit_setting

org_unit

id

org_unit_setting_org_unit_fkey

actor.patron_loader_log

org_unit

id

actor_patron_loader_log_org_fkey

actor.search_filter_group

owner

id

search_filter_group_owner_fkey

actor.stat_cat

owner

id

actor_stat_cat_owner_fkey

actor.stat_cat_entry

owner

id

actor_stat_cat_entry_owner_fkey

actor.stat_cat_entry_default

owner

id

stat_cat_entry_default_owner_fkey

actor.toolbar

org

id

toolbar_org_fkey

actor.usr

home_ou

id

actor_usr_home_ou_fkey

actor.usr_message

sending_lib

id

usr_message_sending_lib_fkey

actor.usr_org_unit_opt_in

org_unit

id

usr_org_unit_opt_in_org_unit_fkey

actor.usr_standing_penalty

org_unit

id

usr_standing_penalty_org_unit_fkey

actor.workstation

owning_lib

id

workstation_owning_lib_fkey

asset.call_number

owning_lib

id

asset_call_number_owning_lib_fkey

asset.call_number_prefix

owning_lib

id

call_number_prefix_owning_lib_fkey

asset.call_number_suffix

owning_lib

id

call_number_suffix_owning_lib_fkey

asset.copy

circ_lib

id

copy_circ_lib_fkey

asset.copy_location

owning_lib

id

copy_location_owning_lib_fkey

asset.copy_location_group

owner

id

copy_location_group_owner_fkey

asset.copy_location_order

org

id

copy_location_order_org_fkey

asset.copy_tag

owner

id

copy_tag_owner_fkey

asset.copy_template

circ_lib

id

copy_template_circ_lib_fkey

asset.copy_template

owning_lib

id

copy_template_owning_lib_fkey

asset.course_module_course

owning_lib

id

course_module_course_owning_lib_fkey

asset.course_module_course_materials

original_circ_lib

id

course_module_course_materials_original_circ_lib_fkey

asset.course_module_term

owning_lib

id

course_module_term_owning_lib_fkey

asset.stat_cat

owner

id

a_sc_owner_fkey

asset.stat_cat_entry

owner

id

a_sce_owner_fkey

biblio.record_entry

owner

id

biblio_record_entry_owner_fkey

booking.reservation

pickup_lib

id

reservation_pickup_lib_fkey

booking.reservation

request_lib

id

reservation_request_lib_fkey

booking.resource

owner

id

resource_owner_fkey

booking.resource_attr

owner

id

resource_attr_owner_fkey

booking.resource_attr_value

owner

id

resource_attr_value_owner_fkey

booking.resource_type

owner

id

resource_type_owner_fkey

config.barcode_completion

org_unit

id

config_barcode_completion_org_unit_fkey

config.billing_type

owner

id

config_billing_type_owner_fkey

config.circ_limit_set

owning_lib

id

circ_limit_set_owning_lib_fkey

config.circ_matrix_matchpoint

copy_circ_lib

id

circ_matrix_matchpoint_copy_circ_lib_fkey

config.circ_matrix_matchpoint

copy_owning_lib

id

circ_matrix_matchpoint_copy_owning_lib_fkey

config.circ_matrix_matchpoint

org_unit

id

circ_matrix_matchpoint_org_unit_fkey

config.circ_matrix_matchpoint

user_home_ou

id

circ_matrix_matchpoint_user_home_ou_fkey

config.copy_alert_type

scope_org

id

copy_alert_type_scope_org_fkey

config.copy_tag_type

owner

id

copy_tag_type_owner_fkey

config.filter_dialog_filter_set

owning_lib

id

config_filter_dialog_filter_set_owning_lib_fkey

config.floating_group_member

org_unit

id

floating_group_member_org_unit_fkey

config.geolocation_service

owner

id

cgs_owner_fkey

config.hold_matrix_matchpoint

item_circ_ou

id

hold_matrix_matchpoint_item_circ_ou_fkey

config.hold_matrix_matchpoint

item_owning_ou

id

hold_matrix_matchpoint_item_owning_ou_fkey

config.hold_matrix_matchpoint

pickup_ou

id

hold_matrix_matchpoint_pickup_ou_fkey

config.hold_matrix_matchpoint

request_ou

id

hold_matrix_matchpoint_request_ou_fkey

config.hold_matrix_matchpoint

user_home_ou

id

hold_matrix_matchpoint_user_home_ou_fkey

config.idl_field_doc

owner

id

idl_field_doc_owner_fkey

config.marc_field

owner

id

config_marc_field_owner_fkey

config.marc_subfield

owner

id

config_marc_subfield_owner_fkey

config.openathens_identity

org_unit

id

config_openathens_identity_ou_fkey

config.org_unit_setting_type_log

org

id

config_org_unit_setting_type_log_fkey

config.patron_loader_header_map

org_unit

id

config_patron_loader_header_map_org_fkey

config.patron_loader_value_map

org_unit

id

config_patron_loader_value_map_org_fkey

config.print_template

owner

id

cpt_owner_fkey

config.remote_account

owner

id

config_remote_account_owner_fkey

config.remoteauth_profile

context_org

id

remoteauth_profile_context_org_fkey

config.ui_staff_portal_page_entry

owner

id

cusppe_owner_fkey

config.weight_assoc

org_unit

id

weight_assoc_org_unit_fkey

config.z3950_source_credentials

owner

id

z3950_source_creds_owner_fkey

container.biblio_record_entry_bucket

owning_lib

id

biblio_record_entry_bucket_owning_lib_fkey

container.biblio_record_entry_bucket_shares

share_org

id

biblio_record_entry_bucket_shares_share_org_fkey

container.call_number_bucket

owning_lib

id

call_number_bucket_owning_lib_fkey

container.carousel

owner

id

carousel_owner_fkey

container.carousel_org_unit

org_unit

id

carousel_org_unit_org_unit_fkey

container.copy_bucket

owning_lib

id

copy_bucket_owning_lib_fkey

container.user_bucket

owning_lib

id

user_bucket_owning_lib_fkey

money.collections_tracker

location

id

collections_tracker_location_fkey

permission.grp_penalty_threshold

org_unit

id

grp_penalty_threshold_org_unit_fkey

permission.grp_tree_display_entry

org

id

grp_tree_display_entry_org_fkey

permission.usr_work_ou_map

work_ou

id

usr_work_ou_map_work_ou_fkey

rating.badge

scope

id

badge_scope_fkey

reporter.output_folder

share_with

id

output_folder_share_with_fkey

reporter.report_folder

share_with

id

report_folder_share_with_fkey

reporter.template_folder

share_with

id

template_folder_share_with_fkey

serial.distribution

holding_lib

id

distribution_holding_lib_fkey

serial.pattern_template

owning_lib

id

pattern_template_owning_lib_fkey

serial.record_entry

owning_lib

id

record_entry_owning_lib_fkey

serial.subscription

owning_lib

id

subscription_owning_lib_fkey

url_verify.session

owning_lib

id

session_owning_lib_fkey

vandelay.import_bib_trash_group

owner

id

import_bib_trash_group_owner_fkey

vandelay.import_item_attr_definition

owner

id

import_item_attr_definition_owner_fkey

vandelay.match_set

owner

id

match_set_owner_fkey

vandelay.merge_profile

owner

id

merge_profile_owner_fkey