actor.org_unit_setting

Org Unit settings

This table contains any arbitrary settings that a client program would like to save for an org unit.

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.

Cascading Deletes: Deleting rows from this table will cascade to: actor.org_unit.

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

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

Columns

Column Type Nullable Default Notes

id PK

bigint

No

nextval('actor.org_unit_setting_id_seq'::regclass)

org_unit FK

integer

No

actor.org_unit(id)

name FK

text

No

config.org_unit_setting_type(name)

value

text

No

Primary Key

(id)

Foreign Keys

Column(s) References On Delete On Update Deferrable Constraint

name

config.org_unit_setting_type(name)

NO ACTION

NO ACTION

DEFERRED

org_unit_setting_name_fkey

org_unit

actor.org_unit(id)

CASCADE

NO ACTION

DEFERRED

org_unit_setting_org_unit_fkey

Unique Constraints

  • ou_once_per_key: (org_unit, name)

Check Constraints

  • aous_must_be_json: CHECK (is_json(value))

Indexes

Index Method Definition

org_unit_setting_pkey PK

btree

CREATE UNIQUE INDEX org_unit_setting_pkey ON actor.org_unit_setting USING btree (id)

ou_once_per_key UNIQUE

btree

CREATE UNIQUE INDEX ou_once_per_key ON actor.org_unit_setting USING btree (org_unit, name)

actor_org_unit_setting_usr_idx

btree

CREATE INDEX actor_org_unit_setting_usr_idx ON actor.org_unit_setting USING btree (org_unit)

Triggers

Trigger Timing Event Level Function

log_ous_change

BEFORE

INSERT OR UPDATE

ROW

evergreen.ous_change_log()

log_ous_del

BEFORE

DELETE

ROW

evergreen.ous_delete_log()

Trigger Bodies

log_ous_change

Function: evergreen.ous_change_log()
Timing: BEFORE INSERT OR UPDATE ROW

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

    DECLARE
    original TEXT;
    BEGIN
        -- Check for which setting is being updated, and log it.
        SELECT INTO original value FROM actor.org_unit_setting WHERE name = NEW.name AND org_unit = NEW.org_unit;

        INSERT INTO config.org_unit_setting_type_log (org,original_value,new_value,field_name) VALUES (NEW.org_unit, original, NEW.value, NEW.name);

        RETURN NEW;
    END;

log_ous_del

Function: evergreen.ous_delete_log()
Timing: BEFORE DELETE ROW

    DECLARE
    original TEXT;
    BEGIN
        -- Check for which setting is being updated, and log it.
        SELECT INTO original value FROM actor.org_unit_setting WHERE name = OLD.name AND org_unit = OLD.org_unit;

        INSERT INTO config.org_unit_setting_type_log (org,original_value,new_value,field_name) VALUES (OLD.org_unit, original, 'null', OLD.name);

        RETURN OLD;
    END;