
DROP VIEW IF EXISTS grouper_attributes_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_group_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_efmship_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_stem_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_member_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_mship_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_attrdef_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_asn_group_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_asn_stem_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_asn_member_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_asn_mship_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_asn_efmship_v cascade;

DROP VIEW IF EXISTS grouper_attr_asn_asn_attrdef_v cascade;

DROP VIEW IF EXISTS grouper_attr_def_name_set_v cascade;

DROP VIEW IF EXISTS grouper_attr_assn_action_set_v cascade;

DROP VIEW IF EXISTS grouper_attr_def_priv_v cascade;

DROP VIEW IF EXISTS grouper_audit_entry_v cascade;

DROP VIEW IF EXISTS grouper_change_log_entry_v cascade;

DROP VIEW IF EXISTS grouper_composites_v cascade;

DROP VIEW IF EXISTS grouper_groups_types_v cascade;

DROP VIEW IF EXISTS grouper_groups_v cascade;

DROP VIEW IF EXISTS grouper_perms_all_v cascade;

DROP VIEW IF EXISTS grouper_perms_role_v cascade;

DROP VIEW IF EXISTS grouper_perms_role_subject_v cascade;

DROP VIEW IF EXISTS grouper_roles_v cascade;

DROP VIEW IF EXISTS grouper_memberships_v cascade;

DROP VIEW IF EXISTS grouper_memberships_lw_v cascade;

DROP VIEW IF EXISTS grouper_mship_attrdef_lw_v cascade;

DROP VIEW IF EXISTS grouper_mship_attr_flat_lw_v cascade;

DROP VIEW IF EXISTS grouper_mship_group_flat_lw_v cascade;

DROP VIEW IF EXISTS grouper_mship_stem_flat_lw_v cascade;

DROP VIEW IF EXISTS grouper_mship_stem_lw_v cascade;

DROP VIEW IF EXISTS grouper_memberships_all_v cascade;

DROP VIEW IF EXISTS grouper_role_set_v cascade;

DROP VIEW IF EXISTS grouper_rpt_attributes_v cascade;

DROP VIEW IF EXISTS grouper_rpt_composites_v cascade;

DROP VIEW IF EXISTS grouper_rpt_group_field_v cascade;

DROP VIEW IF EXISTS grouper_rpt_groups_v cascade;

DROP VIEW IF EXISTS grouper_rpt_members_v cascade;

DROP VIEW IF EXISTS grouper_rpt_roles_v cascade;

DROP VIEW IF EXISTS grouper_rpt_stems_v cascade;

DROP VIEW IF EXISTS grouper_rpt_types_v cascade;

DROP VIEW IF EXISTS grouper_stems_v cascade;
ALTER TABLE grouper_attributes DROP constraint fk_attributes_field_id;
ALTER TABLE grouper_composites DROP constraint fk_composites_owner;
ALTER TABLE grouper_composites DROP constraint fk_composites_left_factor;
ALTER TABLE grouper_composites DROP constraint fk_composites_right_factor;
ALTER TABLE grouper_composites DROP constraint fk_composites_creator_id;
ALTER TABLE grouper_fields DROP constraint fk_fields_grouptype_uuid;
ALTER TABLE grouper_groups DROP constraint fk_groups_parent_stem;
ALTER TABLE grouper_groups DROP constraint fk_groups_creator_id;
ALTER TABLE grouper_groups DROP constraint fk_groups_modifier_id;
ALTER TABLE grouper_groups_types DROP constraint fk_groups_types_group_uuid;
ALTER TABLE grouper_groups_types DROP constraint fk_groups_types_type_uuid;
ALTER TABLE grouper_memberships DROP constraint fk_memberships_member_id;
ALTER TABLE grouper_memberships DROP constraint fk_membership_field_id;
ALTER TABLE grouper_memberships DROP constraint fk_memberships_creator_id;
ALTER TABLE grouper_memberships DROP constraint fk_memberships_group_owner_id;
ALTER TABLE grouper_memberships DROP constraint fk_memberships_stem_owner_id;
ALTER TABLE grouper_memberships DROP constraint fk_memberships_comp_via_id;
ALTER TABLE grouper_memberships DROP constraint fk_mship_attr_def_owner_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_creator_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_field_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_via_group_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_parent_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_owner_attr_def_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_owner_group_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_member_group_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_owner_stem_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_member_stem_id;
ALTER TABLE grouper_group_set DROP constraint fk_group_set_member_field_id;
ALTER TABLE grouper_stems DROP constraint fk_stems_parent_stem;
ALTER TABLE grouper_stems DROP constraint fk_stems_creator_id;
ALTER TABLE grouper_stems DROP constraint fk_stems_modifier_id;
ALTER TABLE grouper_types DROP constraint fk_types_creator_uuid;
ALTER TABLE grouper_audit_entry DROP constraint fk_audit_entry_type_id;
ALTER TABLE grouper_change_log_entry DROP constraint fk_change_log_entry_type_id;
ALTER TABLE grouper_attribute_def DROP constraint fk_attr_def_stem;
ALTER TABLE grouper_attribute_def_name DROP constraint fk_attr_def_name_stem;
ALTER TABLE grouper_attribute_def_name DROP constraint fk_attr_def_name_def_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_action_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_def_name_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_owner_assign_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_owner_def_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_owner_group_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_owner_member_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_owner_mship_id;
ALTER TABLE grouper_attribute_assign DROP constraint fk_attr_assign_owner_stem_id;
ALTER TABLE grouper_attribute_assign_value DROP constraint fk_attr_assign_value_assign_id;
ALTER TABLE grouper_attribute_def_scope DROP constraint fk_attr_def_scope_def_id;
ALTER TABLE grouper_attribute_def_name_set DROP constraint fk_attr_def_name_set_parent;
ALTER TABLE grouper_attribute_def_name_set DROP constraint fk_attr_def_name_if;
ALTER TABLE grouper_attribute_def_name_set DROP constraint fk_attr_def_name_then;
ALTER TABLE grouper_attr_assign_action DROP constraint fk_attr_assn_attr_def_id;
ALTER TABLE grouper_attr_assign_action_set DROP constraint fk_attr_action_set_parent;
ALTER TABLE grouper_attr_assign_action_set DROP constraint fk_attr_action_set_if;
ALTER TABLE grouper_attr_assign_action_set DROP constraint fk_attr_action_set_then;
ALTER TABLE grouper_role_set DROP constraint fk_role_set_parent;
ALTER TABLE grouper_role_set DROP constraint fk_role_if;
ALTER TABLE grouper_role_set DROP constraint fk_role_then;
ALTER TABLE grouper_flat_memberships DROP constraint fk_flat_mship_field_id;
ALTER TABLE grouper_flat_memberships DROP constraint fk_flat_mship_owner_attrdef_id;
ALTER TABLE grouper_flat_memberships DROP constraint fk_flat_mship_owner_group_id;
ALTER TABLE grouper_flat_memberships DROP constraint fk_flat_mship_owner_stem_id;
ALTER TABLE grouper_flat_memberships DROP constraint fk_flat_mship_member_id;
ALTER TABLE grouper_flat_groups DROP constraint fk_flat_group_group_id;
ALTER TABLE grouper_flat_stems DROP constraint fk_flat_stem_stem_id;
ALTER TABLE grouper_flat_attribute_def DROP constraint fk_flat_attrdef_attrdef_id;
DROP INDEX group_set_uniq_idx;

CREATE TABLE grouper_pit_members
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    subject_id VARCHAR(255) NOT NULL,
    subject_source VARCHAR(255) NOT NULL,
    subject_type VARCHAR(255) NOT NULL,
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_fields
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    name VARCHAR(32) NOT NULL,
    type VARCHAR(32) NOT NULL,
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_groups
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    name VARCHAR(1024) NOT NULL,
    stem_id VARCHAR(40) NOT NULL,
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_stems
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    name VARCHAR(1024) NOT NULL,
    parent_stem_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attribute_def
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    name VARCHAR(1024) NOT NULL,
    stem_id VARCHAR(40) NOT NULL,
    attribute_def_type VARCHAR(32) NOT NULL,
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_memberships
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    owner_id VARCHAR(40) NOT NULL,
    owner_attr_def_id VARCHAR(40),
    owner_group_id VARCHAR(40),
    owner_stem_id VARCHAR(40),
    member_id VARCHAR(40) NOT NULL,
    field_id VARCHAR(40) NOT NULL,
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_group_set
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    owner_id VARCHAR(40) NOT NULL,
    owner_attr_def_id VARCHAR(40),
    owner_group_id VARCHAR(40),
    owner_stem_id VARCHAR(40),
    member_id VARCHAR(40) NOT NULL,
    member_attr_def_id VARCHAR(40),
    member_group_id VARCHAR(40),
    member_stem_id VARCHAR(40),
    field_id VARCHAR(40) NOT NULL,
    member_field_id VARCHAR(40) NOT NULL,
    depth INTEGER NOT NULL,
    parent_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attribute_assign
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_def_name_id VARCHAR(40) NOT NULL,
    attribute_assign_action_id VARCHAR(40) NOT NULL,
    attribute_assign_type VARCHAR(15) NOT NULL,
    owner_attribute_assign_id VARCHAR(40),
    owner_attribute_def_id VARCHAR(40),
    owner_group_id VARCHAR(40),
    owner_member_id VARCHAR(40),
    owner_membership_id VARCHAR(40),
    owner_stem_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    disallowed VARCHAR(1),
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attr_assn_value
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attr_assn_actn
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_def_id VARCHAR(40) NOT NULL,
    name VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attr_def_name
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    stem_id VARCHAR(40) NOT NULL,
    attribute_def_id VARCHAR(40) NOT NULL,
    name VARCHAR(1024) NOT NULL,
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attr_def_name_set
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    depth BIGINT NOT NULL,
    if_has_attribute_def_name_id VARCHAR(40) NOT NULL,
    then_has_attribute_def_name_id VARCHAR(40) NOT NULL,
    parent_attr_def_name_set_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_attr_assn_actn_set
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    depth BIGINT NOT NULL,
    if_has_attr_assn_action_id VARCHAR(40) NOT NULL,
    then_has_attr_assn_action_id VARCHAR(40) NOT NULL,
    parent_attr_assn_action_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_pit_role_set
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    depth BIGINT NOT NULL,
    if_has_role_id VARCHAR(40) NOT NULL,
    then_has_role_id VARCHAR(40) NOT NULL,
    parent_role_set_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE TABLE grouper_ext_subj
(
    uuid VARCHAR(40) NOT NULL,
    name VARCHAR(200),
    identifier VARCHAR(300),
    description VARCHAR(500),
    institution VARCHAR(200),
    email VARCHAR(200),
    search_string_lower VARCHAR(4000),
    create_time BIGINT NOT NULL,
    creator_member_id VARCHAR(40) NOT NULL,
    modify_time BIGINT NOT NULL,
    modifier_member_id VARCHAR(40) NOT NULL,
    context_id VARCHAR(40) NOT NULL,
    enabled VARCHAR(1) NOT NULL,
    disabled_time BIGINT,
    hibernate_version_number BIGINT NOT NULL,
    vetted_email_addresses VARCHAR(4000),
    PRIMARY KEY (uuid)
);

CREATE INDEX grouper_ext_subj_cxt_id_idx ON grouper_ext_subj (context_id);

CREATE UNIQUE INDEX grouper_ext_subj_idfr_idx ON grouper_ext_subj (identifier);

CREATE TABLE grouper_ext_subj_attr
(
    uuid VARCHAR(40) NOT NULL,
    attribute_system_name VARCHAR(200) NOT NULL,
    attribute_value VARCHAR(600),
    subject_uuid VARCHAR(40) NOT NULL,
    create_time BIGINT NOT NULL,
    creator_member_id VARCHAR(40) NOT NULL,
    modify_time BIGINT NOT NULL,
    modifier_member_id VARCHAR(40) NOT NULL,
    context_id VARCHAR(40) NOT NULL,
    hibernate_version_number BIGINT NOT NULL,
    PRIMARY KEY (uuid)
);

CREATE INDEX grouper_extsubjattr_cxtid_idx ON grouper_ext_subj_attr (context_id);

CREATE UNIQUE INDEX grouper_extsubjattr_subj_idx ON grouper_ext_subj_attr (subject_uuid, attribute_system_name);

CREATE INDEX grouper_extsubjattr_value_idx ON grouper_ext_subj_attr (attribute_value);

CREATE INDEX attribute_def_type_idx ON grouper_attribute_def (attribute_def_type);

CREATE INDEX change_log_created_on_idx ON grouper_change_log_entry (created_on);

CREATE UNIQUE INDEX group_set_uniq_idx ON grouper_group_set (member_id, field_id, owner_id, parent_id, mship_type);

drop table grouper_flat_memberships cascade;

drop table grouper_flat_groups cascade;

drop table grouper_flat_stems cascade;

drop table grouper_flat_attribute_def cascade;

insert into grouper_pit_fields (id, source_id, name, type, active, start_time, context_id, hibernate_version_number) select id, id, name, type, 'T', '1338919233323000', context_id, '0' from grouper_fields;
commit;


insert into grouper_pit_stems (id, source_id, name, parent_stem_id, active, start_time, context_id, hibernate_version_number) select id, id, name, parent_stem, 'T', '1338919233323000', context_id, '0' from grouper_stems;
commit;


insert into grouper_pit_members (id, source_id, subject_id, subject_source, subject_type, active, start_time, context_id, hibernate_version_number) select id, id, subject_id, subject_source, subject_type, 'T', '1338919233323000', context_id, '0' from grouper_members;
commit;


insert into grouper_pit_group_set (id, source_id, owner_id, owner_attr_def_id, owner_group_id, owner_stem_id, member_id, member_attr_def_id, member_group_id, member_stem_id, field_id, member_field_id, depth, parent_id, active, start_time, context_id, hibernate_version_number) select id, id, owner_id, owner_attr_def_id, owner_group_id, owner_stem_id, member_id, member_attr_def_id, member_group_id, member_stem_id, field_id, member_field_id, depth, parent_id, 'T', '1338919233323000', context_id, '0' from grouper_group_set;
commit;




update grouper_ddl set db_version = 24, last_updated = '2012/06/05 14:00:33', 
history = '2012/06/05 14:00:33: upgrade Grouper from V23 to V24, 2012/06/05 13:52:24: upgrade Grouper from V22 to V23, 2012/06/05 13:52:24: upgrade Grouper from V21 to V22, 2012/06/05 13:52:24: upgrade Grouper from V20 to V21, 2012/06/05 13:52:24: upgrade Grouper from V19 to V20, 2012/06/05 13:52:24: upgrade Grouper from V18 to V19, 2012/06/05 13:52:24: upgrade Grouper from V17 to V18, 2012/06/05 13:52:24: upgrade Grouper from V16 to V17, 2012/06/05 13:52:23: upgrade Grouper from V15 to V16, 2012/06/05 13:52:23: upgrade Grouper from V14 to V15, 2012/06/05 13:52:23: upgrade Grouper from V13 to V14, 2012/06/05 13:52:23: upgrade Grouper from V12 to V13, 2012/06/05 13:52:23: upgrade Grouper from V11 to V12, 2012/06/05 13:52:23: upgrade Grouper from V10 to V11, 2012/06/05 13:52:23: upgrade Grouper from V9 to V10, 2012/06/05 13:52:23: upgrade Grouper from V8 to V9, 2012/06/05 13:52:23: upgrade Grouper from V7 to V8, 2012/06/05 13:52:23: upgrade Grouper from V6 to V7, 2012/06/05 13:52:23: upgrade Grouper from V5 to V6, 2012/06/05 13:52:23: upgrade Grouper from V4 to V5, 2012/06/05 13:52:23: upgrade Grouper from V3 to V4, 2012/06/05 13:52:23: upgrade Grouper from V2 to V3, 2012/06/05 13:52:22: upgrade Grouper from V1 to V2, 2012/06/05 13:52:22: upgrade Grouper from V0 to V1, ' where object_name = 'Grouper';
commit;

ALTER TABLE grouper_attribute_assign
    ADD COLUMN disallowed VARCHAR(1);

ALTER TABLE grouper_groups
    ADD COLUMN last_imm_membership_change BIGINT;

ALTER TABLE grouper_members
    ADD COLUMN description VARCHAR(2048);

CREATE TABLE grouper_members_
(
    id VARCHAR(40) NOT NULL,
    subject_id VARCHAR(255) NOT NULL,
    subject_source VARCHAR(255) NOT NULL,
    subject_type VARCHAR(255) NOT NULL,
    hibernate_version_number BIGINT,
    context_id VARCHAR(40),
    sort_string0 VARCHAR(50),
    sort_string1 VARCHAR(50),
    sort_string2 VARCHAR(50),
    sort_string3 VARCHAR(50),
    sort_string4 VARCHAR(50),
    search_string0 VARCHAR(2048),
    search_string1 VARCHAR(2048),
    search_string2 VARCHAR(2048),
    search_string3 VARCHAR(2048),
    search_string4 VARCHAR(2048),
    name VARCHAR(2048),
    description VARCHAR(2048),
    PRIMARY KEY (id)
);

INSERT INTO grouper_members_ (id,subject_id,subject_source,subject_type,hibernate_version_number,context_id,description) SELECT id,subject_id,subject_source,subject_type,hibernate_version_number,context_id,description FROM grouper_members;

DROP TABLE grouper_members CASCADE;

CREATE TABLE grouper_members
(
    id VARCHAR(40) NOT NULL,
    subject_id VARCHAR(255) NOT NULL,
    subject_source VARCHAR(255) NOT NULL,
    subject_type VARCHAR(255) NOT NULL,
    hibernate_version_number BIGINT,
    context_id VARCHAR(40),
    sort_string0 VARCHAR(50),
    sort_string1 VARCHAR(50),
    sort_string2 VARCHAR(50),
    sort_string3 VARCHAR(50),
    sort_string4 VARCHAR(50),
    search_string0 VARCHAR(2048),
    search_string1 VARCHAR(2048),
    search_string2 VARCHAR(2048),
    search_string3 VARCHAR(2048),
    search_string4 VARCHAR(2048),
    name VARCHAR(2048),
    description VARCHAR(2048),
    PRIMARY KEY (id)
);

CREATE UNIQUE INDEX member_subjectsourcetype_idx ON grouper_members (subject_id, subject_source, subject_type);

CREATE INDEX member_context_idx ON grouper_members (context_id);

CREATE INDEX member_subjectid_idx ON grouper_members (subject_id);

CREATE INDEX member_subjectsource_idx ON grouper_members (subject_source);

CREATE INDEX member_subjecttype_idx ON grouper_members (subject_type);

INSERT INTO grouper_members (id,subject_id,subject_source,subject_type,hibernate_version_number,context_id,sort_string0,sort_string1,sort_string2,sort_string3,sort_string4,search_string0,search_string1,search_string2,search_string3,search_string4,name,description) SELECT id,subject_id,subject_source,subject_type,hibernate_version_number,context_id,sort_string0,sort_string1,sort_string2,sort_string3,sort_string4,search_string0,search_string1,search_string2,search_string3,search_string4,name,description FROM grouper_members_;

DROP TABLE grouper_members_ CASCADE;

CREATE TABLE grouper_pit_attr_assn_value_
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

INSERT INTO grouper_pit_attr_assn_value_ (id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number) SELECT id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number FROM grouper_pit_attr_assn_value;

DROP TABLE grouper_pit_attr_assn_value CASCADE;

CREATE TABLE grouper_pit_attr_assn_value
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

INSERT INTO grouper_pit_attr_assn_value (id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number) SELECT id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number FROM grouper_pit_attr_assn_value_;

DROP TABLE grouper_pit_attr_assn_value_ CASCADE;

CREATE INDEX group_last_imm_membership_idx ON grouper_groups (last_imm_membership_change);

CREATE INDEX member_sort_string0_idx ON grouper_members (sort_string0);

CREATE INDEX member_sort_string1_idx ON grouper_members (sort_string1);

CREATE INDEX member_sort_string2_idx ON grouper_members (sort_string2);

CREATE INDEX member_sort_string3_idx ON grouper_members (sort_string3);

CREATE INDEX member_sort_string4_idx ON grouper_members (sort_string4);

CREATE INDEX member_name_idx ON grouper_members (name);

CREATE INDEX member_description_idx ON grouper_members (description);

CREATE INDEX pit_member_source_id_idx ON grouper_pit_members (source_id);

CREATE INDEX pit_member_subject_id_idx ON grouper_pit_members (subject_id);

CREATE INDEX pit_member_context_idx ON grouper_pit_members (context_id);

CREATE INDEX pit_member_start_idx ON grouper_pit_members (start_time, end_time);

CREATE INDEX pit_member_end_idx ON grouper_pit_members (end_time);

CREATE INDEX pit_field_source_id_idx ON grouper_pit_fields (source_id);

CREATE INDEX pit_field_name_idx ON grouper_pit_fields (name);

CREATE INDEX pit_field_context_idx ON grouper_pit_fields (context_id);

CREATE INDEX pit_field_start_idx ON grouper_pit_fields (start_time, end_time);

CREATE INDEX pit_field_end_idx ON grouper_pit_fields (end_time);

CREATE INDEX pit_group_source_id_idx ON grouper_pit_groups (source_id);

CREATE INDEX pit_group_name_idx ON grouper_pit_groups (name);

CREATE INDEX pit_group_parent_idx ON grouper_pit_groups (stem_id);

CREATE INDEX pit_group_context_idx ON grouper_pit_groups (context_id);

CREATE INDEX pit_group_start_idx ON grouper_pit_groups (start_time, end_time);

CREATE INDEX pit_group_end_idx ON grouper_pit_groups (end_time);

CREATE INDEX pit_stem_source_id_idx ON grouper_pit_stems (source_id);

CREATE INDEX pit_stem_name_idx ON grouper_pit_stems (name);

CREATE INDEX pit_stem_parent_idx ON grouper_pit_stems (parent_stem_id);

CREATE INDEX pit_stem_context_idx ON grouper_pit_stems (context_id);

CREATE INDEX pit_stem_start_idx ON grouper_pit_stems (start_time, end_time);

CREATE INDEX pit_stem_end_idx ON grouper_pit_stems (end_time);

CREATE INDEX pit_attr_def_source_id_idx ON grouper_pit_attribute_def (source_id);

CREATE INDEX pit_attribute_def_name_idx ON grouper_pit_attribute_def (name);

CREATE INDEX pit_attribute_def_parent_idx ON grouper_pit_attribute_def (stem_id);

CREATE INDEX pit_attribute_def_context_idx ON grouper_pit_attribute_def (context_id);

CREATE INDEX pit_attribute_def_type_idx ON grouper_pit_attribute_def (attribute_def_type);

CREATE INDEX pit_attribute_def_start_idx ON grouper_pit_attribute_def (start_time, end_time);

CREATE INDEX pit_attribute_def_end_idx ON grouper_pit_attribute_def (end_time);

CREATE INDEX pit_ms_source_id_idx ON grouper_pit_memberships (source_id);

CREATE INDEX pit_ms_context_idx ON grouper_pit_memberships (context_id);

CREATE INDEX pit_ms_owner_attr_def_idx ON grouper_pit_memberships (owner_attr_def_id);

CREATE INDEX pit_ms_owner_stem_idx ON grouper_pit_memberships (owner_stem_id);

CREATE INDEX pit_ms_owner_group_idx ON grouper_pit_memberships (owner_group_id);

CREATE INDEX pit_ms_member_idx ON grouper_pit_memberships (member_id);

CREATE INDEX pit_ms_field_idx ON grouper_pit_memberships (field_id);

CREATE INDEX pit_ms_owner_field_idx ON grouper_pit_memberships (owner_id, field_id);

CREATE INDEX pit_ms_owner_member_field_idx ON grouper_pit_memberships (owner_id, member_id, field_id);

CREATE INDEX pit_ms_start_idx ON grouper_pit_memberships (start_time, end_time);

CREATE INDEX pit_ms_end_idx ON grouper_pit_memberships (end_time);

CREATE INDEX pit_gs_source_id_idx ON grouper_pit_group_set (source_id);

CREATE INDEX pit_gs_context_idx ON grouper_pit_group_set (context_id);

CREATE INDEX pit_gs_owner_attr_def_idx ON grouper_pit_group_set (owner_attr_def_id);

CREATE INDEX pit_gs_owner_group_idx ON grouper_pit_group_set (owner_group_id);

CREATE INDEX pit_gs_owner_stem_idx ON grouper_pit_group_set (owner_stem_id);

CREATE INDEX pit_gs_member_idx ON grouper_pit_group_set (member_id);

CREATE INDEX pit_gs_member_attr_def_idx ON grouper_pit_group_set (member_attr_def_id);

CREATE INDEX pit_gs_member_group_idx ON grouper_pit_group_set (member_group_id);

CREATE INDEX pit_gs_member_stem_idx ON grouper_pit_group_set (member_stem_id);

CREATE INDEX pit_gs_field_idx ON grouper_pit_group_set (field_id);

CREATE INDEX pit_gs_member_field_idx ON grouper_pit_group_set (member_field_id);

CREATE INDEX pit_gs_parent_idx ON grouper_pit_group_set (parent_id);

CREATE INDEX pit_gs_member_member_field_idx ON grouper_pit_group_set (member_id, member_field_id);

CREATE INDEX pit_gs_group_field_member_idx ON grouper_pit_group_set (owner_group_id, field_id, member_id);

CREATE INDEX pit_gs_owner_field_idx ON grouper_pit_group_set (owner_id, field_id);

CREATE INDEX pit_gs_owner_member_field_idx ON grouper_pit_group_set (owner_id, member_id, field_id);

CREATE INDEX pit_gs_start_idx ON grouper_pit_group_set (start_time, end_time);

CREATE INDEX pit_gs_end_idx ON grouper_pit_group_set (end_time);

CREATE INDEX pit_attr_assn_source_id_idx ON grouper_pit_attribute_assign (source_id);

CREATE INDEX pit_attr_assn_action_idx ON grouper_pit_attribute_assign (attribute_assign_action_id);

CREATE INDEX pit_attr_assn_type_idx ON grouper_pit_attribute_assign (attribute_assign_type);

CREATE INDEX pit_attr_assn_def_name_idx ON grouper_pit_attribute_assign (attribute_def_name_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_own_assn_idx ON grouper_pit_attribute_assign (owner_attribute_assign_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_own_def_idx ON grouper_pit_attribute_assign (owner_attribute_def_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_own_group_idx ON grouper_pit_attribute_assign (owner_group_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_own_mem_idx ON grouper_pit_attribute_assign (owner_member_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_own_mship_idx ON grouper_pit_attribute_assign (owner_membership_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_own_stem_idx ON grouper_pit_attribute_assign (owner_stem_id, attribute_assign_action_id);

CREATE INDEX pit_attr_assn_start_idx ON grouper_pit_attribute_assign (start_time, end_time);

CREATE INDEX pit_attr_assn_end_idx ON grouper_pit_attribute_assign (end_time);

CREATE INDEX pit_attr_val_source_id_idx ON grouper_pit_attr_assn_value (source_id);

CREATE INDEX pit_attr_val_assign_idx ON grouper_pit_attr_assn_value (attribute_assign_id);

CREATE INDEX pit_attr_val_string_idx ON grouper_pit_attr_assn_value (value_string);

CREATE INDEX pit_attr_val_integer_idx ON grouper_pit_attr_assn_value (value_integer);

CREATE INDEX pit_attr_val_floating_idx ON grouper_pit_attr_assn_value (value_floating);

CREATE INDEX pit_attr_val_member_id_idx ON grouper_pit_attr_assn_value (value_member_id);

CREATE INDEX pit_attr_val_start_idx ON grouper_pit_attr_assn_value (start_time, end_time);

CREATE INDEX pit_attr_val_end_idx ON grouper_pit_attr_assn_value (end_time);

CREATE INDEX pit_attr_asn_act_source_id_idx ON grouper_pit_attr_assn_actn (source_id);

CREATE INDEX pit_attr_assn_act_def_id_idx ON grouper_pit_attr_assn_actn (attribute_def_id);

CREATE INDEX pit_attr_assn_act_start_idx ON grouper_pit_attr_assn_actn (start_time, end_time);

CREATE INDEX pit_attr_assn_act_end_idx ON grouper_pit_attr_assn_actn (end_time);

CREATE INDEX pit_attrdef_name_srcid_idx ON grouper_pit_attr_def_name (source_id);

CREATE INDEX pit_attr_def_name_name_idx ON grouper_pit_attr_def_name (name);

CREATE INDEX pit_attr_def_name_stem_idx ON grouper_pit_attr_def_name (stem_id);

CREATE INDEX pit_attr_def_name_def_idx ON grouper_pit_attr_def_name (attribute_def_id);

CREATE INDEX pit_attr_def_name_start_idx ON grouper_pit_attr_def_name (start_time, end_time);

CREATE INDEX pit_attr_def_name_end_idx ON grouper_pit_attr_def_name (end_time);

CREATE INDEX pit_attrdef_name_set_srcid_idx ON grouper_pit_attr_def_name_set (source_id);

CREATE INDEX pit_attr_def_name_set_if_idx ON grouper_pit_attr_def_name_set (if_has_attribute_def_name_id);

CREATE INDEX pit_attr_def_name_set_then_idx ON grouper_pit_attr_def_name_set (then_has_attribute_def_name_id);

CREATE INDEX pit_attr_def_name_set_prnt_idx ON grouper_pit_attr_def_name_set (parent_attr_def_name_set_id);

CREATE INDEX pit_attr_def_name_set_strt_idx ON grouper_pit_attr_def_name_set (start_time, end_time);

CREATE INDEX pit_attr_def_name_set_end_idx ON grouper_pit_attr_def_name_set (end_time);

CREATE INDEX pit_action_set_source_id_idx ON grouper_pit_attr_assn_actn_set (source_id);

CREATE INDEX pit_action_set_if_idx ON grouper_pit_attr_assn_actn_set (if_has_attr_assn_action_id);

CREATE INDEX pit_action_set_then_idx ON grouper_pit_attr_assn_actn_set (then_has_attr_assn_action_id);

CREATE INDEX pit_action_set_parent_idx ON grouper_pit_attr_assn_actn_set (parent_attr_assn_action_id);

CREATE INDEX pit_action_set_start_idx ON grouper_pit_attr_assn_actn_set (start_time, end_time);

CREATE INDEX pit_action_set_end_idx ON grouper_pit_attr_assn_actn_set (end_time);

CREATE INDEX pit_rs_source_id_idx ON grouper_pit_role_set (source_id);

CREATE INDEX pit_rs_if_idx ON grouper_pit_role_set (if_has_role_id);

CREATE INDEX pit_rs_then_idx ON grouper_pit_role_set (then_has_role_id);

CREATE INDEX pit_rs_parent_idx ON grouper_pit_role_set (parent_role_set_id);

CREATE INDEX pit_rs_start_idx ON grouper_pit_role_set (start_time, end_time);

CREATE INDEX pit_rs_end_idx ON grouper_pit_role_set (end_time);


update grouper_ddl set db_version = 25, last_updated = '2012/06/05 14:00:35', 
history = '2012/06/05 14:00:35: upgrade Grouper from V24 to V25, 2012/06/05 14:00:33: upgrade Grouper from V23 to V24, 2012/06/05 13:52:24: upgrade Grouper from V22 to V23, 2012/06/05 13:52:24: upgrade Grouper from V21 to V22, 2012/06/05 13:52:24: upgrade Grouper from V20 to V21, 2012/06/05 13:52:24: upgrade Grouper from V19 to V20, 2012/06/05 13:52:24: upgrade Grouper from V18 to V19, 2012/06/05 13:52:24: upgrade Grouper from V17 to V18, 2012/06/05 13:52:24: upgrade Grouper from V16 to V17, 2012/06/05 13:52:23: upgrade Grouper from V15 to V16, 2012/06/05 13:52:23: upgrade Grouper from V14 to V15, 2012/06/05 13:52:23: upgrade Grouper from V13 to V14, 2012/06/05 13:52:23: upgrade Grouper from V12 to V13, 2012/06/05 13:52:23: upgrade Grouper from V11 to V12, 2012/06/05 13:52:23: upgrade Grouper from V10 to V11, 2012/06/05 13:52:23: upgrade Grouper from V9 to V10, 2012/06/05 13:52:23: upgrade Grouper from V8 to V9, 2012/06/05 13:52:23: upgrade Grouper from V7 to V8, 2012/06/05 13:52:23: upgrade Grouper from V6 to V7, 2012/06/05 13:52:23: upgrade Grouper from V5 to V6, 2012/06/05 13:52:23: upgrade Grouper from V4 to V5, 2012/06/05 13:52:23: upgrade Grouper from V3 to V4, 2012/06/05 13:52:23: upgrade Grouper from V2 to V3, 2012/06/05 13:52:22: upgrade Grouper from V1 to V2, 2012/06/05 13:52:22: upgrade Grouper from V0 to V1, ' where object_name = 'Grouper';
commit;

DROP INDEX composite_composite_idx;

ALTER TABLE grouper_stems
    ADD COLUMN alternate_name VARCHAR(255);

CREATE TABLE grouper_pit_attr_assn_value_
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

INSERT INTO grouper_pit_attr_assn_value_ (id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number) SELECT id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number FROM grouper_pit_attr_assn_value;

DROP TABLE grouper_pit_attr_assn_value CASCADE;

CREATE TABLE grouper_pit_attr_assn_value
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE INDEX pit_attr_val_source_id_idx ON grouper_pit_attr_assn_value (source_id);

CREATE INDEX pit_attr_val_assign_idx ON grouper_pit_attr_assn_value (attribute_assign_id);

CREATE INDEX pit_attr_val_string_idx ON grouper_pit_attr_assn_value (value_string);

CREATE INDEX pit_attr_val_integer_idx ON grouper_pit_attr_assn_value (value_integer);

CREATE INDEX pit_attr_val_floating_idx ON grouper_pit_attr_assn_value (value_floating);

CREATE INDEX pit_attr_val_member_id_idx ON grouper_pit_attr_assn_value (value_member_id);

CREATE INDEX pit_attr_val_start_idx ON grouper_pit_attr_assn_value (start_time, end_time);

CREATE INDEX pit_attr_val_end_idx ON grouper_pit_attr_assn_value (end_time);

INSERT INTO grouper_pit_attr_assn_value (id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number) SELECT id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number FROM grouper_pit_attr_assn_value_;

DROP TABLE grouper_pit_attr_assn_value_ CASCADE;

CREATE UNIQUE INDEX composite_composite_idx ON grouper_composites (owner);

CREATE INDEX stem_alternate_name_idx ON grouper_stems (alternate_name);


update grouper_ddl set db_version = 26, last_updated = '2012/06/05 14:00:36', 
history = '2012/06/05 14:00:36: upgrade Grouper from V25 to V26, 2012/06/05 14:00:35: upgrade Grouper from V24 to V25, 2012/06/05 14:00:33: upgrade Grouper from V23 to V24, 2012/06/05 13:52:24: upgrade Grouper from V22 to V23, 2012/06/05 13:52:24: upgrade Grouper from V21 to V22, 2012/06/05 13:52:24: upgrade Grouper from V20 to V21, 2012/06/05 13:52:24: upgrade Grouper from V19 to V20, 2012/06/05 13:52:24: upgrade Grouper from V18 to V19, 2012/06/05 13:52:24: upgrade Grouper from V17 to V18, 2012/06/05 13:52:24: upgrade Grouper from V16 to V17, 2012/06/05 13:52:23: upgrade Grouper from V15 to V16, 2012/06/05 13:52:23: upgrade Grouper from V14 to V15, 2012/06/05 13:52:23: upgrade Grouper from V13 to V14, 2012/06/05 13:52:23: upgrade Grouper from V12 to V13, 2012/06/05 13:52:23: upgrade Grouper from V11 to V12, 2012/06/05 13:52:23: upgrade Grouper from V10 to V11, 2012/06/05 13:52:23: upgrade Grouper from V9 to V10, 2012/06/05 13:52:23: upgrade Grouper from V8 to V9, 2012/06/05 13:52:23: upgrade Grouper from V7 to V8, 2012/06/05 13:52:23: upgrade Grouper from V6 to V7, 2012/06/05 13:52:23: upgrade Grouper from V5 to V6, 2012/06/05 13:52:23: upgrade Grouper from V4 to V5, 2012/06/05 13:52:23: upgrade Grouper from V3 to V4, 2012/06/05 13:52:23: upgrade Grouper from V2 to V3, 2012/06/05 13:52:22: upgrade Grouper from V1 to V2, 2012/06/05 13:52:22: upgrade Grouper from V0 to V1, ' where object_name = 'Grouper';
commit;

CREATE TABLE grouper_pit_attr_assn_value_
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

INSERT INTO grouper_pit_attr_assn_value_ (id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number) SELECT id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number FROM grouper_pit_attr_assn_value;

DROP TABLE grouper_pit_attr_assn_value CASCADE;

CREATE TABLE grouper_pit_attr_assn_value
(
    id VARCHAR(40) NOT NULL,
    source_id VARCHAR(40) NOT NULL,
    attribute_assign_id VARCHAR(40) NOT NULL,
    value_integer BIGINT,
    value_floating DOUBLE PRECISION,
    value_string VARCHAR(4000),
    value_member_id VARCHAR(40),
    active VARCHAR(1) NOT NULL,
    start_time BIGINT NOT NULL,
    end_time BIGINT,
    context_id VARCHAR(40),
    hibernate_version_number BIGINT,
    PRIMARY KEY (id)
);

CREATE INDEX pit_attr_val_source_id_idx ON grouper_pit_attr_assn_value (source_id);

CREATE INDEX pit_attr_val_assign_idx ON grouper_pit_attr_assn_value (attribute_assign_id);

CREATE INDEX pit_attr_val_string_idx ON grouper_pit_attr_assn_value (value_string);

CREATE INDEX pit_attr_val_integer_idx ON grouper_pit_attr_assn_value (value_integer);

CREATE INDEX pit_attr_val_floating_idx ON grouper_pit_attr_assn_value (value_floating);

CREATE INDEX pit_attr_val_member_id_idx ON grouper_pit_attr_assn_value (value_member_id);

CREATE INDEX pit_attr_val_start_idx ON grouper_pit_attr_assn_value (start_time, end_time);

CREATE INDEX pit_attr_val_end_idx ON grouper_pit_attr_assn_value (end_time);

INSERT INTO grouper_pit_attr_assn_value (id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number) SELECT id,source_id,attribute_assign_id,value_integer,value_floating,value_string,value_member_id,active,start_time,end_time,context_id,hibernate_version_number FROM grouper_pit_attr_assn_value_;

DROP TABLE grouper_pit_attr_assn_value_ CASCADE;

ALTER TABLE grouper_attr_assign_action
    ADD CONSTRAINT fk_attr_assn_attr_def_id FOREIGN KEY (attribute_def_id) REFERENCES grouper_attribute_def (id);

ALTER TABLE grouper_attr_assign_action_set
    ADD CONSTRAINT fk_attr_action_set_parent FOREIGN KEY (parent_attr_assn_action_id) REFERENCES grouper_attr_assign_action_set (id);

ALTER TABLE grouper_attr_assign_action_set
    ADD CONSTRAINT fk_attr_action_set_if FOREIGN KEY (if_has_attr_assn_action_id) REFERENCES grouper_attr_assign_action (id);

ALTER TABLE grouper_attr_assign_action_set
    ADD CONSTRAINT fk_attr_action_set_then FOREIGN KEY (then_has_attr_assn_action_id) REFERENCES grouper_attr_assign_action (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_action_id FOREIGN KEY (attribute_assign_action_id) REFERENCES grouper_attr_assign_action (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_def_name_id FOREIGN KEY (attribute_def_name_id) REFERENCES grouper_attribute_def_name (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_owner_assign_id FOREIGN KEY (owner_attribute_assign_id) REFERENCES grouper_attribute_assign (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_owner_def_id FOREIGN KEY (owner_attribute_def_id) REFERENCES grouper_attribute_def (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_owner_group_id FOREIGN KEY (owner_group_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_owner_member_id FOREIGN KEY (owner_member_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_owner_mship_id FOREIGN KEY (owner_membership_id) REFERENCES grouper_memberships (id);

ALTER TABLE grouper_attribute_assign
    ADD CONSTRAINT fk_attr_assign_owner_stem_id FOREIGN KEY (owner_stem_id) REFERENCES grouper_stems (id);

ALTER TABLE grouper_attribute_assign_value
    ADD CONSTRAINT fk_attr_assign_value_assign_id FOREIGN KEY (attribute_assign_id) REFERENCES grouper_attribute_assign (id);

ALTER TABLE grouper_attribute_def
    ADD CONSTRAINT fk_attr_def_stem FOREIGN KEY (stem_id) REFERENCES grouper_stems (id);

ALTER TABLE grouper_attribute_def_name
    ADD CONSTRAINT fk_attr_def_name_stem FOREIGN KEY (stem_id) REFERENCES grouper_stems (id);

ALTER TABLE grouper_attribute_def_name
    ADD CONSTRAINT fk_attr_def_name_def_id FOREIGN KEY (attribute_def_id) REFERENCES grouper_attribute_def (id);

ALTER TABLE grouper_attribute_def_name_set
    ADD CONSTRAINT fk_attr_def_name_set_parent FOREIGN KEY (parent_attr_def_name_set_id) REFERENCES grouper_attribute_def_name_set (id);

ALTER TABLE grouper_attribute_def_name_set
    ADD CONSTRAINT fk_attr_def_name_if FOREIGN KEY (if_has_attribute_def_name_id) REFERENCES grouper_attribute_def_name (id);

ALTER TABLE grouper_attribute_def_name_set
    ADD CONSTRAINT fk_attr_def_name_then FOREIGN KEY (then_has_attribute_def_name_id) REFERENCES grouper_attribute_def_name (id);

ALTER TABLE grouper_attribute_def_scope
    ADD CONSTRAINT fk_attr_def_scope_def_id FOREIGN KEY (attribute_def_id) REFERENCES grouper_attribute_def (id);

ALTER TABLE grouper_attributes
    ADD CONSTRAINT fk_attributes_field_id FOREIGN KEY (field_id) REFERENCES grouper_fields (id);

ALTER TABLE grouper_audit_entry
    ADD CONSTRAINT fk_audit_entry_type_id FOREIGN KEY (audit_type_id) REFERENCES grouper_audit_type (id);

ALTER TABLE grouper_change_log_entry
    ADD CONSTRAINT fk_change_log_entry_type_id FOREIGN KEY (change_log_type_id) REFERENCES grouper_change_log_type (id);

ALTER TABLE grouper_composites
    ADD CONSTRAINT fk_composites_owner FOREIGN KEY (owner) REFERENCES grouper_groups (id);

ALTER TABLE grouper_composites
    ADD CONSTRAINT fk_composites_left_factor FOREIGN KEY (left_factor) REFERENCES grouper_groups (id);

ALTER TABLE grouper_composites
    ADD CONSTRAINT fk_composites_right_factor FOREIGN KEY (right_factor) REFERENCES grouper_groups (id);

ALTER TABLE grouper_composites
    ADD CONSTRAINT fk_composites_creator_id FOREIGN KEY (creator_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_fields
    ADD CONSTRAINT fk_fields_grouptype_uuid FOREIGN KEY (grouptype_uuid) REFERENCES grouper_types (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_creator_id FOREIGN KEY (creator_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_field_id FOREIGN KEY (field_id) REFERENCES grouper_fields (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_via_group_id FOREIGN KEY (via_group_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_parent_id FOREIGN KEY (parent_id) REFERENCES grouper_group_set (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_owner_attr_def_id FOREIGN KEY (owner_attr_def_id) REFERENCES grouper_attribute_def (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_owner_group_id FOREIGN KEY (owner_group_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_member_group_id FOREIGN KEY (member_group_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_owner_stem_id FOREIGN KEY (owner_stem_id) REFERENCES grouper_stems (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_member_stem_id FOREIGN KEY (member_stem_id) REFERENCES grouper_stems (id);

ALTER TABLE grouper_group_set
    ADD CONSTRAINT fk_group_set_member_field_id FOREIGN KEY (member_field_id) REFERENCES grouper_fields (id);

ALTER TABLE grouper_groups
    ADD CONSTRAINT fk_groups_parent_stem FOREIGN KEY (parent_stem) REFERENCES grouper_stems (id);

ALTER TABLE grouper_groups
    ADD CONSTRAINT fk_groups_creator_id FOREIGN KEY (creator_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_groups
    ADD CONSTRAINT fk_groups_modifier_id FOREIGN KEY (modifier_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_groups_types
    ADD CONSTRAINT fk_groups_types_group_uuid FOREIGN KEY (group_uuid) REFERENCES grouper_groups (id);

ALTER TABLE grouper_groups_types
    ADD CONSTRAINT fk_groups_types_type_uuid FOREIGN KEY (type_uuid) REFERENCES grouper_types (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_memberships_member_id FOREIGN KEY (member_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_membership_field_id FOREIGN KEY (field_id) REFERENCES grouper_fields (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_memberships_creator_id FOREIGN KEY (creator_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_memberships_group_owner_id FOREIGN KEY (owner_group_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_memberships_stem_owner_id FOREIGN KEY (owner_stem_id) REFERENCES grouper_stems (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_memberships_comp_via_id FOREIGN KEY (via_composite_id) REFERENCES grouper_composites (id);

ALTER TABLE grouper_memberships
    ADD CONSTRAINT fk_mship_attr_def_owner_id FOREIGN KEY (owner_attr_def_id) REFERENCES grouper_attribute_def (id);

ALTER TABLE grouper_role_set
    ADD CONSTRAINT fk_role_set_parent FOREIGN KEY (parent_role_set_id) REFERENCES grouper_role_set (id);

ALTER TABLE grouper_role_set
    ADD CONSTRAINT fk_role_if FOREIGN KEY (if_has_role_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_role_set
    ADD CONSTRAINT fk_role_then FOREIGN KEY (then_has_role_id) REFERENCES grouper_groups (id);

ALTER TABLE grouper_stems
    ADD CONSTRAINT fk_stems_parent_stem FOREIGN KEY (parent_stem) REFERENCES grouper_stems (id);

ALTER TABLE grouper_stems
    ADD CONSTRAINT fk_stems_creator_id FOREIGN KEY (creator_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_stems
    ADD CONSTRAINT fk_stems_modifier_id FOREIGN KEY (modifier_id) REFERENCES grouper_members (id);

ALTER TABLE grouper_types
    ADD CONSTRAINT fk_types_creator_uuid FOREIGN KEY (creator_uuid) REFERENCES grouper_members (id);

ALTER TABLE grouper_pit_groups
    ADD CONSTRAINT fk_pit_group_stem FOREIGN KEY (stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_stems
    ADD CONSTRAINT fk_pit_stem_parent FOREIGN KEY (parent_stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_attribute_def
    ADD CONSTRAINT fk_pit_attr_def_stem FOREIGN KEY (stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_memberships
    ADD CONSTRAINT fk_pit_ms_owner_attrdef_id FOREIGN KEY (owner_attr_def_id) REFERENCES grouper_pit_attribute_def (id);

ALTER TABLE grouper_pit_memberships
    ADD CONSTRAINT fk_pit_ms_owner_group_id FOREIGN KEY (owner_group_id) REFERENCES grouper_pit_groups (id);

ALTER TABLE grouper_pit_memberships
    ADD CONSTRAINT fk_pit_ms_owner_stem_id FOREIGN KEY (owner_stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_memberships
    ADD CONSTRAINT fk_pit_ms_member_id FOREIGN KEY (member_id) REFERENCES grouper_pit_members (id);

ALTER TABLE grouper_pit_memberships
    ADD CONSTRAINT fk_pit_ms_field_id FOREIGN KEY (field_id) REFERENCES grouper_pit_fields (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_owner_attrdef_id FOREIGN KEY (owner_attr_def_id) REFERENCES grouper_pit_attribute_def (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_owner_group_id FOREIGN KEY (owner_group_id) REFERENCES grouper_pit_groups (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_owner_stem_id FOREIGN KEY (owner_stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_member_attrdef_id FOREIGN KEY (member_attr_def_id) REFERENCES grouper_pit_attribute_def (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_member_group_id FOREIGN KEY (member_group_id) REFERENCES grouper_pit_groups (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_member_stem_id FOREIGN KEY (member_stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_field_id FOREIGN KEY (field_id) REFERENCES grouper_pit_fields (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_member_field_id FOREIGN KEY (member_field_id) REFERENCES grouper_pit_fields (id);

ALTER TABLE grouper_pit_group_set
    ADD CONSTRAINT fk_pit_gs_parent_id FOREIGN KEY (parent_id) REFERENCES grouper_pit_group_set (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_action_id FOREIGN KEY (attribute_assign_action_id) REFERENCES grouper_pit_attr_assn_actn (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_def_name_id FOREIGN KEY (attribute_def_name_id) REFERENCES grouper_pit_attr_def_name (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_owner_assn_id FOREIGN KEY (owner_attribute_assign_id) REFERENCES grouper_pit_attribute_assign (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_owner_def_id FOREIGN KEY (owner_attribute_def_id) REFERENCES grouper_pit_attribute_def (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_owner_grp_id FOREIGN KEY (owner_group_id) REFERENCES grouper_pit_groups (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_owner_mem_id FOREIGN KEY (owner_member_id) REFERENCES grouper_pit_members (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_owner_ms_id FOREIGN KEY (owner_membership_id) REFERENCES grouper_pit_memberships (id);

ALTER TABLE grouper_pit_attribute_assign
    ADD CONSTRAINT fk_pit_attr_assn_owner_stem_id FOREIGN KEY (owner_stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_attr_assn_value
    ADD CONSTRAINT fk_pit_attr_assn_value_assn_id FOREIGN KEY (attribute_assign_id) REFERENCES grouper_pit_attribute_assign (id);

ALTER TABLE grouper_pit_attr_assn_actn
    ADD CONSTRAINT fk_pit_attr_assn_attr_def_id FOREIGN KEY (attribute_def_id) REFERENCES grouper_pit_attribute_def (id);

ALTER TABLE grouper_pit_attr_def_name
    ADD CONSTRAINT fk_pit_attr_def_name_stem FOREIGN KEY (stem_id) REFERENCES grouper_pit_stems (id);

ALTER TABLE grouper_pit_attr_def_name
    ADD CONSTRAINT fk_pit_attr_def_name_def_id FOREIGN KEY (attribute_def_id) REFERENCES grouper_pit_attribute_def (id);

ALTER TABLE grouper_pit_attr_def_name_set
    ADD CONSTRAINT fk_pit_attr_def_name_set_parnt FOREIGN KEY (parent_attr_def_name_set_id) REFERENCES grouper_pit_attr_def_name_set (id);

ALTER TABLE grouper_pit_attr_def_name_set
    ADD CONSTRAINT fk_pit_attr_def_name_if FOREIGN KEY (if_has_attribute_def_name_id) REFERENCES grouper_pit_attr_def_name (id);

ALTER TABLE grouper_pit_attr_def_name_set
    ADD CONSTRAINT fk_pit_attr_def_name_then FOREIGN KEY (then_has_attribute_def_name_id) REFERENCES grouper_pit_attr_def_name (id);

ALTER TABLE grouper_pit_attr_assn_actn_set
    ADD CONSTRAINT fk_pit_attr_action_set_parent FOREIGN KEY (parent_attr_assn_action_id) REFERENCES grouper_pit_attr_assn_actn_set (id);

ALTER TABLE grouper_pit_attr_assn_actn_set
    ADD CONSTRAINT fk_pit_attr_action_set_if FOREIGN KEY (if_has_attr_assn_action_id) REFERENCES grouper_pit_attr_assn_actn (id);

ALTER TABLE grouper_pit_attr_assn_actn_set
    ADD CONSTRAINT fk_pit_attr_action_set_then FOREIGN KEY (then_has_attr_assn_action_id) REFERENCES grouper_pit_attr_assn_actn (id);

ALTER TABLE grouper_pit_role_set
    ADD CONSTRAINT fk_pit_role_set_parent FOREIGN KEY (parent_role_set_id) REFERENCES grouper_pit_role_set (id);

ALTER TABLE grouper_pit_role_set
    ADD CONSTRAINT fk_pit_role_if FOREIGN KEY (if_has_role_id) REFERENCES grouper_pit_groups (id);

ALTER TABLE grouper_pit_role_set
    ADD CONSTRAINT fk_pit_role_then FOREIGN KEY (then_has_role_id) REFERENCES grouper_pit_groups (id);

ALTER TABLE grouper_ext_subj_attr
    ADD CONSTRAINT fk_ext_subj_attr_subj_uuid FOREIGN KEY (subject_uuid) REFERENCES grouper_ext_subj (uuid);

COMMENT ON TABLE grouper_ddl IS 'holds a record for each database object name, and db version, and java version';

COMMENT ON COLUMN grouper_ddl.id IS 'uuid of this ddl record';

COMMENT ON COLUMN grouper_ddl.object_name IS 'Corresponds to an enum in grouper.ddl package (with Ddl on end), represents one module, so grouper itself is one object';

COMMENT ON COLUMN grouper_ddl.db_version IS 'Version of this object as far as DB knows about';

COMMENT ON COLUMN grouper_ddl.last_updated IS 'last update timestamp, string so it can easily be used from update statement';

COMMENT ON COLUMN grouper_ddl.history IS 'history of this object name, with most recent first (truncated after 4k)';

COMMENT ON TABLE grouper_attr_assign_action IS 'list of actions that are available for attributes';

COMMENT ON COLUMN grouper_attr_assign_action.attribute_def_id IS 'attribute definition foreign key';

COMMENT ON COLUMN grouper_attr_assign_action.context_id IS 'context id in the auditing table';

COMMENT ON COLUMN grouper_attr_assign_action.created_on IS 'number of millis since 1970 when this was created';

COMMENT ON COLUMN grouper_attr_assign_action.id IS 'uuid of this record';

COMMENT ON COLUMN grouper_attr_assign_action.last_updated IS 'number of millis since 1970 when this was created';

COMMENT ON COLUMN grouper_attr_assign_action.name IS 'name of this action';

COMMENT ON COLUMN grouper_attr_assign_action.hibernate_version_number IS 'optimistic locking for grouper updates/deletes';

COMMENT ON TABLE grouper_pit_attr_assn_actn IS 'point in time: list of actions that are available for attributes';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.attribute_def_id IS 'attribute definition foreign key';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.context_id IS 'context id in the auditing table';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.active IS 'T or F for if this row is active, based on start and end time';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.start_time IS 'number of millis since 1970 when this row was inserted';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.end_time IS 'number of millis since 1970 when this row was deleted';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.id IS 'uuid of this record';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.name IS 'name of this action';

COMMENT ON COLUMN grouper_pit_attr_assn_actn.hibernate_version_number IS 'optimistic locking for grouper updates/deletes';

COMMENT ON TABLE grouper_attr_assign_action_set IS 'relationships in action inheritance... e.g. admin action implies read and write actions.  also holds effective relationships';

COMMENT ON COLUMN grouper_attr_assign_action_set.context_id IS 'uuid for the audit table';

COMMENT ON COLUMN grouper_attr_assign_action_set.created_on IS 'millis since 1970 when this row was created';

COMMENT ON COLUMN grouper_attr_assign_action_set.depth IS 'number of hops from one node to another, immediate is one';

COMMENT ON COLUMN grouper_attr_assign_action_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_attr_assign_action_set.if_has_attr_assn_action_id IS 'uuid foreign key of left hand side of this relationship, if you have this action, it implies the then_has action';

COMMENT ON COLUMN grouper_attr_assign_action_set.last_updated IS 'millis since 1970 when this was last updated';

COMMENT ON COLUMN grouper_attr_assign_action_set.parent_attr_assn_action_id IS 'if this is not immediate, then this is the row that puts this relationship n-1 almost there';

COMMENT ON COLUMN grouper_attr_assign_action_set.then_has_attr_assn_action_id IS 'uuid foreign key of the right hand side of this relationship, if you have the if_has action, then you have this one';

COMMENT ON COLUMN grouper_attr_assign_action_set.type IS 'from enum AttributeAssignActionType: self, immediate, effective';

COMMENT ON COLUMN grouper_attr_assign_action_set.hibernate_version_number IS 'hibernate optimistic locking number for updates and deletes';

COMMENT ON TABLE grouper_pit_attr_assn_actn_set IS 'point in time relationships in action inheritance... e.g. admin action implies read and write actions.  also holds effective relationships';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.context_id IS 'uuid for the audit table';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.active IS 'T or F for if this row is active based on start and end times';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.start_time IS 'millis since 1970 that this row was inserted';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.end_time IS 'millis since 1970 that this row was deleted';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.depth IS 'number of hops from one node to another, immediate is one';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.if_has_attr_assn_action_id IS 'uuid foreign key of left hand side of this relationship, if you have this action, it implies the then_has action';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.parent_attr_assn_action_id IS 'if this is not immediate, then this is the row that puts this relationship n-1 almost there';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.then_has_attr_assn_action_id IS 'uuid foreign key of the right hand side of this relationship, if you have the if_has action, then you have this one';

COMMENT ON COLUMN grouper_pit_attr_assn_actn_set.hibernate_version_number IS 'hibernate optimistic locking number for updates and deletes';

COMMENT ON TABLE grouper_attribute_assign IS 'table that assigns an attribute def name to an owner (one of various types), and has an action';

COMMENT ON COLUMN grouper_attribute_assign.attribute_assign_action_id IS 'foreign key to the action which is in this attribute assignment, or permissions, it could be custom, for attributes, it is assign';

COMMENT ON COLUMN grouper_attribute_assign.attribute_assign_delegatable IS 'AttributeAssignDelegatable enum, TRUE, FALSE, or GRANT (can grant to someone else)';

COMMENT ON COLUMN grouper_attribute_assign.attribute_assign_type IS 'AttributeAssignType enum, what is the type of owner: any_mem, any_mem_asgn, attr_def, attr_def_asgn, group, group_asgn, imm_mem, imm_mem_asgn, mem_asgn, member, stem, stem_asgn';

COMMENT ON COLUMN grouper_attribute_assign.attribute_def_name_id IS 'foreign key to the attribute def name is which attribute is assigned';

COMMENT ON COLUMN grouper_attribute_assign.context_id IS 'links this row to an audit record';

COMMENT ON COLUMN grouper_attribute_assign.created_on IS 'number of millis since 1970 when this was created';

COMMENT ON COLUMN grouper_attribute_assign.disabled_time IS 'null if not disabled, or the number of millis since 1970 when this was or will be disabled.  if in the future, Grouper will disable this row at that time.';

COMMENT ON COLUMN grouper_attribute_assign.disallowed IS 'T or F for if disallowed';

COMMENT ON COLUMN grouper_attribute_assign.enabled_time IS 'number of millis since 1970 when this was or will be enabled.  if it future then this row will not be enabled';

COMMENT ON COLUMN grouper_attribute_assign.id IS 'uuid of row';

COMMENT ON COLUMN grouper_attribute_assign.last_updated IS 'millis since 1970 when this row was last updated';

COMMENT ON COLUMN grouper_attribute_assign.notes IS 'notes about this assignment to describe why it exists or anything else, freeform';

COMMENT ON COLUMN grouper_attribute_assign.owner_attribute_assign_id IS 'if this is an assignment on an assignment, then this is the foreign key to this table which is which assignment owns this assignment';

COMMENT ON COLUMN grouper_attribute_assign.owner_attribute_def_id IS 'if this is an assignment on an attribute definition, then this is the foreign key to the attribute definition table';

COMMENT ON COLUMN grouper_attribute_assign.owner_group_id IS 'if this is an assignment on a group or role or effective membership then this is the foreign key to the grouper_groups table';

COMMENT ON COLUMN grouper_attribute_assign.owner_member_id IS 'if this is an assignment on a member or effective membership, then this is the foreign key to the grouper_members table';

COMMENT ON COLUMN grouper_attribute_assign.owner_membership_id IS 'if this is an assignment on an immediate membership, then this is the foreign key to the grouper_memberships table';

COMMENT ON COLUMN grouper_attribute_assign.owner_stem_id IS 'if this is an assignment on a stem aka folder, then this is the foreign key to the grouper_stems table';

COMMENT ON COLUMN grouper_attribute_assign.hibernate_version_number IS 'optimistic locking column for hibernate on updates or deletes';

COMMENT ON COLUMN grouper_attribute_assign.enabled IS 'T or F to indicate if this assignment is enabled';

COMMENT ON TABLE grouper_pit_attribute_assign IS 'point in time table that assigns an attribute def name to an owner (one of various types), and has an action';

COMMENT ON COLUMN grouper_pit_attribute_assign.attribute_assign_action_id IS 'foreign key to the action which is in this attribute assignment, or permissions, it could be custom, for attributes, it is assign';

COMMENT ON COLUMN grouper_pit_attribute_assign.active IS 'T of F for if this row is active or not based on start and end dates';

COMMENT ON COLUMN grouper_pit_attribute_assign.start_time IS 'number of millis since 1970 that this row was inserted';

COMMENT ON COLUMN grouper_pit_attribute_assign.end_time IS 'number of millis since 1970 that this row was deleted';

COMMENT ON COLUMN grouper_pit_attribute_assign.attribute_assign_type IS 'AttributeAssignType enum, what is the type of owner: any_mem, any_mem_asgn, attr_def, attr_def_asgn, group, group_asgn, imm_mem, imm_mem_asgn, mem_asgn, member, stem, stem_asgn';

COMMENT ON COLUMN grouper_pit_attribute_assign.attribute_def_name_id IS 'foreign key to the attribute def name is which attribute is assigned';

COMMENT ON COLUMN grouper_pit_attribute_assign.context_id IS 'links this row to an audit record';

COMMENT ON COLUMN grouper_pit_attribute_assign.disallowed IS 'T or F for if disallowed or not';

COMMENT ON COLUMN grouper_pit_attribute_assign.id IS 'uuid of row';

COMMENT ON COLUMN grouper_pit_attribute_assign.owner_attribute_assign_id IS 'if this is an assignment on an assignment, then this is the foreign key to this table which is which assignment owns this assignment';

COMMENT ON COLUMN grouper_pit_attribute_assign.owner_attribute_def_id IS 'if this is an assignment on an attribute definition, then this is the foreign key to the attribute definition table';

COMMENT ON COLUMN grouper_pit_attribute_assign.owner_group_id IS 'if this is an assignment on a group or role or effective membership then this is the foreign key to the grouper_groups table';

COMMENT ON COLUMN grouper_pit_attribute_assign.owner_member_id IS 'if this is an assignment on a member or effective membership, then this is the foreign key to the grouper_members table';

COMMENT ON COLUMN grouper_pit_attribute_assign.owner_membership_id IS 'if this is an assignment on an immediate membership, then this is the foreign key to the grouper_memberships table';

COMMENT ON COLUMN grouper_pit_attribute_assign.owner_stem_id IS 'if this is an assignment on a stem aka folder, then this is the foreign key to the grouper_stems table';

COMMENT ON COLUMN grouper_pit_attribute_assign.hibernate_version_number IS 'optimistic locking column for hibernate on updates or deletes';

COMMENT ON TABLE grouper_attribute_def IS 'table that holds attribute definitions, which is the first part of the attribute framework';

COMMENT ON COLUMN grouper_attribute_def.assign_to_attribute_def IS 'T or F if you can assign this attribute to an attribute definition';

COMMENT ON COLUMN grouper_attribute_def.assign_to_attribute_def_assn IS 'T or F if you can assign this attribute to an assignment on an attribute definition';

COMMENT ON COLUMN grouper_attribute_def.assign_to_eff_membership IS 'T or F if you you can assign this attribute to an effective membership: group/member pair';

COMMENT ON COLUMN grouper_attribute_def.assign_to_eff_membership_assn IS 'T or F if you can assign this attribute to an effective membership attribute assignment: group/member pair';

COMMENT ON COLUMN grouper_attribute_def.assign_to_group IS 'T or F if you can assign this attribute to a group or role';

COMMENT ON COLUMN grouper_attribute_def.assign_to_group_assn IS 'T or F if you can assign this attribute to an assignment on a group or role';

COMMENT ON COLUMN grouper_attribute_def.assign_to_imm_membership IS 'T or F if you can assign this attribute to an immediate membership';

COMMENT ON COLUMN grouper_attribute_def.assign_to_imm_membership_assn IS 'T or F if you can assign this attribute to an attribute assignment on an immediate membership';

COMMENT ON COLUMN grouper_attribute_def.assign_to_member IS 'T or F if you can assign this attribute to a member';

COMMENT ON COLUMN grouper_attribute_def.assign_to_member_assn IS 'T or F if you can assign this attribute to an assignment on a member';

COMMENT ON COLUMN grouper_attribute_def.assign_to_stem IS 'T or F if you can assign this attribute to a stem/folder';

COMMENT ON COLUMN grouper_attribute_def.assign_to_stem_assn IS 'T or F if you can assign this attribute to an assignment on an attribute definition';

COMMENT ON COLUMN grouper_attribute_def.attribute_def_public IS 'T or F if this is a public attribute';

COMMENT ON COLUMN grouper_attribute_def.attribute_def_type IS 'AttributeDefType enum: attr, domain, type, limit, perm';

COMMENT ON COLUMN grouper_attribute_def.context_id IS 'links back to the grouper audit entry table';

COMMENT ON COLUMN grouper_attribute_def.created_on IS 'number of millis since 1970 when this row was created';

COMMENT ON COLUMN grouper_attribute_def.creator_id IS 'member id of the subject who created this row';

COMMENT ON COLUMN grouper_attribute_def.description IS 'freeform text that describes this attribute definition';

COMMENT ON COLUMN grouper_attribute_def.extension IS 'system name in the folder of this attribute definition';

COMMENT ON COLUMN grouper_attribute_def.id IS 'uuid of this record';

COMMENT ON COLUMN grouper_attribute_def.last_updated IS 'number of millis since 1970 when this row was last updated';

COMMENT ON COLUMN grouper_attribute_def.multi_assignable IS 'T or F if you can assign this attribute to the same owner twice';

COMMENT ON COLUMN grouper_attribute_def.multi_valued IS 'T or F if this assignment can have multiple values';

COMMENT ON COLUMN grouper_attribute_def.name IS 'full system name including system folder names separated by colons';

COMMENT ON COLUMN grouper_attribute_def.stem_id IS 'uuid of the stem/folder where this attribute definition lives';

COMMENT ON COLUMN grouper_attribute_def.value_type IS 'AttributeAssignValueType enum: floating, integerValue, memberId, nullValue, string';

COMMENT ON COLUMN grouper_attribute_def.hibernate_version_number IS 'hibernate version number for optimistic locking during updates and deletes';

COMMENT ON TABLE grouper_pit_attribute_def IS 'point in time table that holds attribute definitions, which is the first part of the attribute framework';

COMMENT ON COLUMN grouper_pit_attribute_def.attribute_def_type IS 'AttributeDefType enum: attr, domain, type, limit, perm';

COMMENT ON COLUMN grouper_pit_attribute_def.context_id IS 'links back to the grouper audit entry table';

COMMENT ON COLUMN grouper_pit_attribute_def.id IS 'uuid of this record';

COMMENT ON COLUMN grouper_pit_attribute_def.name IS 'full system name including system folder names separated by colons';

COMMENT ON COLUMN grouper_pit_attribute_def.stem_id IS 'uuid of the stem/folder where this attribute definition lives';

COMMENT ON COLUMN grouper_pit_attribute_def.hibernate_version_number IS 'hibernate version number for optimistic locking during updates and deletes';

COMMENT ON COLUMN grouper_pit_attribute_def.active IS 'T or F if this row is active based on start and end time';

COMMENT ON COLUMN grouper_pit_attribute_def.start_time IS 'millis since 1970 that this row was inserted';

COMMENT ON COLUMN grouper_pit_attribute_def.end_time IS 'millis since 1970 that this row was deleted';

COMMENT ON TABLE grouper_attribute_def_name IS 'table that holds attribute names, which is the second part of the attribute framework, along with the attribute definition';

COMMENT ON COLUMN grouper_attribute_def_name.attribute_def_id IS 'uuid foreign key links back to the attribute definition';

COMMENT ON COLUMN grouper_attribute_def_name.context_id IS 'uuid that links to the audit entry table';

COMMENT ON COLUMN grouper_attribute_def_name.created_on IS 'number of millis since 1970 when this row was created';

COMMENT ON COLUMN grouper_attribute_def_name.description IS 'freeform description of this attribute name';

COMMENT ON COLUMN grouper_attribute_def_name.display_extension IS 'display name (can change) of this attribute name, not including the stem/folder names';

COMMENT ON COLUMN grouper_attribute_def_name.display_name IS 'display name (can change) of this attribute name, including the display names of folders separated by colons';

COMMENT ON COLUMN grouper_attribute_def_name.extension IS 'system name (should not change often) of this attribute name, not including the stem/folder names';

COMMENT ON COLUMN grouper_attribute_def_name.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_attribute_def_name.last_updated IS 'number of millis since 1970 when this row was created';

COMMENT ON COLUMN grouper_attribute_def_name.name IS 'system name (should not change often) of this attribute name, including the stem/folder system names separated by colons';

COMMENT ON COLUMN grouper_attribute_def_name.stem_id IS 'uuid of the stem where this attribute name lives';

COMMENT ON COLUMN grouper_attribute_def_name.hibernate_version_number IS 'optimistic locking column for this row for updates and deletes';

COMMENT ON TABLE grouper_pit_attr_def_name IS 'point in time table that holds attribute names, which is the second part of the attribute framework, along with the attribute definition';

COMMENT ON COLUMN grouper_pit_attr_def_name.attribute_def_id IS 'uuid foreign key links back to the attribute definition';

COMMENT ON COLUMN grouper_pit_attr_def_name.context_id IS 'uuid that links to the audit entry table';

COMMENT ON COLUMN grouper_pit_attr_def_name.active IS 'T or F if this row is active based on start and end times';

COMMENT ON COLUMN grouper_pit_attr_def_name.start_time IS 'millis since 1970 that this row was inserted';

COMMENT ON COLUMN grouper_pit_attr_def_name.end_time IS 'millis since 1970 that this row was deleted';

COMMENT ON COLUMN grouper_pit_attr_def_name.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_pit_attr_def_name.name IS 'system name (should not change often) of this attribute name, including the stem/folder system names separated by colons';

COMMENT ON COLUMN grouper_pit_attr_def_name.stem_id IS 'uuid of the stem where this attribute name lives';

COMMENT ON COLUMN grouper_pit_attr_def_name.hibernate_version_number IS 'optimistic locking column for this row for updates and deletes';

COMMENT ON TABLE grouper_attribute_def_scope IS 'table that holds rules for where attributes can be assigned (i.e. only to objects in a certain folder etc)';

COMMENT ON COLUMN grouper_attribute_def_scope.attribute_def_id IS 'foreign key to the uuid of the attribute definition: grouper_attribute_def';

COMMENT ON COLUMN grouper_attribute_def_scope.attribute_def_scope_type IS 'AttributeDefScopeType enum: attributeDefNameIdAssigned, idEquals, inStem, nameEquals, nameLike, sourceId';

COMMENT ON COLUMN grouper_attribute_def_scope.context_id IS 'uuid of the audit entry';

COMMENT ON COLUMN grouper_attribute_def_scope.created_on IS 'number of millis since 1970 when this was created';

COMMENT ON COLUMN grouper_attribute_def_scope.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_attribute_def_scope.last_updated IS 'number of millis since 1970 when this attribute was last updated';

COMMENT ON COLUMN grouper_attribute_def_scope.scope_string IS 'describes where this can be assigned depending on the type of this constraint';

COMMENT ON COLUMN grouper_attribute_def_scope.scope_string2 IS 'describes where this can be assigned depending on the type of this constraint';

COMMENT ON COLUMN grouper_attribute_def_scope.hibernate_version_number IS 'optimistic locking column used by hibernate for updates and deletes';

COMMENT ON TABLE grouper_attribute_def_name_set IS 'table that holds immediate and effective relationships for attribute names that are permissions for inheritance... e.g. artsAndSciences implies english';

COMMENT ON COLUMN grouper_attribute_def_name_set.context_id IS 'uuid of the audit entry for the last change of this record';

COMMENT ON COLUMN grouper_attribute_def_name_set.created_on IS 'number of millis since 1970 when this record was created';

COMMENT ON COLUMN grouper_attribute_def_name_set.depth IS 'number of hops from one node to another: 0 is self, 1 is immediate, etc';

COMMENT ON COLUMN grouper_attribute_def_name_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_attribute_def_name_set.if_has_attribute_def_name_id IS 'left hand side of this relationship: if it has this uuid of foreign key of grouper_attribute_def_name then it implies the then_has column';

COMMENT ON COLUMN grouper_attribute_def_name_set.last_updated IS 'number of millis since 1970 when this row was last updated';

COMMENT ON COLUMN grouper_attribute_def_name_set.parent_attr_def_name_set_id IS 'link to the relationship above this one (hops-1)';

COMMENT ON COLUMN grouper_attribute_def_name_set.then_has_attribute_def_name_id IS 'right hand side of this relationship: if it has the if_has then it implies this uuid of the foreign key of the grouper_attribute_def_name';

COMMENT ON COLUMN grouper_attribute_def_name_set.type IS 'AttributeDefAssignmentType enum: effective, immediate, self';

COMMENT ON COLUMN grouper_attribute_def_name_set.hibernate_version_number IS 'column for hibernate optimistic locking for updates and deletes';

COMMENT ON TABLE grouper_pit_attr_def_name_set IS 'point in time: table that holds immediate and effective relationships for attribute names that are permissions for inheritance... e.g. artsAndSciences implies english';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.context_id IS 'uuid of the audit entry for the last change of this record';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.active IS 'T or F if this row is active based on start and end times';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.start_time IS 'number of millis since 1970 when this row was inserted';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.end_time IS 'number of millis since 1970 when this row was deleted';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.depth IS 'number of hops from one node to another: 0 is self, 1 is immediate, etc';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.if_has_attribute_def_name_id IS 'left hand side of this relationship: if it has this uuid of foreign key of grouper_attribute_def_name then it implies the then_has column';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.parent_attr_def_name_set_id IS 'link to the relationship above this one (hops-1)';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.then_has_attribute_def_name_id IS 'right hand side of this relationship: if it has the if_has then it implies this uuid of the foreign key of the grouper_attribute_def_name';

COMMENT ON COLUMN grouper_pit_attr_def_name_set.hibernate_version_number IS 'column for hibernate optimistic locking for updates and deletes';

COMMENT ON TABLE grouper_attribute_assign_value IS 'value assignment on an attribute assignment';

COMMENT ON COLUMN grouper_attribute_assign_value.attribute_assign_id IS 'foreign key to the attribute assignment grouper_attribute_assign for this assignment';

COMMENT ON COLUMN grouper_attribute_assign_value.context_id IS 'uuid of the audit entry for the last action on this row';

COMMENT ON COLUMN grouper_attribute_assign_value.created_on IS 'number of millis since 1970 when this row was created';

COMMENT ON COLUMN grouper_attribute_assign_value.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_attribute_assign_value.last_updated IS 'number of millis since 1970 when this row was last updated';

COMMENT ON COLUMN grouper_attribute_assign_value.value_floating IS 'if this is a floating type attribute definition, this is the value';

COMMENT ON COLUMN grouper_attribute_assign_value.value_integer IS 'if this is an integer type attribute definition, this is the value';

COMMENT ON COLUMN grouper_attribute_assign_value.value_member_id IS 'if this is a member type attribute definition, this is the value';

COMMENT ON COLUMN grouper_attribute_assign_value.value_string IS 'if this is a string type attribute definition, this is the value';

COMMENT ON COLUMN grouper_attribute_assign_value.hibernate_version_number IS 'hibernate optimistic locking column for updates and deletes';

COMMENT ON TABLE grouper_pit_attr_assn_value IS 'point in time history of value assignment on an attribute assignment';

COMMENT ON COLUMN grouper_pit_attr_assn_value.attribute_assign_id IS 'foreign key to the attribute assignment grouper_attribute_assign for this assignment';

COMMENT ON COLUMN grouper_pit_attr_assn_value.context_id IS 'uuid of the audit entry for the last action on this row';

COMMENT ON COLUMN grouper_pit_attr_assn_value.start_time IS 'number of millis since 1970 when this row started in point in time';

COMMENT ON COLUMN grouper_pit_attr_assn_value.end_time IS 'number of millis since 1970 when this row ended in point in time';

COMMENT ON COLUMN grouper_pit_attr_assn_value.active IS 'T or F if this is an active record based on start and end dates';

COMMENT ON COLUMN grouper_pit_attr_assn_value.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_pit_attr_assn_value.end_time IS 'number of millis since 1970 when this row row ended in point in time';

COMMENT ON COLUMN grouper_pit_attr_assn_value.value_floating IS 'if this is a floating type attribute definition, this is the value';

COMMENT ON COLUMN grouper_pit_attr_assn_value.value_integer IS 'if this is an integer type attribute definition, this is the value';

COMMENT ON COLUMN grouper_pit_attr_assn_value.value_member_id IS 'if this is a member type attribute definition, this is the value';

COMMENT ON COLUMN grouper_pit_attr_assn_value.value_string IS 'if this is a string type attribute definition, this is the value';

COMMENT ON COLUMN grouper_pit_attr_assn_value.hibernate_version_number IS 'hibernate optimistic locking column for updates and deletes';

COMMENT ON TABLE grouper_change_log_type IS 'type of this change log entry, e.g. an insert into grouper groups';

COMMENT ON COLUMN grouper_change_log_type.action_name IS 'action name, e.g. addGroup, deleteMember';

COMMENT ON COLUMN grouper_change_log_type.change_log_category IS 'action category, e.g. group, member';

COMMENT ON COLUMN grouper_change_log_type.context_id IS 'uuid of the change log entry for this row';

COMMENT ON COLUMN grouper_change_log_type.created_on IS 'number of millis since 1970 when this row was created';

COMMENT ON COLUMN grouper_change_log_type.hibernate_version_number IS 'hibernate version for optimistic locking for updates and deletes';

COMMENT ON COLUMN grouper_change_log_type.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_change_log_type.label_string01 IS 'label of the 01 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string02 IS 'label of the 02 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string03 IS 'label of the 03 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string04 IS 'label of the 04 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string05 IS 'label of the 05 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string06 IS 'label of the 06 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string07 IS 'label of the 07 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string08 IS 'label of the 08 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string09 IS 'label of the 09 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string10 IS 'label of the 10 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string11 IS 'label of the 11 string entry';

COMMENT ON COLUMN grouper_change_log_type.label_string12 IS 'label of the 12 string entry';

COMMENT ON COLUMN grouper_change_log_type.last_updated IS 'number of millis since 1970 when this row was last changed';

COMMENT ON TABLE grouper_change_log_consumer IS 'table keeps track of change log consumers so if they stop, they will start at the place where they left off in processing change log entries';

COMMENT ON COLUMN grouper_change_log_consumer.created_on IS 'number of millis since 1970 when this record was created';

COMMENT ON COLUMN grouper_change_log_consumer.hibernate_version_number IS 'hibernate optimistic locking versioning column for updates and deletes';

COMMENT ON COLUMN grouper_change_log_consumer.id IS 'UUID of this row';

COMMENT ON COLUMN grouper_change_log_consumer.last_sequence_processed IS 'index of the change log row which was last processed by this consumer';

COMMENT ON COLUMN grouper_change_log_consumer.last_updated IS 'millis since 1970 that this row was last updated';

COMMENT ON COLUMN grouper_change_log_consumer.name IS 'name of the consumer';

COMMENT ON TABLE grouper_change_log_entry_temp IS 'rows are inserted here in the transaction of the actual action, e.g. an add member.  The change log daemon will move records from here to the change log entry table in order, to be processed by consumers';

COMMENT ON COLUMN grouper_change_log_entry_temp.change_log_type_id IS 'foreign key to the grouper_change_log_type table';

COMMENT ON COLUMN grouper_change_log_entry_temp.context_id IS 'uuid to the grouper_audit_entry table';

COMMENT ON COLUMN grouper_change_log_entry_temp.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_change_log_entry_temp.string01 IS 'value of the string for value 01 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string02 IS 'value of the string for value 02 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string03 IS 'value of the string for value 03 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string04 IS 'value of the string for value 04 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string05 IS 'value of the string for value 05 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string06 IS 'value of the string for value 06 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string07 IS 'value of the string for value 07 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string08 IS 'value of the string for value 08 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string09 IS 'value of the string for value 09 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string10 IS 'value of the string for value 10 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string11 IS 'value of the string for value 11 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.string12 IS 'value of the string for value 12 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry_temp.created_on IS 'number of thousandths of millis from 1970 when this row was created';

COMMENT ON TABLE grouper_change_log_entry IS 'The change log daemon will move records from grouper_change_log_entry_temp to this table in time order, to be processed by consumers';

COMMENT ON COLUMN grouper_change_log_entry.change_log_type_id IS 'foreign key to the grouper_change_log_type table, the type of action';

COMMENT ON COLUMN grouper_change_log_entry.context_id IS 'uuid referencing the grouper_audit_entry table';

COMMENT ON COLUMN grouper_change_log_entry.created_on IS 'number of thousandths of millis from 1970 when this row was created';

COMMENT ON COLUMN grouper_change_log_entry.sequence_number IS 'integer which is in order which these records should be processed by change log consumers';

COMMENT ON COLUMN grouper_change_log_entry.string01 IS 'value of the string for value 01 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string02 IS 'value of the string for value 02 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string03 IS 'value of the string for value 03 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string04 IS 'value of the string for value 04 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string05 IS 'value of the string for value 05 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string06 IS 'value of the string for value 06 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string07 IS 'value of the string for value 07 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string08 IS 'value of the string for value 08 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string09 IS 'value of the string for value 09 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string10 IS 'value of the string for value 10 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string11 IS 'value of the string for value 11 which corresponds to the grouper_change_log_type table label';

COMMENT ON COLUMN grouper_change_log_entry.string12 IS 'value of the string for value 12 which corresponds to the grouper_change_log_type table label';

COMMENT ON TABLE grouper_group_set IS 'This table holds relationships for memberships or privileges on groups, stems, attributes.  This allows quick joining of who is in a group effectively';

COMMENT ON COLUMN grouper_group_set.context_id IS 'uuid that links to the grouper_audit_entry';

COMMENT ON COLUMN grouper_group_set.create_time IS 'number of millis since 1970 that this row was created';

COMMENT ON COLUMN grouper_group_set.creator_id IS 'uuid of grouper_members of who created this row';

COMMENT ON COLUMN grouper_group_set.depth IS '0 for self, 1 for immediate, or more for effective.  this is the number of hops between nodes';

COMMENT ON COLUMN grouper_group_set.field_id IS 'uuid foreign key from grouper_fields which is the list of the membership, normally members or the privilege in question';

COMMENT ON COLUMN grouper_group_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_group_set.member_attr_def_id IS 'foreign key of grouper_attribute_def of the member record';

COMMENT ON COLUMN grouper_group_set.member_field_id IS 'uuid foreign key from grouper_fields which is the list of the membership, normally members';

COMMENT ON COLUMN grouper_group_set.member_group_id IS 'uuid to the grouper_groups table which is the group that is a member of the owner';

COMMENT ON COLUMN grouper_group_set.member_id IS 'whether this is groups, stems, or attribute definitions, this is the member';

COMMENT ON COLUMN grouper_group_set.member_stem_id IS 'uuid to the grouper_stems table which is the stem that is implied by the owner';

COMMENT ON COLUMN grouper_group_set.mship_type IS 'MembershipType enum, effective or immediate';

COMMENT ON COLUMN grouper_group_set.owner_attr_def_id IS 'uuid to the grouper_attribute_def table which is the owner of this record, which implies a relationship to the member, if null, it will have (NULL) which helps with some DB vendors';

COMMENT ON COLUMN grouper_group_set.owner_attr_def_id_null IS 'uuid to the grouper_attribute_def table which is the owner of this record, which implies a relationship to the member, if null, it will be null';

COMMENT ON COLUMN grouper_group_set.owner_group_id IS 'uuid to the grouper_groups table which is the owner of this record, which implies a membership to the member uuid, if null, it will be (NULL) which helps with some DB vendors';

COMMENT ON COLUMN grouper_group_set.owner_group_id_null IS 'uuid to the grouper_groups table which is the owner of this record, which implies a membership to the member uuid, if null, it will be null';

COMMENT ON COLUMN grouper_group_set.owner_id IS 'whether this is ';

COMMENT ON COLUMN grouper_group_set.owner_stem_id IS 'uuid to the grouper_stems table which is the owner of this record, which implies a privilege to the member uuid, if null, it will be (NULL) which helps with some DB vendors';

COMMENT ON COLUMN grouper_group_set.owner_stem_id_null IS 'uuid to the grouper_stems table which is the owner of this record, which implies a privilege to the member uuid, if null, it will be null';

COMMENT ON COLUMN grouper_group_set.parent_id IS 'this is the link back to the grouper_group_set table which is the one one hop away and related to this one...';

COMMENT ON COLUMN grouper_group_set.via_group_id IS 'same as member_group_id if depth is not 0 otherwise null';

COMMENT ON COLUMN grouper_group_set.hibernate_version_number IS 'optimistic locking column for hibernate used for updates and deletes';

COMMENT ON TABLE grouper_pit_group_set IS 'point in time: This table holds relationships for memberships or privileges on groups, stems, attributes.  This allows quick joining of who is in a group effectively';

COMMENT ON COLUMN grouper_pit_group_set.context_id IS 'uuid that links to the grouper_audit_entry';

COMMENT ON COLUMN grouper_pit_group_set.active IS 'T or F for if this is active, based on start and end time';

COMMENT ON COLUMN grouper_pit_group_set.start_time IS 'number of millis since 1970 that this row was created';

COMMENT ON COLUMN grouper_pit_group_set.end_time IS 'number of millis since 1970 that this row was deleted';

COMMENT ON COLUMN grouper_pit_group_set.depth IS '0 for self, 1 for immediate, or more for effective.  this is the number of hops between nodes';

COMMENT ON COLUMN grouper_pit_group_set.field_id IS 'uuid foreign key from grouper_fields which is the list of the membership, normally members or the privilege in question';

COMMENT ON COLUMN grouper_pit_group_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_pit_group_set.member_attr_def_id IS 'foreign key of grouper_attribute_def of the member record';

COMMENT ON COLUMN grouper_pit_group_set.member_field_id IS 'uuid foreign key from grouper_fields which is the list of the membership, normally members';

COMMENT ON COLUMN grouper_pit_group_set.member_group_id IS 'uuid to the grouper_groups table which is the group that is a member of the owner';

COMMENT ON COLUMN grouper_pit_group_set.member_id IS 'whether this is groups, stems, or attribute definitions, this is the member';

COMMENT ON COLUMN grouper_pit_group_set.member_stem_id IS 'uuid to the grouper_stems table which is the stem that is implied by the owner';

COMMENT ON COLUMN grouper_pit_group_set.owner_attr_def_id IS 'uuid to the grouper_attribute_def table which is the owner of this record, which implies a relationship to the member, if null, it will have (NULL) which helps with some DB vendors';

COMMENT ON COLUMN grouper_pit_group_set.owner_group_id IS 'uuid to the grouper_groups table which is the owner of this record, which implies a membership to the member uuid, if null, it will be (NULL) which helps with some DB vendors';

COMMENT ON COLUMN grouper_pit_group_set.owner_id IS 'whether this is ';

COMMENT ON COLUMN grouper_pit_group_set.owner_stem_id IS 'uuid to the grouper_stems table which is the owner of this record, which implies a privilege to the member uuid, if null, it will be (NULL) which helps with some DB vendors';

COMMENT ON COLUMN grouper_pit_group_set.parent_id IS 'this is the link back to the grouper_group_set table which is the one one hop away and related to this one...';

COMMENT ON COLUMN grouper_pit_group_set.hibernate_version_number IS 'optimistic locking column for hibernate used for updates and deletes';

COMMENT ON TABLE grouper_role_set IS 'This table holds relationships between roles if one role inherits permissions from another role';

COMMENT ON COLUMN grouper_role_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_role_set.context_id IS 'links to the grouper_audit_entry for the last change of this row';

COMMENT ON COLUMN grouper_role_set.created_on IS 'millis since 1970 that this row was created';

COMMENT ON COLUMN grouper_role_set.depth IS 'number of hops across the relationship, 0 means self, 1 is immediate, more is effective';

COMMENT ON COLUMN grouper_role_set.if_has_role_id IS 'this is the foreign key uuid in grouper_groups where if the user has this role then they get the permissions assigned to another role then_has';

COMMENT ON COLUMN grouper_role_set.last_updated IS 'millis since 1970 when this row was last updated';

COMMENT ON COLUMN grouper_role_set.parent_role_set_id IS 'this is the foreign key to the uuid in this table grouper_role_set which is the next closest to the underlying assignment';

COMMENT ON COLUMN grouper_role_set.then_has_role_id IS 'this is the foreign key uuid in grouper_gropus where if the user has the if_has role then the user gets the permissions assigned to this then_has role';

COMMENT ON COLUMN grouper_role_set.type IS 'RoleHierarchyType enum: self, immediate, effective';

COMMENT ON COLUMN grouper_role_set.hibernate_version_number IS 'optimistic logging integer used by hibernate during updates and deletes';

COMMENT ON TABLE grouper_pit_role_set IS 'point in time: This table holds relationships between roles if one role inherits permissions from another role';

COMMENT ON COLUMN grouper_pit_role_set.context_id IS 'links to the grouper_audit_entry for the last change of this row';

COMMENT ON COLUMN grouper_pit_role_set.id IS 'uuid of this row';

COMMENT ON COLUMN grouper_pit_role_set.active IS 'T or F for if this row is active based on start time and end time';

COMMENT ON COLUMN grouper_pit_role_set.start_time IS 'number of millis since 1970 that this row was inserted';

COMMENT ON COLUMN grouper_pit_role_set.end_time IS 'number of millis since 1970 that this row was deleted';

COMMENT ON COLUMN grouper_pit_role_set.depth IS 'number of hops across the relationship, 0 means self, 1 is immediate, more is effective';

COMMENT ON COLUMN grouper_pit_role_set.if_has_role_id IS 'this is the foreign key uuid in grouper_groups where if the user has this role then they get the permissions assigned to another role then_has';

COMMENT ON COLUMN grouper_pit_role_set.parent_role_set_id IS 'this is the foreign key to the uuid in this table grouper_role_set which is the next closest to the underlying assignment';

COMMENT ON COLUMN grouper_pit_role_set.then_has_role_id IS 'this is the foreign key uuid in grouper_gropus where if the user has the if_has role then the user gets the permissions assigned to this then_has role';

COMMENT ON COLUMN grouper_pit_role_set.hibernate_version_number IS 'optimistic logging integer used by hibernate during updates and deletes';

COMMENT ON TABLE grouper_attributes IS 'attributes for groups, including name, extension, etc';

COMMENT ON COLUMN grouper_attributes.id IS 'db id of this attribute record';

COMMENT ON COLUMN grouper_attributes.group_id IS 'group_uuid foreign key';

COMMENT ON COLUMN grouper_attributes.field_id IS 'foreign key to field by id';

COMMENT ON COLUMN grouper_attributes.value IS 'value this attribute record';

COMMENT ON COLUMN grouper_attributes.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_attributes.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_audit_entry IS 'holds one record for each audit entry record which is a high level action that ties together lower level actions';

COMMENT ON COLUMN grouper_audit_entry.act_as_member_id IS 'Member id (foreign key) of the user who is being acted as';

COMMENT ON COLUMN grouper_audit_entry.audit_type_id IS 'foreign key to the grouper_audit_type table which is the type of this entry';

COMMENT ON COLUMN grouper_audit_entry.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_audit_entry.created_on IS 'When this audit entry record was created';

COMMENT ON COLUMN grouper_audit_entry.description IS 'Description is a sentence form expression of what is being audited';

COMMENT ON COLUMN grouper_audit_entry.env_name IS 'environment label of the system running, from grouper.properties';

COMMENT ON COLUMN grouper_audit_entry.grouper_engine IS 'Grouper engine is e.g. UI, WS, GSH, loader, etc';

COMMENT ON COLUMN grouper_audit_entry.grouper_version IS 'Grouper version of the API executing';

COMMENT ON COLUMN grouper_audit_entry.hibernate_version_number IS 'hibernate version number keeps track of if multiple sessions step on toes';

COMMENT ON COLUMN grouper_audit_entry.id IS 'db id of this audit entry record';

COMMENT ON COLUMN grouper_audit_entry.int01 IS 'The int 01 value';

COMMENT ON COLUMN grouper_audit_entry.int02 IS 'The int 02 value';

COMMENT ON COLUMN grouper_audit_entry.int03 IS 'The int 03 value';

COMMENT ON COLUMN grouper_audit_entry.int04 IS 'The int 04 value';

COMMENT ON COLUMN grouper_audit_entry.int05 IS 'The int 05 value';

COMMENT ON COLUMN grouper_audit_entry.last_updated IS 'When this audit entry was last updated';

COMMENT ON COLUMN grouper_audit_entry.logged_in_member_id IS 'Member id (foreign key) of the user logged in';

COMMENT ON COLUMN grouper_audit_entry.server_host IS 'Host of the system running the grouper API';

COMMENT ON COLUMN grouper_audit_entry.string01 IS 'The string 01 value';

COMMENT ON COLUMN grouper_audit_entry.string02 IS 'The string 02 value';

COMMENT ON COLUMN grouper_audit_entry.string03 IS 'The string 03 value';

COMMENT ON COLUMN grouper_audit_entry.string04 IS 'The string 04 value';

COMMENT ON COLUMN grouper_audit_entry.string05 IS 'The string 05 value';

COMMENT ON COLUMN grouper_audit_entry.string06 IS 'The string 06 value';

COMMENT ON COLUMN grouper_audit_entry.string07 IS 'The string 07 value';

COMMENT ON COLUMN grouper_audit_entry.string08 IS 'The string 08 value';

COMMENT ON COLUMN grouper_audit_entry.user_ip_address IS 'IP address of the user connecting to the system (e.g. from UI or WS)';

COMMENT ON COLUMN grouper_audit_entry.duration_microseconds IS 'Duration of the context, in microseconds (millionths of a second)';

COMMENT ON COLUMN grouper_audit_entry.query_count IS 'Number of database queries required for this context';

COMMENT ON COLUMN grouper_audit_entry.server_user_name IS 'Username of the OS user running the API.  This might identify who ran a GSH call';

COMMENT ON TABLE grouper_audit_type IS 'audit type is a category and an action that organizes audits.  Also holds labels for all the misc string and int fields';

COMMENT ON COLUMN grouper_audit_type.action_name IS 'The action in this audit category to differentiate from others';

COMMENT ON COLUMN grouper_audit_type.audit_category IS 'The category of this audit in logical grouping';

COMMENT ON COLUMN grouper_audit_type.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_audit_type.created_on IS 'When this audit type was created';

COMMENT ON COLUMN grouper_audit_type.hibernate_version_number IS 'Hibernate version number makes sure multiple sessions do not step on toes';

COMMENT ON COLUMN grouper_audit_type.id IS 'Unique id of this audit entry';

COMMENT ON COLUMN grouper_audit_type.label_int01 IS 'The int 01 value';

COMMENT ON COLUMN grouper_audit_type.label_int02 IS 'The int 02 value';

COMMENT ON COLUMN grouper_audit_type.label_int03 IS 'The int 03 value';

COMMENT ON COLUMN grouper_audit_type.label_int04 IS 'The int 04 value';

COMMENT ON COLUMN grouper_audit_type.label_int05 IS 'The int 05 value';

COMMENT ON COLUMN grouper_audit_type.label_string01 IS 'The label of the string field 01 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string02 IS 'The label of the string field 02 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string03 IS 'The label of the string field 03 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string04 IS 'The label of the string field 04 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string05 IS 'The label of the string field 05 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string06 IS 'The label of the string field 06 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string07 IS 'The label of the string field 07 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.label_string08 IS 'The label of the string field 08 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_type.last_updated IS 'When this audit type was last updated';

COMMENT ON TABLE grouper_composites IS 'records the composite group, and its factors';

COMMENT ON COLUMN grouper_composites.id IS 'db id of this composite record';

COMMENT ON COLUMN grouper_composites.owner IS 'group uuid of the composite group';

COMMENT ON COLUMN grouper_composites.left_factor IS 'left factor of the composite group';

COMMENT ON COLUMN grouper_composites.right_factor IS 'right factor of the composite group';

COMMENT ON COLUMN grouper_composites.type IS 'e.g. union, complement, intersection';

COMMENT ON COLUMN grouper_composites.creator_id IS 'member uuid of who created this';

COMMENT ON COLUMN grouper_composites.create_time IS 'number of millis since 1970 until when created';

COMMENT ON COLUMN grouper_composites.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_composites.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_ext_subj IS 'external subjects stored in grouper';

COMMENT ON COLUMN grouper_ext_subj.context_id IS 'context id links back to an auditing record';

COMMENT ON COLUMN grouper_ext_subj.create_time IS 'when this record was created in millis from 1970';

COMMENT ON COLUMN grouper_ext_subj.creator_member_id IS 'member id of who created this record';

COMMENT ON COLUMN grouper_ext_subj.description IS 'description field of the subject object';

COMMENT ON COLUMN grouper_ext_subj.email IS 'email address of subject (optional)';

COMMENT ON COLUMN grouper_ext_subj.identifier IS 'identifier of subject, e.g. the eppn.';

COMMENT ON COLUMN grouper_ext_subj.institution IS 'institution name where the subject is from';

COMMENT ON COLUMN grouper_ext_subj.modifier_member_id IS 'member id of who last edited the record';

COMMENT ON COLUMN grouper_ext_subj.modify_time IS 'when the record was last modified';

COMMENT ON COLUMN grouper_ext_subj.name IS 'name field of the subject object';

COMMENT ON COLUMN grouper_ext_subj.search_string_lower IS 'subject searches will use this field, it should contain most of the other fields, lower case';

COMMENT ON COLUMN grouper_ext_subj.uuid IS 'unique identifier for row';

COMMENT ON COLUMN grouper_ext_subj.enabled IS 'T or F for if this subject is enabled';

COMMENT ON COLUMN grouper_ext_subj.disabled_time IS 'number of millis since 1970 when this row was disabled';

COMMENT ON COLUMN grouper_ext_subj.hibernate_version_number IS 'hibernate optimistic locking value for updates and deletes';

COMMENT ON COLUMN grouper_ext_subj.vetted_email_addresses IS 'comma separated email addresses that this user has responded to';

COMMENT ON TABLE grouper_ext_subj_attr IS 'external subjects stored in grouper';

COMMENT ON COLUMN grouper_ext_subj_attr.attribute_system_name IS 'system name of the attribute, should not change, used as column name in view';

COMMENT ON COLUMN grouper_ext_subj_attr.attribute_value IS 'value of the attribute';

COMMENT ON COLUMN grouper_ext_subj_attr.context_id IS 'context id links back to an auditing record';

COMMENT ON COLUMN grouper_ext_subj_attr.create_time IS 'when this record was created in millis from 1970';

COMMENT ON COLUMN grouper_ext_subj_attr.creator_member_id IS 'member id of who created this record';

COMMENT ON COLUMN grouper_ext_subj_attr.modifier_member_id IS 'member id of who last edited the record';

COMMENT ON COLUMN grouper_ext_subj_attr.modify_time IS 'when the record was last modified';

COMMENT ON COLUMN grouper_ext_subj_attr.subject_uuid IS 'foreign key back to external subject';

COMMENT ON COLUMN grouper_ext_subj_attr.uuid IS 'unique identifier for row';

COMMENT ON COLUMN grouper_ext_subj_attr.hibernate_version_number IS 'hibernate optimistic locking value for updates and deletes';

COMMENT ON TABLE grouper_fields IS 'describes fields related to types';

COMMENT ON COLUMN grouper_fields.id IS 'db id of this field record';

COMMENT ON COLUMN grouper_fields.hibernate_version_number IS 'hibernate optimistic locking version number for updates and deletes';

COMMENT ON COLUMN grouper_fields.grouptype_uuid IS 'foreign key to group type';

COMMENT ON COLUMN grouper_fields.is_nullable IS 'if this is nullable';

COMMENT ON COLUMN grouper_fields.name IS 'name of the field';

COMMENT ON COLUMN grouper_fields.read_privilege IS 'which privilege is required to read this field';

COMMENT ON COLUMN grouper_fields.type IS 'type of field (e.g. attribute, list, access, naming)';

COMMENT ON COLUMN grouper_fields.write_privilege IS 'which privilege is required to write this attribute';

COMMENT ON COLUMN grouper_fields.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_pit_fields IS 'point in time history that describes fields related to types';

COMMENT ON COLUMN grouper_pit_fields.id IS 'db id of this field record';

COMMENT ON COLUMN grouper_pit_fields.active IS 'T or F if this record is currently active';

COMMENT ON COLUMN grouper_pit_fields.start_time IS 'number of millis since 1970 that this record was inserted';

COMMENT ON COLUMN grouper_pit_fields.end_time IS 'number of millis since 1970 that this record was deleted';

COMMENT ON COLUMN grouper_pit_fields.hibernate_version_number IS 'hibernate optimistic locking id for updates and deletes';

COMMENT ON COLUMN grouper_pit_fields.name IS 'name of the field';

COMMENT ON COLUMN grouper_pit_fields.type IS 'type of field (e.g. attribute, list, access, naming)';

COMMENT ON COLUMN grouper_pit_fields.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_groups IS 'holds the groups in the grouper system';

COMMENT ON COLUMN grouper_groups.id IS 'db id of this group record';

COMMENT ON COLUMN grouper_groups.parent_stem IS 'uuid of the stem that this group refers to';

COMMENT ON COLUMN grouper_groups.creator_id IS 'member uuid of the creator of this group';

COMMENT ON COLUMN grouper_groups.create_time IS 'number of millis since 1970 that this group was created';

COMMENT ON COLUMN grouper_groups.modifier_id IS 'member uuid of the last modifier of this group';

COMMENT ON COLUMN grouper_groups.modify_time IS 'number of millis since 1970 that this group was modified';

COMMENT ON COLUMN grouper_groups.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_groups.name IS 'group name is the fully qualified extension of group and all parent stems.  It shouldnt change much, and can be used to reference group from external systems';

COMMENT ON COLUMN grouper_groups.display_name IS 'group display name is the fully qualified display extension of group and all parent stems.  It can change as needed, and can not be used to reference group from external systems';

COMMENT ON COLUMN grouper_groups.extension IS 'group extension is the label for this group inside a stem.  It shouldnt change much, and can be used to reference group from external systems (in conjunction with parent stem id)';

COMMENT ON COLUMN grouper_groups.display_extension IS 'group display extension is the display label for this group inside a stem.  It cant change as needed, and can not be used to reference group from external systems';

COMMENT ON COLUMN grouper_groups.description IS 'group description is an optional text blurb that can be used to describe the group';

COMMENT ON COLUMN grouper_groups.last_membership_change IS 'If configured to keep track, this is the last membership change for this group';

COMMENT ON COLUMN grouper_groups.last_imm_membership_change IS 'If configured to keep track, this is the last immediate membership change for this group';

COMMENT ON COLUMN grouper_groups.alternate_name IS 'An alternate name for this group';

COMMENT ON COLUMN grouper_groups.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_groups.type_of_group IS 'if this is a group or role';

COMMENT ON TABLE grouper_pit_groups IS 'point in time info about groups in the grouper system';

COMMENT ON COLUMN grouper_pit_groups.id IS 'db id of this group record';

COMMENT ON COLUMN grouper_pit_groups.start_time IS 'millis since 1970 when this record was inserted';

COMMENT ON COLUMN grouper_pit_groups.end_time IS 'millis since 1970 when this record was deleted';

COMMENT ON COLUMN grouper_pit_groups.active IS 'T or F if this record is currently active';

COMMENT ON COLUMN grouper_pit_groups.stem_id IS 'uuid of the stem that this group refers to';

COMMENT ON COLUMN grouper_pit_groups.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_pit_groups.name IS 'group name is the fully qualified extension of group and all parent stems.  It shouldnt change much, and can be used to reference group from external systems';

COMMENT ON COLUMN grouper_pit_groups.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_groups_types IS 'holds the association between group and type';

COMMENT ON COLUMN grouper_groups_types.id IS 'id of this group/type record';

COMMENT ON COLUMN grouper_groups_types.group_uuid IS 'group uuid foreign key';

COMMENT ON COLUMN grouper_groups_types.type_uuid IS 'type uuid foreign key';

COMMENT ON COLUMN grouper_groups_types.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_groups_types.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_members IS 'keeps track of subjects used in grouper.  Records are never deleted from this table';

COMMENT ON COLUMN grouper_members.id IS 'db id of this row';

COMMENT ON COLUMN grouper_members.subject_id IS 'subject id is the id from the subject source';

COMMENT ON COLUMN grouper_members.subject_source IS 'id of the source from sources.xml';

COMMENT ON COLUMN grouper_members.subject_type IS 'type of subject, e.g. person';

COMMENT ON COLUMN grouper_members.sort_string0 IS 'string that can be used to sort results';

COMMENT ON COLUMN grouper_members.sort_string1 IS 'string that can be used to sort results';

COMMENT ON COLUMN grouper_members.sort_string2 IS 'string that can be used to sort results';

COMMENT ON COLUMN grouper_members.sort_string3 IS 'string that can be used to sort results';

COMMENT ON COLUMN grouper_members.sort_string4 IS 'string that can be used to sort results';

COMMENT ON COLUMN grouper_members.search_string0 IS 'string that can be used to filter results';

COMMENT ON COLUMN grouper_members.search_string1 IS 'string that can be used to filter results';

COMMENT ON COLUMN grouper_members.search_string2 IS 'string that can be used to filter results';

COMMENT ON COLUMN grouper_members.search_string3 IS 'string that can be used to filter results';

COMMENT ON COLUMN grouper_members.search_string4 IS 'string that can be used to filter results';

COMMENT ON COLUMN grouper_members.name IS 'name of subject';

COMMENT ON COLUMN grouper_members.description IS 'description of subject';

COMMENT ON COLUMN grouper_members.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_members.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_pit_members IS 'keeps track of subjects used in grouper.  Records are never deleted from this table';

COMMENT ON COLUMN grouper_pit_members.id IS 'db id of this row';

COMMENT ON COLUMN grouper_pit_members.subject_id IS 'subject id is the id from the subject source';

COMMENT ON COLUMN grouper_pit_members.subject_source IS 'id of the source from sources.xml';

COMMENT ON COLUMN grouper_pit_members.subject_type IS 'type of subject, e.g. person';

COMMENT ON COLUMN grouper_pit_members.active IS 'T or F if this is an active record based on start and end dates';

COMMENT ON COLUMN grouper_pit_members.start_time IS 'millis from 1970 when this record was inserted';

COMMENT ON COLUMN grouper_pit_members.end_time IS 'millis from 1970 when this record was deleted';

COMMENT ON COLUMN grouper_pit_members.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_pit_members.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_memberships IS 'keeps track of memberships and permissions';

COMMENT ON COLUMN grouper_memberships.id IS 'db id of this row';

COMMENT ON COLUMN grouper_memberships.owner_group_id IS 'group of the membership if applicable';

COMMENT ON COLUMN grouper_memberships.owner_stem_id IS 'stem of the membership if applicable';

COMMENT ON COLUMN grouper_memberships.member_id IS 'member of the memership';

COMMENT ON COLUMN grouper_memberships.owner_id IS 'owner of the memership';

COMMENT ON COLUMN grouper_memberships.field_id IS 'foreign key to field by id';

COMMENT ON COLUMN grouper_memberships.mship_type IS 'type of membership, immediate or composite';

COMMENT ON COLUMN grouper_memberships.via_composite_id IS 'for composite, this is the composite uuid';

COMMENT ON COLUMN grouper_memberships.creator_id IS 'member uuid of the creator of this record';

COMMENT ON COLUMN grouper_memberships.create_time IS 'number of millis since 1970 that this record was created';

COMMENT ON COLUMN grouper_memberships.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_memberships.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_memberships.enabled IS 'T or F to indicate if the membership is enabled';

COMMENT ON COLUMN grouper_memberships.enabled_timestamp IS 'When the membership will be enabled if the time is in the future.';

COMMENT ON COLUMN grouper_memberships.disabled_timestamp IS 'When the membership will be disabled if the time is in the future.';

COMMENT ON COLUMN grouper_memberships.owner_attr_def_id IS 'For attribute definition privileges, this is the foreign key to the grouper_attribute_def table';

COMMENT ON TABLE grouper_pit_memberships IS 'keeps track of memberships and permissions';

COMMENT ON COLUMN grouper_pit_memberships.id IS 'db id of this row';

COMMENT ON COLUMN grouper_pit_memberships.owner_group_id IS 'group of the membership if applicable';

COMMENT ON COLUMN grouper_pit_memberships.owner_stem_id IS 'stem of the membership if applicable';

COMMENT ON COLUMN grouper_pit_memberships.owner_attr_def_id IS 'attribute def of the membership if applicable';

COMMENT ON COLUMN grouper_pit_memberships.member_id IS 'member of the memership';

COMMENT ON COLUMN grouper_pit_memberships.owner_id IS 'owner of the memership';

COMMENT ON COLUMN grouper_pit_memberships.field_id IS 'foreign key to field by id';

COMMENT ON COLUMN grouper_pit_memberships.active IS 'T or F if this row is active based on start_time and end_time';

COMMENT ON COLUMN grouper_pit_memberships.start_time IS 'number of millis since 1970 when this record was inserted';

COMMENT ON COLUMN grouper_pit_memberships.end_time IS 'number of millis since 1970 when this record was deleted';

COMMENT ON COLUMN grouper_pit_memberships.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_pit_memberships.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_group_set IS 'keeps track of the set of immediate and effective group members for all groups and stems';

COMMENT ON COLUMN grouper_group_set.id IS 'db id of this row';

COMMENT ON COLUMN grouper_group_set.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_group_set.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_group_set.field_id IS 'field represented by this group set';

COMMENT ON COLUMN grouper_group_set.mship_type IS 'type of membership represented by this group set, immediate or composite or effective';

COMMENT ON COLUMN grouper_group_set.via_group_id IS 'same as member_group_id if depth is greater than 0, otherwise null.';

COMMENT ON COLUMN grouper_group_set.depth IS 'number of hops in directed graph';

COMMENT ON COLUMN grouper_group_set.parent_id IS 'parent group set';

COMMENT ON COLUMN grouper_group_set.creator_id IS 'member uuid of the creator of this record';

COMMENT ON COLUMN grouper_group_set.create_time IS 'number of millis since 1970 that this record was created';

COMMENT ON COLUMN grouper_group_set.owner_id IS 'owner id';

COMMENT ON COLUMN grouper_group_set.owner_attr_def_id IS 'owner attr def if applicable';

COMMENT ON COLUMN grouper_group_set.owner_attr_def_id_null IS 'same as owner_attr_def_id except nulls are replaced with the string <NULL>';

COMMENT ON COLUMN grouper_group_set.owner_group_id IS 'owner group if applicable';

COMMENT ON COLUMN grouper_group_set.owner_group_id_null IS 'same as owner_group_id except nulls are replaced with the string <NULL>';

COMMENT ON COLUMN grouper_group_set.owner_stem_id IS 'owner stem if applicable';

COMMENT ON COLUMN grouper_group_set.owner_stem_id_null IS 'same as owner_stem_id except nulls are replaced with the string <NULL>';

COMMENT ON COLUMN grouper_group_set.member_attr_def_id IS 'member attr def if applicable';

COMMENT ON COLUMN grouper_group_set.member_group_id IS 'member group if applicable';

COMMENT ON COLUMN grouper_group_set.member_stem_id IS 'member stem if applicable';

COMMENT ON COLUMN grouper_group_set.member_id IS 'member id';

COMMENT ON COLUMN grouper_group_set.member_field_id IS 'used to join with the field_id column in the grouper_memberships table';

COMMENT ON TABLE grouper_stems IS 'entries for stems and their attributes';

COMMENT ON COLUMN grouper_stems.id IS 'db id of this row';

COMMENT ON COLUMN grouper_stems.parent_stem IS 'stem uuid of parent stem or empty if under root';

COMMENT ON COLUMN grouper_stems.name IS 'full name (id) path of stem';

COMMENT ON COLUMN grouper_stems.display_name IS 'full dislpay name path of stem';

COMMENT ON COLUMN grouper_stems.creator_id IS 'member_id of who created this stem';

COMMENT ON COLUMN grouper_stems.create_time IS 'number of millis since 1970 since this was created';

COMMENT ON COLUMN grouper_stems.modifier_id IS 'member_id of modifier who last edited';

COMMENT ON COLUMN grouper_stems.modify_time IS 'number of millis since 1970 since this was edited';

COMMENT ON COLUMN grouper_stems.display_extension IS 'display extension (not full path) of stem';

COMMENT ON COLUMN grouper_stems.extension IS 'extension (id) (not full path) of this stem';

COMMENT ON COLUMN grouper_stems.description IS 'description of stem';

COMMENT ON COLUMN grouper_stems.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_stems.last_membership_change IS 'If configured to keep track, this is the last membership change for this stem';

COMMENT ON COLUMN grouper_stems.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_pit_stems IS 'entries for stems and their attributes';

COMMENT ON COLUMN grouper_pit_stems.id IS 'db id of this row';

COMMENT ON COLUMN grouper_pit_stems.parent_stem_id IS 'stem uuid of parent stem or empty if under root';

COMMENT ON COLUMN grouper_pit_stems.name IS 'full name (id) path of stem';

COMMENT ON COLUMN grouper_pit_stems.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_pit_stems.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_pit_stems.active IS 'T or F if this row is active by start and end time';

COMMENT ON COLUMN grouper_pit_stems.start_time IS 'millis sinve 1970 that this row was inserted';

COMMENT ON COLUMN grouper_pit_stems.end_time IS 'millis since 1970 that this row was deleted';

COMMENT ON TABLE grouper_types IS 'the various types which can be assigned to groups';

COMMENT ON COLUMN grouper_types.id IS 'db id of this row';

COMMENT ON COLUMN grouper_types.name IS 'name of this type';

COMMENT ON COLUMN grouper_types.creator_uuid IS 'member_id of the creator';

COMMENT ON COLUMN grouper_types.create_time IS 'number of millis since 1970 since this was created';

COMMENT ON COLUMN grouper_types.is_assignable IS 'if this type is assignable (not internal)';

COMMENT ON COLUMN grouper_types.is_internal IS 'if this type if internal (not assignable)';

COMMENT ON COLUMN grouper_types.hibernate_version_number IS 'hibernate uses this to version rows';

COMMENT ON COLUMN grouper_types.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON TABLE grouper_loader_log IS 'log table with a row for each grouper loader job run';

COMMENT ON COLUMN grouper_loader_log.id IS 'uuid of this log record';

COMMENT ON COLUMN grouper_loader_log.job_name IS 'Could be group name (friendly) or just config name';

COMMENT ON COLUMN grouper_loader_log.status IS 'STARTED, RUNNING, SUCCESS, ERROR, WARNING, CONFIG_ERROR';

COMMENT ON COLUMN grouper_loader_log.started_time IS 'When the job was started';

COMMENT ON COLUMN grouper_loader_log.ended_time IS 'When the job ended (might be blank if daemon died)';

COMMENT ON COLUMN grouper_loader_log.millis IS 'Milliseconds this process took';

COMMENT ON COLUMN grouper_loader_log.millis_get_data IS 'Milliseconds this process took to get the data from the source';

COMMENT ON COLUMN grouper_loader_log.millis_load_data IS 'Milliseconds this process took to load the data to grouper';

COMMENT ON COLUMN grouper_loader_log.job_type IS 'GrouperLoaderJobType enum value';

COMMENT ON COLUMN grouper_loader_log.job_schedule_type IS 'GrouperLoaderJobscheduleType enum value';

COMMENT ON COLUMN grouper_loader_log.job_description IS 'More information about the job';

COMMENT ON COLUMN grouper_loader_log.job_message IS 'Could be a status or error message or stack';

COMMENT ON COLUMN grouper_loader_log.host IS 'Host that this job ran on';

COMMENT ON COLUMN grouper_loader_log.group_uuid IS 'If this job involves one group, this is uuid';

COMMENT ON COLUMN grouper_loader_log.job_schedule_quartz_cron IS 'Quartz cron string for this col';

COMMENT ON COLUMN grouper_loader_log.job_schedule_interval_seconds IS 'How many seconds this is supposed to wait between runs';

COMMENT ON COLUMN grouper_loader_log.last_updated IS 'When this record was last updated';

COMMENT ON COLUMN grouper_loader_log.unresolvable_subject_count IS 'The number of records which were not subject resolvable';

COMMENT ON COLUMN grouper_loader_log.insert_count IS 'The number of records inserted';

COMMENT ON COLUMN grouper_loader_log.update_count IS 'The number of records updated';

COMMENT ON COLUMN grouper_loader_log.delete_count IS 'The number of records deleted';

COMMENT ON COLUMN grouper_loader_log.total_count IS 'The total number of records (e.g. total number of members)';

COMMENT ON COLUMN grouper_loader_log.parent_job_name IS 'If this job is a subjob of another job, then put the parent job name here';

COMMENT ON COLUMN grouper_loader_log.parent_job_id IS 'If this job is a subjob of another job, then put the parent job id here';

COMMENT ON COLUMN grouper_loader_log.and_group_names IS 'If this group query is anded with another group or groups, they are listed here comma separated';

COMMENT ON COLUMN grouper_loader_log.job_schedule_priority IS 'Priority of this job (5 is unprioritized, higher the better)';

COMMENT ON COLUMN grouper_loader_log.context_id IS 'link to the audit entry table';

CREATE VIEW grouper_audit_entry_v (created_on, audit_category, action_name, logged_in_subject_id, act_as_subject_id, label_string01, string01, label_string02, string02, label_string03, string03, label_string04, string04, label_string05, string05, label_string06, string06, label_string07, string07, label_string08, string08, label_int01, int01, label_int02, int02, label_int03, int03, label_int04, int04, label_int05, int05, context_id, grouper_engine, description, logged_in_source_id, act_as_source_id, logged_in_member_id, act_as_member_id, audit_type_id, user_ip_address, server_host, audit_entry_last_updated, audit_entry_id, grouper_version, env_name) AS select gae.created_on, gat.audit_category, gat.action_name, (select gm.subject_id from grouper_members gm where gm.id = gae.logged_in_member_id) as logged_in_subject_id, (select gm.subject_id from grouper_members gm where gm.id = gae.act_as_member_id) as act_as_subject_id, gat.label_string01, gae.string01, gat.label_string02, gae.string02, gat.label_string03, gae.string03, gat.label_string04, gae.string04, gat.label_string05, gae.string05, gat.label_string06, gae.string06, gat.label_string07, gae.string07, gat.label_string08, gae.string08, gat.label_int01, gae.int01, gat.label_int02, gae.int02, gat.label_int03, gae.int03, gat.label_int04, gae.int04, gat.label_int05, gae.int05, gae.context_id, gae.grouper_engine, gae.description, (select gm.subject_source from grouper_members gm where gm.id = gae.logged_in_member_id) as logged_in_source_id, (select gm.subject_source from grouper_members gm where gm.id = gae.act_as_member_id) as act_as_source_id, gae.logged_in_member_id, gae.act_as_member_id, gat.id as audit_type_id, gae.user_ip_address, gae.server_host, gae.last_updated, gae.id as audit_entry_id, gae.grouper_version, gae.env_name from grouper_audit_type gat, grouper_audit_entry gae where gat.id = gae.audit_type_id ;

COMMENT ON VIEW grouper_audit_entry_v IS 'Join of audit entry and audit type, and converts member ids to subject ids';

COMMENT ON COLUMN grouper_audit_entry_v.created_on IS 'When this audit entry record was created';

COMMENT ON COLUMN grouper_audit_entry_v.audit_category IS 'The category of this audit from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.action_name IS 'The action in this audit category from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.logged_in_subject_id IS 'The subject id of the logged in subject, e.g. from WS or UI';

COMMENT ON COLUMN grouper_audit_entry_v.act_as_subject_id IS 'The subject id of the user using the system if they are acting as another user, e.g. from WS';

COMMENT ON COLUMN grouper_audit_entry_v.label_string01 IS 'The label of the string field 01 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string01 IS 'The string 01 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string02 IS 'The label of the string field 02 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string02 IS 'The string 02 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string03 IS 'The label of the string field 03 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string03 IS 'The string 03 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string04 IS 'The label of the string field 04 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string04 IS 'The string 04 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string05 IS 'The label of the string field 05 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string05 IS 'The string 05 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string06 IS 'The label of the string field 06 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string06 IS 'The string 06 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string07 IS 'The label of the string field 07 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string07 IS 'The string 07 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_string08 IS 'The label of the string field 08 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.string08 IS 'The string 08 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_int01 IS 'The label of the int field 01 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.int01 IS 'The int 01 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_int02 IS 'The label of the int field 02 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.int02 IS 'The int 02 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_int03 IS 'The label of the int field 03 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.int03 IS 'The int 03 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_int04 IS 'The label of the int field 04 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.int04 IS 'The int 04 value';

COMMENT ON COLUMN grouper_audit_entry_v.label_int05 IS 'The label of the int field 05 from grouper_audit_type';

COMMENT ON COLUMN grouper_audit_entry_v.int05 IS 'The int 05 value';

COMMENT ON COLUMN grouper_audit_entry_v.context_id IS 'Context id links together multiple operations into one high level action';

COMMENT ON COLUMN grouper_audit_entry_v.grouper_engine IS 'Grouper engine is e.g. UI, WS, GSH, loader, etc';

COMMENT ON COLUMN grouper_audit_entry_v.description IS 'Description is a sentence form expression of what is being audited';

COMMENT ON COLUMN grouper_audit_entry_v.logged_in_source_id IS 'Source id of the user who is logged in';

COMMENT ON COLUMN grouper_audit_entry_v.act_as_source_id IS 'Source id of the user who is being acted as (e.g. in WS)';

COMMENT ON COLUMN grouper_audit_entry_v.logged_in_member_id IS 'Member id (foreign key) of the user logged in';

COMMENT ON COLUMN grouper_audit_entry_v.act_as_member_id IS 'Member id (foreign key) of the user who is being acted as';

COMMENT ON COLUMN grouper_audit_entry_v.audit_type_id IS 'ID of the audit type row';

COMMENT ON COLUMN grouper_audit_entry_v.user_ip_address IS 'IP address of the user connecting to the system (e.g. from UI or WS)';

COMMENT ON COLUMN grouper_audit_entry_v.server_host IS 'Host of the system running the grouper API';

COMMENT ON COLUMN grouper_audit_entry_v.audit_entry_last_updated IS 'When this audit entry was last updated';

COMMENT ON COLUMN grouper_audit_entry_v.audit_entry_id IS 'ID of this audit entry';

COMMENT ON COLUMN grouper_audit_entry_v.grouper_version IS 'Grouper version of the API executing';

COMMENT ON COLUMN grouper_audit_entry_v.env_name IS 'environment label of the system running, from grouper.properties';

CREATE VIEW grouper_change_log_entry_v (created_on, change_log_category, action_name, sequence_number, label_string01, string01, label_string02, string02, label_string03, string03, label_string04, string04, label_string05, string05, label_string06, string06, label_string07, string07, label_string08, string08, label_string09, string09, label_string10, string10, label_string11, string11, label_string12, string12, context_id, change_log_type_id) AS SELECT gcle.created_on, gclt.change_log_category, gclt.action_name, gcle.sequence_number,        gclt.label_string01, gcle.string01, gclt.label_string02, gcle.string02,        gclt.label_string03, gcle.string03, gclt.label_string04, gcle.string04,        gclt.label_string05, gcle.string05, gclt.label_string06, gcle.string06,        gclt.label_string07, gcle.string07, gclt.label_string08, gcle.string08,        gclt.label_string09, gcle.string09, gclt.label_string10, gcle.string10,        gclt.label_string11, gcle.string11, gclt.label_string12, gcle.string12,        gcle.context_id, gcle.change_log_type_id   FROM grouper_change_log_type gclt, grouper_change_log_entry gcle  WHERE gclt.id = gcle.change_log_type_id;

COMMENT ON VIEW grouper_change_log_entry_v IS 'Join of change log entry and change log type';

COMMENT ON COLUMN grouper_change_log_entry_v.created_on IS 'created_on: when this change happened, number of millis since 1970';

COMMENT ON COLUMN grouper_change_log_entry_v.change_log_category IS 'change_log_category: category of this change';

COMMENT ON COLUMN grouper_change_log_entry_v.action_name IS 'action_name: action of this change';

COMMENT ON COLUMN grouper_change_log_entry_v.sequence_number IS 'sequence_number: increasing integer of each change';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string01 IS 'label_string01: label of first string';

COMMENT ON COLUMN grouper_change_log_entry_v.string01 IS 'string01: value of first string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string02 IS 'label_string02: label of second string';

COMMENT ON COLUMN grouper_change_log_entry_v.string02 IS 'string02: value of second string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string03 IS 'label_string03: label of third string';

COMMENT ON COLUMN grouper_change_log_entry_v.string03 IS 'string03: value of third string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string04 IS 'label_string04: label of fourth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string04 IS 'string04: value of fourth string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string05 IS 'label_string05: label of fifth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string05 IS 'string05: value of fifth string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string06 IS 'label_string06: label of sixth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string06 IS 'string06: value of sixth string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string07 IS 'label_string07: label of seventh string';

COMMENT ON COLUMN grouper_change_log_entry_v.string07 IS 'string07: value of seventh string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string08 IS 'label_string08: label of eighth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string08 IS 'string08: value of eighth string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string09 IS 'label_string09: label of ninth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string09 IS 'string09: value of ninth string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string10 IS 'label_string10: label of tenth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string10 IS 'string10: value of tenth string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string11 IS 'label_string11: label of eleventh string';

COMMENT ON COLUMN grouper_change_log_entry_v.string11 IS 'string11: value of eleventh string';

COMMENT ON COLUMN grouper_change_log_entry_v.label_string12 IS 'label_string12: label of twelfth string';

COMMENT ON COLUMN grouper_change_log_entry_v.string12 IS 'string12: value of twelfth string';

COMMENT ON COLUMN grouper_change_log_entry_v.context_id IS 'context_id: links this record with an audit record';

COMMENT ON COLUMN grouper_change_log_entry_v.change_log_type_id IS 'change_log_type_id: id of this category and name';

CREATE VIEW grouper_attributes_v (GROUP_NAME, GROUP_DISPLAY_NAME, ATTRIBUTE_NAME, ATTRIBUTE_VALUE, GROUP_TYPE_NAME, FIELD_ID, ATTRIBUTE_ID, GROUP_ID, GROUPTYPE_UUID, CONTEXT_ID) AS select  gg.name as group_name, gg.display_name as group_display_name, gf.NAME as attribute_name, ga.VALUE as attribute_value, gt.NAME as group_type_name, ga.FIELD_ID, ga.ID as attribute_id, gg.ID as group_id, gf.grouptype_uuid, ga.context_id from grouper_attributes ga, grouper_groups gg, grouper_fields gf, grouper_types gt where ga.FIELD_ID = gf.ID and ga.GROUP_ID = gg.ID and gf.GROUPTYPE_UUID = gt.ID ;

COMMENT ON VIEW grouper_attributes_v IS 'Join of groups and attributes with friendly names.  Attributes are name/value pairs for groups.  Each group type is related to a set of 0 to many attributes, each attribute is related to one group type.grouper_fields holds each attribute name under the field type of ^attribute^';

COMMENT ON COLUMN grouper_attributes_v.GROUP_NAME IS 'Group name is full id path, e.g. school:stem1:groupId';

COMMENT ON COLUMN grouper_attributes_v.GROUP_DISPLAY_NAME IS 'Group display name is the full friendly name, e.g. My School:Stem 1:The Group';

COMMENT ON COLUMN grouper_attributes_v.ATTRIBUTE_NAME IS 'Attribute name is the name of the name/value pair';

COMMENT ON COLUMN grouper_attributes_v.ATTRIBUTE_VALUE IS 'Attribute value is the value of the name/value pair';

COMMENT ON COLUMN grouper_attributes_v.GROUP_TYPE_NAME IS 'Group_type_name is the name of the group type this attribute is related to';

COMMENT ON COLUMN grouper_attributes_v.FIELD_ID IS 'Field_id is the uuid that uniquely identifies a the field';

COMMENT ON COLUMN grouper_attributes_v.ATTRIBUTE_ID IS 'Attribute_id is the uuid that uniquely identifies the pairing of group and attribute';

COMMENT ON COLUMN grouper_attributes_v.GROUP_ID IS 'Group_id is the uuid that uniquely identifies a group';

COMMENT ON COLUMN grouper_attributes_v.GROUPTYPE_UUID IS 'GroupType_uuid is the uuid that uniquely identifies a group type';

COMMENT ON COLUMN grouper_attributes_v.CONTEXT_ID IS 'Context id links together multiple operations into one high level action';

CREATE VIEW grouper_composites_v (OWNER_GROUP_NAME, COMPOSITE_TYPE, LEFT_FACTOR_GROUP_NAME, RIGHT_FACTOR_GROUP_NAME, OWNER_GROUP_DISPLAYNAME, LEFT_FACTOR_GROUP_DISPLAYNAME, RIGHT_FACTOR_GROUP_DISPLAYNAME, owner_group_id, LEFT_FACTOR_GROUP_ID, RIGHT_FACTOR_GROUP_ID, COMPOSITE_ID, CREATE_TIME, CREATOR_ID, HIBERNATE_VERSION_NUMBER, CONTEXT_ID) AS select  (select gg.name from grouper_groups gg  where gg.id = gc.owner) as owner_group_name,  gc.TYPE as composite_type,  (select gg.name from grouper_groups gg  where gg.id =  gc.left_factor) as left_factor_group_name,  (select gg.name from grouper_groups gg  where gg.id = gc.right_factor) as right_factor_group_name,  (select gg.display_name from grouper_groups gg  where gg.id = gc.owner) as owner_group_displayname,  (select gg.display_name from grouper_groups gg  where gg.id = gc.left_factor) as left_factor_group_displayname,  (select gg.display_name from grouper_groups gg  where gg.id = gc.right_factor) as right_factor_group_displayname,  gc.OWNER as owner_group_id,  gc.LEFT_FACTOR as left_factor_group_id,  gc.RIGHT_FACTOR as right_factor_group_id,  gc.ID as composite_id,  gc.CREATE_TIME,  gc.CREATOR_ID,  gc.HIBERNATE_VERSION_NUMBER, gc.context_id from grouper_composites gc  ;

COMMENT ON VIEW grouper_composites_v IS 'Grouper_composites_v is a view of composite relationships with friendly names.  A composite is a joining of two groups with a group math operator of: union, intersection, or complement.';

COMMENT ON COLUMN grouper_composites_v.OWNER_GROUP_NAME IS 'OWNER_GROUP_NAME: Name of the group which is the result of the composite operation, e.g. school:stem1:allPeople';

COMMENT ON COLUMN grouper_composites_v.COMPOSITE_TYPE IS 'COMPOSITE_TYPE: union (all members), intersection (only members in both), or complement (in first, not in second)';

COMMENT ON COLUMN grouper_composites_v.LEFT_FACTOR_GROUP_NAME IS 'LEFT_FACTOR_GROUP_NAME: Name of group which is the first of two groups in the composite operation, e.g. school:stem1:part1';

COMMENT ON COLUMN grouper_composites_v.RIGHT_FACTOR_GROUP_NAME IS 'RIGHT_FACTOR_GROUP_NAME: Name of group which is the second of two groups in the composite operation, e.g. school:stem1:part2';

COMMENT ON COLUMN grouper_composites_v.OWNER_GROUP_DISPLAYNAME IS 'OWNER_GROUP_DISPLAYNAME: Display name of result group of composite operation, e.g. My school:The stem1:All people';

COMMENT ON COLUMN grouper_composites_v.LEFT_FACTOR_GROUP_DISPLAYNAME IS 'LEFT_FACTOR_GROUP_DISPLAYNAME: Display name of group which is the first of two groups in the composite operation, e.g. My school:The stem1:Part 1';

COMMENT ON COLUMN grouper_composites_v.RIGHT_FACTOR_GROUP_DISPLAYNAME IS 'RIGHT_FACTOR_GROUP_DISPLAYNAME: Display name of group which is the second of two groups in the composite operation, e.g. My school:The stem1:Part 1';

COMMENT ON COLUMN grouper_composites_v.owner_group_id IS 'OWNER_GROUP_ID: UUID of the result group';

COMMENT ON COLUMN grouper_composites_v.LEFT_FACTOR_GROUP_ID IS 'LEFT_FACTOR_GROUP_ID: UUID of the first group of the composite operation';

COMMENT ON COLUMN grouper_composites_v.RIGHT_FACTOR_GROUP_ID IS 'RIGHT_FACTOR_GROUP_ID: UUID of the second group of the composite operation';

COMMENT ON COLUMN grouper_composites_v.COMPOSITE_ID IS 'COMPOSITE_ID: UUID of the composite relationship among the three groups';

COMMENT ON COLUMN grouper_composites_v.CREATE_TIME IS 'CREATE_TIME: number of millis since 1970 that the composite was created';

COMMENT ON COLUMN grouper_composites_v.CREATOR_ID IS 'CREATOR_ID: member id of the subject that created the composite relationship';

COMMENT ON COLUMN grouper_composites_v.HIBERNATE_VERSION_NUMBER IS 'HIBERNATE_VERSION_NUMBER: increments with each update, starts at 0';

COMMENT ON COLUMN grouper_composites_v.CONTEXT_ID IS 'CONTEXT_ID: Context id links together multiple operations into one high level action';

CREATE VIEW grouper_ext_subj_v (uuid, name, identifier, description, institution, email, search_string_lower) AS SELECT ges.uuid, ges.name, ges.identifier, ges.description , ges.institution , ges.email , ges.search_string_lower  FROM grouper_ext_subj ges WHERE ges.enabled = 'T';

COMMENT ON VIEW grouper_ext_subj_v IS 'grouper_ext_subj_v is a view of external subjects, and they attributes';

COMMENT ON COLUMN grouper_ext_subj_v.uuid IS 'uuid: universally unique id of subject';

COMMENT ON COLUMN grouper_ext_subj_v.name IS 'name: name field of the subject object';

COMMENT ON COLUMN grouper_ext_subj_v.identifier IS 'identifier: identifier of subject, e.g. the eppn';

COMMENT ON COLUMN grouper_ext_subj_v.description IS 'description: description field of the subject object';

COMMENT ON COLUMN grouper_ext_subj_v.institution IS 'institution: where the subject comes from';

COMMENT ON COLUMN grouper_ext_subj_v.email IS 'email: email address of the subject';

COMMENT ON COLUMN grouper_ext_subj_v.search_string_lower IS 'search_string_lower: lower case list of strings that the search will return results for subject';

CREATE VIEW grouper_groups_types_v (GROUP_NAME, GROUP_DISPLAYNAME, GROUP_TYPE_NAME, GROUP_ID, GROUP_TYPE_UUID, GROUPER_GROUPS_TYPES_ID, HIBERNATE_VERSION_NUMBER, CONTEXT_ID) AS select   (select gg.name from grouper_groups gg  where gg.id = ggt.GROUP_UUID) as group_name,  (select gg.display_name from grouper_groups gg  where gg.id = ggt.GROUP_UUID) as group_displayname,  gt.NAME as group_type_name,  ggt.GROUP_UUID as group_id,  ggt.TYPE_UUID as group_type_uuid,  ggt.ID as grouper_groups_types_id,  ggt.HIBERNATE_VERSION_NUMBER, ggt.context_id  from grouper_groups_types ggt, grouper_types gt  where ggt.TYPE_UUID = gt.ID  ;

COMMENT ON VIEW grouper_groups_types_v IS 'A group can have one or many types associated.  This is a view of those relationships with friendly names';

COMMENT ON COLUMN grouper_groups_types_v.GROUP_NAME IS 'GROUP_NAME: name of group which has the type, e.g. school:stem1:theGroup';

COMMENT ON COLUMN grouper_groups_types_v.GROUP_DISPLAYNAME IS 'GROUP_DISPLAYNAME: display name of the group which has the type, e.g. My school, the stem 1, The group';

COMMENT ON COLUMN grouper_groups_types_v.GROUP_TYPE_NAME IS 'GROUP_TYPE_NAME: friendly name of the type, e.g. grouperLoader';

COMMENT ON COLUMN grouper_groups_types_v.GROUP_ID IS 'GROUP_ID: uuid unique id of the group which has the type';

COMMENT ON COLUMN grouper_groups_types_v.GROUP_TYPE_UUID IS 'GROUP_TYPE_UUID: uuid unique id of the type related to the group';

COMMENT ON COLUMN grouper_groups_types_v.GROUPER_GROUPS_TYPES_ID IS 'GROUPER_GROUPS_TYPES_ID: uuid unique id of the relationship between the group and type';

COMMENT ON COLUMN grouper_groups_types_v.HIBERNATE_VERSION_NUMBER IS 'HIBERNATE_VERSION_NUMBER: increments by one with each update, starts at 0';

COMMENT ON COLUMN grouper_groups_types_v.CONTEXT_ID IS 'Context id links together multiple operations into one high level action';

CREATE VIEW grouper_groups_v (EXTENSION, NAME, DISPLAY_EXTENSION, DISPLAY_NAME, DESCRIPTION, PARENT_STEM_NAME, TYPE_OF_GROUP, GROUP_ID, PARENT_STEM_ID, MODIFIER_SOURCE, MODIFIER_SUBJECT_ID, CREATOR_SOURCE, CREATOR_SUBJECT_ID, IS_COMPOSITE_OWNER, IS_COMPOSITE_FACTOR, CREATOR_ID, CREATE_TIME, MODIFIER_ID, MODIFY_TIME, HIBERNATE_VERSION_NUMBER, CONTEXT_ID) AS select  gg.extension as extension, gg.name as name, gg.display_extension as display_extension, gg.display_name as display_name, gg.description as description, gs.NAME as parent_stem_name, gg.type_of_group, gg.id as group_id, gs.ID as parent_stem_id, (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gg.MODIFIER_ID) as modifier_source, (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gg.MODIFIER_ID) as modifier_subject_id, (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gg.CREATOR_ID) as creator_source, (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gg.CREATOR_ID) as creator_subject_id, (select distinct 'T' from grouper_composites gc where gc.OWNER = gg.ID) as is_composite_owner, (select distinct 'T' from grouper_composites gc where gc.LEFT_FACTOR = gg.ID or gc.right_factor = gg.id) as is_composite_factor, gg.CREATOR_ID, gg.CREATE_TIME, gg.MODIFIER_ID, gg.MODIFY_TIME, gg.HIBERNATE_VERSION_NUMBER, gg.context_id   from grouper_groups gg, grouper_stems gs where gg.PARENT_STEM = gs.ID ;

COMMENT ON VIEW grouper_groups_v IS 'Contains one record for each group, with friendly names for some attributes and some more information';

COMMENT ON COLUMN grouper_groups_v.EXTENSION IS 'EXTENSION: part of group name not including path information, e.g. theGroup';

COMMENT ON COLUMN grouper_groups_v.NAME IS 'NAME: name of the group, e.g. school:stem1:theGroup';

COMMENT ON COLUMN grouper_groups_v.DISPLAY_EXTENSION IS 'DISPLAY_EXTENSION: name for display of the group, e.g. My school:The stem 1:The group';

COMMENT ON COLUMN grouper_groups_v.DISPLAY_NAME IS 'DISPLAY_NAME: name for display of the group without any path information, e.g. The group';

COMMENT ON COLUMN grouper_groups_v.DESCRIPTION IS 'DESCRIPTION: contains user entered information about the group e.g. why it exists';

COMMENT ON COLUMN grouper_groups_v.PARENT_STEM_NAME IS 'PARENT_STEM_NAME: name of the stem this group is in, e.g. school:stem1';

COMMENT ON COLUMN grouper_groups_v.TYPE_OF_GROUP IS 'TYPE_OF_GROUP: group if it is a group, role if it is a role';

COMMENT ON COLUMN grouper_groups_v.GROUP_ID IS 'GROUP_ID: uuid unique id of the group';

COMMENT ON COLUMN grouper_groups_v.PARENT_STEM_ID IS 'PARENT_STEM_ID: uuid unique id of the stem this group is in';

COMMENT ON COLUMN grouper_groups_v.MODIFIER_SOURCE IS 'MODIFIER_SOURCE: source name of the subject who last modified this group, e.g. schoolPersonSource';

COMMENT ON COLUMN grouper_groups_v.MODIFIER_SUBJECT_ID IS 'MODIFIER_SUBJECT_ID: subject id of the subject who last modified this group, e.g. 12345';

COMMENT ON COLUMN grouper_groups_v.CREATOR_SOURCE IS 'CREATOR_SOURCE: source name of the subject who created this group, e.g. schoolPersonSource';

COMMENT ON COLUMN grouper_groups_v.CREATOR_SUBJECT_ID IS 'CREATOR_SUBJECT_ID: subject id of the subject who created this group, e.g. 12345';

COMMENT ON COLUMN grouper_groups_v.IS_COMPOSITE_OWNER IS 'IS_COMPOSITE_OWNER: T if this is a result of a composite operation (union, intersection, complement), or blank if not';

COMMENT ON COLUMN grouper_groups_v.IS_COMPOSITE_FACTOR IS 'IS_COMPOSITE_FACTOR: T if this is a member of a composite operation, e.g. one of the grouper being unioned, intersected, or complemeneted';

COMMENT ON COLUMN grouper_groups_v.CREATOR_ID IS 'CREATOR_ID: member id of the subject who created this group, foreign key to grouper_members';

COMMENT ON COLUMN grouper_groups_v.CREATE_TIME IS 'CREATE_TIME: number of millis since 1970 since this group was created';

COMMENT ON COLUMN grouper_groups_v.MODIFIER_ID IS 'MODIFIER_ID: member id of the subject who last modified this group, foreign key to grouper_members';

COMMENT ON COLUMN grouper_groups_v.MODIFY_TIME IS 'MODIFY_TIME: number of millis since 1970 since this group was last changed';

COMMENT ON COLUMN grouper_groups_v.HIBERNATE_VERSION_NUMBER IS 'HIBERNATE_VERSION_NUMBER: increments by 1 for each update';

COMMENT ON COLUMN grouper_groups_v.CONTEXT_ID IS 'Context id links together multiple operations into one high level action';

CREATE VIEW grouper_roles_v (EXTENSION, NAME, DISPLAY_EXTENSION, DISPLAY_NAME, DESCRIPTION, PARENT_STEM_NAME, ROLE_ID, PARENT_STEM_ID, MODIFIER_SOURCE, MODIFIER_SUBJECT_ID, CREATOR_SOURCE, CREATOR_SUBJECT_ID, IS_COMPOSITE_OWNER, IS_COMPOSITE_FACTOR, CREATOR_ID, CREATE_TIME, MODIFIER_ID, MODIFY_TIME, HIBERNATE_VERSION_NUMBER, CONTEXT_ID) AS select  gg.extension as extension, gg.name as name, gg.display_extension as display_extension, gg.display_name as display_name, gg.description as description, gs.NAME as parent_stem_name, gg.id as role_id, gs.ID as parent_stem_id, (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gg.MODIFIER_ID) as modifier_source, (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gg.MODIFIER_ID) as modifier_subject_id, (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gg.CREATOR_ID) as creator_source, (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gg.CREATOR_ID) as creator_subject_id, (select distinct 'T' from grouper_composites gc where gc.OWNER = gg.ID) as is_composite_owner, (select distinct 'T' from grouper_composites gc where gc.LEFT_FACTOR = gg.ID or gc.right_factor = gg.id) as is_composite_factor, gg.CREATOR_ID, gg.CREATE_TIME, gg.MODIFIER_ID, gg.MODIFY_TIME, gg.HIBERNATE_VERSION_NUMBER, gg.context_id   from grouper_groups gg, grouper_stems gs where gg.PARENT_STEM = gs.ID and type_of_group = 'role' ;

COMMENT ON VIEW grouper_roles_v IS 'Contains one record for each role, with friendly names for some attributes and some more information';

COMMENT ON COLUMN grouper_roles_v.EXTENSION IS 'EXTENSION: part of role name not including path information, e.g. theRole';

COMMENT ON COLUMN grouper_roles_v.NAME IS 'NAME: name of the role, e.g. school:stem1:theRole';

COMMENT ON COLUMN grouper_roles_v.DISPLAY_EXTENSION IS 'DISPLAY_EXTENSION: name for display of the role, e.g. My school:The stem 1:The role';

COMMENT ON COLUMN grouper_roles_v.DISPLAY_NAME IS 'DISPLAY_NAME: name for display of the role without any path information, e.g. The role';

COMMENT ON COLUMN grouper_roles_v.DESCRIPTION IS 'DESCRIPTION: contains user entered information about the group e.g. why it exists';

COMMENT ON COLUMN grouper_roles_v.PARENT_STEM_NAME IS 'PARENT_STEM_NAME: name of the stem this role is in, e.g. school:stem1';

COMMENT ON COLUMN grouper_roles_v.ROLE_ID IS 'ROLE_ID: uuid unique id of the role';

COMMENT ON COLUMN grouper_roles_v.PARENT_STEM_ID IS 'PARENT_STEM_ID: uuid unique id of the stem this role is in';

COMMENT ON COLUMN grouper_roles_v.MODIFIER_SOURCE IS 'MODIFIER_SOURCE: source name of the subject who last modified this role, e.g. schoolPersonSource';

COMMENT ON COLUMN grouper_roles_v.MODIFIER_SUBJECT_ID IS 'MODIFIER_SUBJECT_ID: subject id of the subject who last modified this role, e.g. 12345';

COMMENT ON COLUMN grouper_roles_v.CREATOR_SOURCE IS 'CREATOR_SOURCE: source name of the subject who created this role, e.g. schoolPersonSource';

COMMENT ON COLUMN grouper_roles_v.CREATOR_SUBJECT_ID IS 'CREATOR_SUBJECT_ID: subject id of the subject who created this role, e.g. 12345';

COMMENT ON COLUMN grouper_roles_v.IS_COMPOSITE_OWNER IS 'IS_COMPOSITE_OWNER: T if this is a result of a composite operation (union, intersection, complement), or blank if not';

COMMENT ON COLUMN grouper_roles_v.IS_COMPOSITE_FACTOR IS 'IS_COMPOSITE_FACTOR: T if this is a member of a composite operation, e.g. one of the grouper being unioned, intersected, or complemeneted';

COMMENT ON COLUMN grouper_roles_v.CREATOR_ID IS 'CREATOR_ID: member id of the subject who created this role, foreign key to grouper_members';

COMMENT ON COLUMN grouper_roles_v.CREATE_TIME IS 'CREATE_TIME: number of millis since 1970 since this role was created';

COMMENT ON COLUMN grouper_roles_v.MODIFIER_ID IS 'MODIFIER_ID: member id of the subject who last modified this role, foreign key to grouper_members';

COMMENT ON COLUMN grouper_roles_v.MODIFY_TIME IS 'MODIFY_TIME: number of millis since 1970 since this role was last changed';

COMMENT ON COLUMN grouper_roles_v.HIBERNATE_VERSION_NUMBER IS 'HIBERNATE_VERSION_NUMBER: increments by 1 for each update';

COMMENT ON COLUMN grouper_roles_v.CONTEXT_ID IS 'Context id links together multiple operations into one high level action';

CREATE VIEW grouper_memberships_all_v (MEMBERSHIP_ID, IMMEDIATE_MEMBERSHIP_ID, GROUP_SET_ID, MEMBER_ID, FIELD_ID, IMMEDIATE_FIELD_ID, OWNER_ID, OWNER_ATTR_DEF_ID, OWNER_GROUP_ID, OWNER_STEM_ID, VIA_GROUP_ID, VIA_COMPOSITE_ID, DEPTH, MSHIP_TYPE, IMMEDIATE_MSHIP_ENABLED, IMMEDIATE_MSHIP_ENABLED_TIME, IMMEDIATE_MSHIP_DISABLED_TIME, GROUP_SET_PARENT_ID, MEMBERSHIP_CREATOR_ID, MEMBERSHIP_CREATE_TIME, GROUP_SET_CREATOR_ID, GROUP_SET_CREATE_TIME, HIBERNATE_VERSION_NUMBER, CONTEXT_ID) AS select ms.id || ':' || gs.id as membership_id, ms.id as immediate_membership_id, gs.id as group_set_id, ms.member_id, gs.field_id, ms.field_id, gs.owner_id, gs.owner_attr_def_id, gs.owner_group_id, gs.owner_stem_id, gs.via_group_id, ms.via_composite_id, gs.depth, gs.mship_type, ms.enabled, ms.enabled_timestamp, ms.disabled_timestamp, gs.parent_id as group_set_parent_id, ms.creator_id as membership_creator_id, ms.create_time as membership_create_time, gs.creator_id as group_set_creator_id, gs.create_time as group_set_create_time, ms.hibernate_version_number, ms.context_id from grouper_memberships ms, grouper_group_set gs where ms.owner_id = gs.member_id and ms.field_id = gs.member_field_id;

COMMENT ON VIEW grouper_memberships_all_v IS 'Grouper_memberships_all_v holds one record for each immediate, composite and effective membership or privilege in the system for members to groups or stems (for privileges).';

COMMENT ON COLUMN grouper_memberships_all_v.MEMBERSHIP_ID IS 'MEMBERSHIP_ID: uuid unique id of this membership';

COMMENT ON COLUMN grouper_memberships_all_v.IMMEDIATE_MEMBERSHIP_ID IS 'IMMEDIATE_MEMBERSHIP_ID: uuid of the immediate (or composite) membership that causes this membership';

COMMENT ON COLUMN grouper_memberships_all_v.GROUP_SET_ID IS 'GROUP_SET_ID: uuid of the group set that causes this membership';

COMMENT ON COLUMN grouper_memberships_all_v.MEMBER_ID IS 'MEMBER_ID: id in the grouper_members table';

COMMENT ON COLUMN grouper_memberships_all_v.FIELD_ID IS 'FIELD_ID: id in the grouper_fields table';

COMMENT ON COLUMN grouper_memberships_all_v.IMMEDIATE_FIELD_ID IS 'IMMEDIATE_FIELD_ID: id in the grouper_fields table for the immediate (or composite) membership that causes this membership';

COMMENT ON COLUMN grouper_memberships_all_v.OWNER_ID IS 'OWNER_ID: owner id';

COMMENT ON COLUMN grouper_memberships_all_v.OWNER_ATTR_DEF_ID IS 'OWNER_ATTR_DEF_ID: owner attribute def id if applicable';

COMMENT ON COLUMN grouper_memberships_all_v.OWNER_GROUP_ID IS 'OWNER_GROUP_ID: owner group if applicable';

COMMENT ON COLUMN grouper_memberships_all_v.OWNER_STEM_ID IS 'OWNER_STEM_ID: owner stem if applicable';

COMMENT ON COLUMN grouper_memberships_all_v.VIA_GROUP_ID IS 'VIA_GROUP_ID: membership is due to this group if effective';

COMMENT ON COLUMN grouper_memberships_all_v.VIA_COMPOSITE_ID IS 'VIA_COMPOSITE_ID: membership is due to this composite if applicable';

COMMENT ON COLUMN grouper_memberships_all_v.DEPTH IS 'DEPTH: number of hops in a directed graph';

COMMENT ON COLUMN grouper_memberships_all_v.MSHIP_TYPE IS 'MSHIP_TYPE: type of membership, immediate or effective or composite';

COMMENT ON COLUMN grouper_memberships_all_v.IMMEDIATE_MSHIP_ENABLED IS 'IMMEDIATE_MSHIP_ENABLED: T or F to indicate if this membership is enabled';

COMMENT ON COLUMN grouper_memberships_all_v.IMMEDIATE_MSHIP_ENABLED_TIME IS 'IMMEDIATE_MSHIP_ENABLED_TIME: when the membership will be enabled if the time is in the future';

COMMENT ON COLUMN grouper_memberships_all_v.IMMEDIATE_MSHIP_DISABLED_TIME IS 'IMMEDIATE_MSHIP_DISABLED_TIME: when the membership will be disabled if the time is in the future.';

COMMENT ON COLUMN grouper_memberships_all_v.GROUP_SET_PARENT_ID IS 'GROUP_SET_PARENT_ID: parent group set';

COMMENT ON COLUMN grouper_memberships_all_v.MEMBERSHIP_CREATOR_ID IS 'MEMBERSHIP_CREATOR_ID: member uuid of the creator of the immediate or composite membership';

COMMENT ON COLUMN grouper_memberships_all_v.MEMBERSHIP_CREATE_TIME IS 'MEMBERSHIP_CREATOR_TIME: number of millis since 1970 the immedate or composite membership was created';

COMMENT ON COLUMN grouper_memberships_all_v.GROUP_SET_CREATOR_ID IS 'GROUP_SET_CREATOR_ID: member uuid of the creator of the group set';

COMMENT ON COLUMN grouper_memberships_all_v.GROUP_SET_CREATE_TIME IS 'GROUP_SET_CREATE_TIME: number of millis since 1970 the group set was created';

COMMENT ON COLUMN grouper_memberships_all_v.HIBERNATE_VERSION_NUMBER IS 'HIBERNATE_VERSION_NUMBER: hibernate uses this to version rows';

COMMENT ON COLUMN grouper_memberships_all_v.CONTEXT_ID IS 'CONTEXT_ID: Context id links together multiple operations into one high level action';

CREATE VIEW grouper_pit_memberships_all_v (ID, MEMBERSHIP_ID, MEMBERSHIP_SOURCE_ID, GROUP_SET_ID, MEMBER_ID, FIELD_ID, MEMBERSHIP_FIELD_ID, OWNER_ID, OWNER_ATTR_DEF_ID, OWNER_GROUP_ID, OWNER_STEM_ID, GROUP_SET_ACTIVE, GROUP_SET_START_TIME, GROUP_SET_END_TIME, MEMBERSHIP_ACTIVE, MEMBERSHIP_START_TIME, MEMBERSHIP_END_TIME, DEPTH, GROUP_SET_PARENT_ID) AS select ms.id || ':' || gs.id as membership_id, ms.id as immediate_membership_id, ms.source_id as membership_source_id, gs.id as group_set_id, ms.member_id, gs.field_id, ms.field_id, gs.owner_id, gs.owner_attr_def_id, gs.owner_group_id, gs.owner_stem_id, gs.active, gs.start_time, gs.end_time, ms.active, ms.start_time, ms.end_time, gs.depth, gs.parent_id as group_set_parent_id from grouper_pit_memberships ms, grouper_pit_group_set gs where ms.owner_id = gs.member_id and ms.field_id = gs.member_field_id;

COMMENT ON VIEW grouper_pit_memberships_all_v IS 'Grouper_pit_memberships_all_v holds one record for each immediate, composite and effective membership or privilege in the system that currently exists or has existed in the past for members to groups or stems (for privileges).';

COMMENT ON COLUMN grouper_pit_memberships_all_v.ID IS 'ID: id of this membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBERSHIP_ID IS 'MEMBERSHIP_ID: id of the immediate (or composite) membership that causes this membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBERSHIP_SOURCE_ID IS 'MEMBERSHIP_SOURCE_ID: id of the actual (non-pit) immediate (or composite) membership that causes this membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.GROUP_SET_ID IS 'GROUP_SET_ID: id of the group set that causes this membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBER_ID IS 'MEMBER_ID: member id';

COMMENT ON COLUMN grouper_pit_memberships_all_v.FIELD_ID IS 'FIELD_ID: field id';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBERSHIP_FIELD_ID IS 'MEMBERSHIP_FIELD_ID: field id of the immediate (or composite) membership that causes this membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.OWNER_ID IS 'OWNER_ID: owner id';

COMMENT ON COLUMN grouper_pit_memberships_all_v.OWNER_ATTR_DEF_ID IS 'OWNER_ATTR_DEF_ID: owner attribute def id if applicable';

COMMENT ON COLUMN grouper_pit_memberships_all_v.OWNER_GROUP_ID IS 'OWNER_GROUP_ID: owner group id if applicable';

COMMENT ON COLUMN grouper_pit_memberships_all_v.OWNER_STEM_ID IS 'OWNER_STEM_ID: owner stem id if applicable';

COMMENT ON COLUMN grouper_pit_memberships_all_v.GROUP_SET_ACTIVE IS 'GROUP_SET_ACTIVE: whether the group set is active';

COMMENT ON COLUMN grouper_pit_memberships_all_v.GROUP_SET_START_TIME IS 'GROUP_SET_START_TIME: start time of the group set';

COMMENT ON COLUMN grouper_pit_memberships_all_v.GROUP_SET_END_TIME IS 'GROUP_SET_END_TIME: end time of the group set';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBERSHIP_ACTIVE IS 'MEMBERSHIP_ACTIVE: whether the immediate (or composite) membership is active';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBERSHIP_START_TIME IS 'MEMBERSHIP_START_TIME: start time of the immediate (or composite) membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.MEMBERSHIP_END_TIME IS 'MEMBERSHIP_END_TIME: end time of the immediate (or composite) membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.DEPTH IS 'DEPTH: depth of this membership';

COMMENT ON COLUMN grouper_pit_memberships_all_v.GROUP_SET_PARENT_ID IS 'GROUP_SET_PARENT_ID: parent group set';

CREATE VIEW grouper_memberships_lw_v (SUBJECT_ID, SUBJECT_SOURCE, GROUP_NAME, LIST_NAME, LIST_TYPE, GROUP_ID, MEMBER_ID) AS select distinct gm.SUBJECT_ID, gm.SUBJECT_SOURCE, gg.name as group_name, gfl.NAME as list_name, gfl.TYPE as list_type, gg.ID as group_id, gm.ID as member_id  from grouper_memberships_all_v gms, grouper_members gm, grouper_groups gg, grouper_fields gfl where gms.OWNER_GROUP_ID = gg.id and gms.FIELD_ID = gfl.ID and gms.MEMBER_ID = gm.ID and gms.IMMEDIATE_MSHIP_ENABLED = 'T';

COMMENT ON VIEW grouper_memberships_lw_v IS 'Grouper_memberships_lw_v unique membership records that can be read from a SQL interface outside of grouper.  Immediate and effective memberships are represented here (distinct)';

COMMENT ON COLUMN grouper_memberships_lw_v.SUBJECT_ID IS 'SUBJECT_ID: of the member of the group';

COMMENT ON COLUMN grouper_memberships_lw_v.SUBJECT_SOURCE IS 'SUBJECT_SOURCE: of the member of the group';

COMMENT ON COLUMN grouper_memberships_lw_v.GROUP_NAME IS 'GROUP_NAME: system name of the group';

COMMENT ON COLUMN grouper_memberships_lw_v.LIST_NAME IS 'LIST_NAME: name of the list, e.g. members';

COMMENT ON COLUMN grouper_memberships_lw_v.LIST_TYPE IS 'LIST_TYPE: type of list e.g. access or list';

COMMENT ON COLUMN grouper_memberships_lw_v.GROUP_ID IS 'GROUP_ID: uuid of the group';

COMMENT ON COLUMN grouper_memberships_lw_v.MEMBER_ID IS 'MEMBER_ID: uuid of the member';

CREATE VIEW grouper_mship_stem_lw_v (SUBJECT_ID, SUBJECT_SOURCE, STEM_NAME, LIST_NAME, LIST_TYPE, STEM_ID) AS select distinct gm.SUBJECT_ID, gm.SUBJECT_SOURCE, gs.name as stem_name, gfl.NAME as list_name, gfl.TYPE as list_type, gs.ID as stem_id from grouper_memberships_all_v gms, grouper_members gm, grouper_stems gs, grouper_fields gfl where gms.OWNER_STEM_ID = gs.id and gms.FIELD_ID = gfl.ID and gms.MEMBER_ID = gm.ID;

COMMENT ON VIEW grouper_mship_stem_lw_v IS 'grouper_mship_stem_lw_v unique membership records that can be read from a SQL interface outside of grouper for stems.  Immediate and effective memberships are represented here (distinct)';

COMMENT ON COLUMN grouper_mship_stem_lw_v.SUBJECT_ID IS 'SUBJECT_ID: of the member of the stem';

COMMENT ON COLUMN grouper_mship_stem_lw_v.SUBJECT_SOURCE IS 'SUBJECT_SOURCE: of the member of the stem';

COMMENT ON COLUMN grouper_mship_stem_lw_v.STEM_NAME IS 'STEM_NAME: system name of the stem';

COMMENT ON COLUMN grouper_mship_stem_lw_v.LIST_NAME IS 'LIST_NAME: name of the list, e.g. members';

COMMENT ON COLUMN grouper_mship_stem_lw_v.LIST_TYPE IS 'LIST_TYPE: type of list e.g. access or list';

COMMENT ON COLUMN grouper_mship_stem_lw_v.STEM_ID IS 'STEM_ID: uuid of the stem';

CREATE VIEW grouper_mship_attrdef_lw_v (SUBJECT_ID, SUBJECT_SOURCE, ATTRIBUTE_DEF_NAME, LIST_NAME, LIST_TYPE, ATTRIBUTE_DEF_ID) AS select distinct gm.SUBJECT_ID, gm.SUBJECT_SOURCE, gad.name as attribute_def_name, gfl.NAME as list_name, gfl.TYPE as list_type, gad.id as attribute_def_id from grouper_memberships_all_v gms, grouper_members gm, grouper_attribute_def gad, grouper_fields gfl where gms.OWNER_ATTR_DEF_ID = gad.id and gms.FIELD_ID = gfl.ID and gms.MEMBER_ID = gm.ID;

COMMENT ON VIEW grouper_mship_attrdef_lw_v IS 'grouper_mship_attrdef_lw_v unique membership records of attr defs that can be read from a SQL interface outside of grouper.  Immediate and effective memberships are represented here (distinct)';

COMMENT ON COLUMN grouper_mship_attrdef_lw_v.SUBJECT_ID IS 'SUBJECT_ID: of the member of the group';

COMMENT ON COLUMN grouper_mship_attrdef_lw_v.SUBJECT_SOURCE IS 'SUBJECT_SOURCE: of the member of the attributeDef';

COMMENT ON COLUMN grouper_mship_attrdef_lw_v.ATTRIBUTE_DEF_NAME IS 'ATTRIBUTE_DEF_NAME: system name of the attributeDef';

COMMENT ON COLUMN grouper_mship_attrdef_lw_v.LIST_NAME IS 'LIST_NAME: name of the list, e.g. members';

COMMENT ON COLUMN grouper_mship_attrdef_lw_v.LIST_TYPE IS 'LIST_TYPE: type of list e.g. access or list';

COMMENT ON COLUMN grouper_mship_attrdef_lw_v.ATTRIBUTE_DEF_ID IS 'ATTRIBUTE_DEF_ID: uuid of the attributeDef';

CREATE VIEW grouper_memberships_v (GROUP_NAME, GROUP_DISPLAYNAME, STEM_NAME, STEM_DISPLAYNAME, SUBJECT_ID, SUBJECT_SOURCE, MEMBER_ID, LIST_TYPE, LIST_NAME, MEMBERSHIP_TYPE, COMPOSITE_PARENT_GROUP_NAME, DEPTH, CREATOR_SOURCE, CREATOR_SUBJECT_ID, MEMBERSHIP_ID, IMMEDIATE_MEMBERSHIP_ID, GROUP_SET_ID, STEM_ID, GROUP_ID, CREATE_TIME, CREATOR_ID, FIELD_ID, CONTEXT_ID) AS select  (select gg.name from grouper_groups gg  where gg.id = gms.owner_group_id) as group_name,  (select gg.display_name from grouper_groups gg  where gg.id = gms.owner_group_id) as group_displayname,  (select gs.NAME from grouper_stems gs  where gs.ID = gms.owner_stem_id) as stem_name,  (select gs.display_NAME from grouper_stems gs  where gs.ID = gms.owner_stem_id) as stem_displayname,  gm.subject_id, gm.subject_source, gms.member_id, gf.TYPE as list_type,  gf.NAME as list_name,  gms.MSHIP_TYPE as membership_type,  (select gg.name from grouper_groups gg, grouper_composites gc  where gg.id = gms.VIA_composite_ID and gg.id = gc.OWNER) as composite_parent_group_name,  depth,   (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gms.membership_creator_ID) as creator_source,  (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gms.membership_creator_ID) as creator_subject_id,  gms.membership_id as membership_id,   gms.immediate_membership_id as immediate_membership_id,   gms.GROUP_SET_ID as group_set_id,  (select gs.id from grouper_stems gs where gs.ID = gms.owner_stem_id) as stem_id,  (select gg.id from grouper_groups gg where gg.id = gms.owner_group_id) as group_id,  gms.membership_create_time,  gms.membership_creator_id,  gms.field_id, gms.context_id   from grouper_memberships_all_v gms, grouper_members gm, grouper_fields gf   where gms.MEMBER_ID = gm.ID and gms.field_id = gf.id  ;

COMMENT ON VIEW grouper_memberships_v IS 'Grouper_memberships_v holds one record for each membership or privilege in the system for members to groups or stems (for privileges).  This is denormalized so there are records for the actual immediate relationships, and the cascaded effective relationships.  This has friendly names.';

COMMENT ON COLUMN grouper_memberships_v.GROUP_NAME IS 'GROUP_NAME: name of the group if this is a group membership, e.g. school:stem1:theGroup';

COMMENT ON COLUMN grouper_memberships_v.GROUP_DISPLAYNAME IS 'GROUP_DISPLAYNAME: display name of the group if this is a group membership, e.g. My school:The stem1:The group';

COMMENT ON COLUMN grouper_memberships_v.STEM_NAME IS 'STEM_NAME: name of the stem if this is a stem privilege, e.g. school:stem1';

COMMENT ON COLUMN grouper_memberships_v.STEM_DISPLAYNAME IS 'STEM_DISPLAYNAME: display name of the stems if this is a stem privilege, e.g. My school:The stem1';

COMMENT ON COLUMN grouper_memberships_v.SUBJECT_ID IS 'SUBJECT_ID: e.g. a school id of a person in the membership e.g. 12345';

COMMENT ON COLUMN grouper_memberships_v.SUBJECT_SOURCE IS 'SUBJECT_SOURCE: source where the subject in the membership is from e.g. mySchoolPeople';

COMMENT ON COLUMN grouper_memberships_v.MEMBER_ID IS 'MEMBER_ID: id in the grouper_members table';

COMMENT ON COLUMN grouper_memberships_v.LIST_TYPE IS 'LIST_TYPE: list: members of a group, access: privilege of a group, naming: privilege of a stem';

COMMENT ON COLUMN grouper_memberships_v.LIST_NAME IS 'LIST_NAME: subset of list type.  which list if a list membership.  which privilege if a privilege.  e.g. members';

COMMENT ON COLUMN grouper_memberships_v.MEMBERSHIP_TYPE IS 'MEMBERSHIP_TYPE: either immediate (direct membership or privilege), of effective (membership due to a composite or a group being a member of another group)';

COMMENT ON COLUMN grouper_memberships_v.COMPOSITE_PARENT_GROUP_NAME IS 'COMPOSITE_PARENT_GROUP_NAME: name of group if this membership relates to a composite relationship, e.g. school:stem:allStudents';

COMMENT ON COLUMN grouper_memberships_v.DEPTH IS 'DEPTH: 0 for composite, if not then it is the 0 indexed count of number of group hops between member and group';

COMMENT ON COLUMN grouper_memberships_v.CREATOR_SOURCE IS 'CREATOR_SOURCE: subject source where the creator of the group is from';

COMMENT ON COLUMN grouper_memberships_v.CREATOR_SUBJECT_ID IS 'CREATOR_SUBJECT_ID: subject id of the creator of the group, e.g. 12345';

COMMENT ON COLUMN grouper_memberships_v.MEMBERSHIP_ID IS 'MEMBERSHIP_ID: uuid unique id of this membership';

COMMENT ON COLUMN grouper_memberships_v.IMMEDIATE_MEMBERSHIP_ID IS 'IMMEDIATE_MEMBERSHIP_ID: uuid of the immediate membership that causes this membership';

COMMENT ON COLUMN grouper_memberships_v.GROUP_SET_ID IS 'GROUP_SET_ID: uuid of the group set that causes this membership';

COMMENT ON COLUMN grouper_memberships_v.STEM_ID IS 'STEM_ID: if this is a stem privilege, this is the stem uuid unique id';

COMMENT ON COLUMN grouper_memberships_v.GROUP_ID IS 'GROUP_ID: if this is a group list or privilege, this is the group uuid unique id';

COMMENT ON COLUMN grouper_memberships_v.CREATE_TIME IS 'CREATE_TIME: number of millis since 1970 since this membership was created';

COMMENT ON COLUMN grouper_memberships_v.CREATOR_ID IS 'CREATOR_ID: member_id of the creator, foreign key into grouper_members';

COMMENT ON COLUMN grouper_memberships_v.FIELD_ID IS 'FIELD_ID: uuid unique id of the field.  foreign key to grouper_fields.  This represents the list_type and list_name';

COMMENT ON COLUMN grouper_memberships_v.CONTEXT_ID IS 'CONTEXT_ID: Context id links together multiple operations into one high level action';

CREATE VIEW grouper_stems_v (EXTENSION, NAME, DISPLAY_EXTENSION, DISPLAY_NAME, DESCRIPTION, PARENT_STEM_NAME, PARENT_STEM_DISPLAYNAME, CREATOR_SOURCE, CREATOR_SUBJECT_ID, MODIFIER_SOURCE, MODIFIER_SUBJECT_ID, CREATE_TIME, CREATOR_ID, STEM_ID, MODIFIER_ID, MODIFY_TIME, PARENT_STEM, HIBERNATE_VERSION_NUMBER, CONTEXT_ID) AS select gs.extension, gs.NAME, gs.DISPLAY_EXTENSION, gs.DISPLAY_NAME, gs.DESCRIPTION, (select gs_parent.NAME from grouper_stems gs_parent where gs_parent.id = gs.PARENT_STEM) as parent_stem_name, (select gs_parent.DISPLAY_NAME from grouper_stems gs_parent where gs_parent.id = gs.PARENT_STEM) as parent_stem_displayname, (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gs.creator_ID) as creator_source, (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gs.creator_ID) as creator_subject_id, (select gm.SUBJECT_SOURCE from grouper_members gm where gm.ID = gs.MODIFIER_ID) as modifier_source, (select gm.SUBJECT_ID from grouper_members gm where gm.ID = gs.MODIFIER_ID) as modifier_subject_id, gs.CREATE_TIME, gs.CREATOR_ID,  gs.ID as stem_id, gs.MODIFIER_ID, gs.MODIFY_TIME, gs.PARENT_STEM, gs.HIBERNATE_VERSION_NUMBER, gs.context_id from grouper_stems gs ;

COMMENT ON VIEW grouper_stems_v IS 'GROUPER_STEMS_V: holds one record for each stem (folder) in grouper, with friendly names';

COMMENT ON COLUMN grouper_stems_v.EXTENSION IS 'EXTENSION: name of the stem without the parent stem names, e.g. stem1';

COMMENT ON COLUMN grouper_stems_v.NAME IS 'NAME: name of the stem including parent stem names, e.g. school:stem1';

COMMENT ON COLUMN grouper_stems_v.DISPLAY_EXTENSION IS 'DISPLAY_EXTENSION: display name of the stem without parent stem names, e.g. The stem 1';

COMMENT ON COLUMN grouper_stems_v.DISPLAY_NAME IS 'DISPLAY_NAME: display name of the stem including parent stem names, e.g. My school: The stem 1';

COMMENT ON COLUMN grouper_stems_v.DESCRIPTION IS 'DESCRIPTION: description entered in about the stem, for example including why the stem exists and who has access';

COMMENT ON COLUMN grouper_stems_v.PARENT_STEM_NAME IS 'PARENT_STEM_NAME: name of the stem (folder) that this stem is in.  e.g. school';

COMMENT ON COLUMN grouper_stems_v.PARENT_STEM_DISPLAYNAME IS 'PARENT_STEM_DISPLAYNAME: display name of the stem (folder) that this stem is in.  e.g. My school';

COMMENT ON COLUMN grouper_stems_v.CREATOR_SOURCE IS 'CREATOR_SOURCE: subject source where the subject that created this stem is from, e.g. mySchoolPeople';

COMMENT ON COLUMN grouper_stems_v.CREATOR_SUBJECT_ID IS 'CREATOR_SUBJECT_ID: e.g. the school id of the subject that created this stem, e.g. 12345';

COMMENT ON COLUMN grouper_stems_v.MODIFIER_SOURCE IS 'MODIFIER_SOURCE: subject source where the subject that last modified this stem is from, e.g. mySchoolPeople';

COMMENT ON COLUMN grouper_stems_v.MODIFIER_SUBJECT_ID IS 'MODIFIER_SUBJECT_ID: e.g. the school id of the subject who last modified this stem, e.g. 12345';

COMMENT ON COLUMN grouper_stems_v.CREATE_TIME IS 'CREATE_TIME: number of millis since 1970 that this stem was created';

COMMENT ON COLUMN grouper_stems_v.CREATOR_ID IS 'CREATOR_ID: member id of the subject who created this stem, foreign key to grouper_members';

COMMENT ON COLUMN grouper_stems_v.STEM_ID IS 'STEM_ID: uuid unique id of this stem';

COMMENT ON COLUMN grouper_stems_v.MODIFIER_ID IS 'MODIFIER_ID: member id of the subject who last modified this stem, foreign key to grouper_members';

COMMENT ON COLUMN grouper_stems_v.MODIFY_TIME IS 'MODIFY_TIME: number of millis since 1970 since this stem was last modified';

COMMENT ON COLUMN grouper_stems_v.PARENT_STEM IS 'PARENT_STEM: stem_id uuid unique id of the stem (folder) that this stem is in';

COMMENT ON COLUMN grouper_stems_v.HIBERNATE_VERSION_NUMBER IS 'HIBERNATE_VERSION_NUMBER: increments by one for each update from hibernate';

COMMENT ON COLUMN grouper_stems_v.CONTEXT_ID IS 'CONTEXT_ID: Context id links together multiple operations into one high level action';

CREATE VIEW grouper_rpt_attributes_v (ATTRIBUTE_NAME, GROUP_COUNT, GROUP_TYPE_NAME, FIELD_ID, GROUP_TYPE_ID) AS select gf.NAME as attribute_name,  (select count(*) from grouper_attributes ga where ga.FIELD_ID = gf.id) as group_count,   gt.NAME as group_type_name, gf.ID as field_id, gt.ID as group_type_id from grouper_fields gf, grouper_types gt where gf.TYPE = 'attribute' and gf.GROUPTYPE_UUID = gt.ID ;

COMMENT ON VIEW grouper_rpt_attributes_v IS 'GROUPER_RPT_ATTRIBUTES_V: report on attributes, how many groups use each attribute';

COMMENT ON COLUMN grouper_rpt_attributes_v.ATTRIBUTE_NAME IS 'ATTRIBUTE_NAME: friendly name of the attribute which is actually from grouper_fields';

COMMENT ON COLUMN grouper_rpt_attributes_v.GROUP_COUNT IS 'GROUP_COUNT: number of groups which define this attribute';

COMMENT ON COLUMN grouper_rpt_attributes_v.GROUP_TYPE_NAME IS 'GROUP_TYPE_NAME: group type which owns this attribute';

COMMENT ON COLUMN grouper_rpt_attributes_v.FIELD_ID IS 'FIELD_ID: uuid unique id of this field (attribute), foreign key from grouper_attributes to grouper_fields';

COMMENT ON COLUMN grouper_rpt_attributes_v.GROUP_TYPE_ID IS 'GROUP_TYPE_ID: uuid unique id of the group type.  foreign key from grouper_fields to grouper_types';

CREATE VIEW grouper_rpt_composites_v (COMPOSITE_TYPE, THE_COUNT) AS select gc.TYPE as composite_type, count(*) as the_count from grouper_composites gc group by gc.type ;

COMMENT ON VIEW grouper_rpt_composites_v IS 'GROUPER_RPT_COMPOSITES_V: report on the three composite types: union, intersection, complement and how many of each exist';

COMMENT ON COLUMN grouper_rpt_composites_v.COMPOSITE_TYPE IS 'COMPOSITE_TYPE: either union: all members from both factors, intersection: only members in both factors, complement: members in first but not second factor';

COMMENT ON COLUMN grouper_rpt_composites_v.THE_COUNT IS 'THE_COUNT: nubmer of composites of this type in the system';

CREATE VIEW grouper_rpt_group_field_v (GROUP_NAME, GROUP_DISPLAYNAME, FIELD_TYPE, FIELD_NAME, MEMBER_COUNT) AS select gg.name as group_name, gg.display_name as group_displayName, gf.type as field_type, gf.name as field_name, count(distinct gms.member_id) as member_count from grouper_memberships_all_v gms, grouper_groups gg, grouper_fields gf where gms.FIELD_ID = gf.ID and gg.id = gms.OWNER_group_ID group by gg.name, gg.display_name, gf.type, gf.name ;

COMMENT ON VIEW grouper_rpt_group_field_v IS 'GROUPER_RPT_GROUP_FIELD_V: report on how many unique members are in each group based on field (or list) name and type';

COMMENT ON COLUMN grouper_rpt_group_field_v.GROUP_NAME IS 'GROUP_NAME: name of the group where the list and members are, e.g. school:stem1:myGroup';

COMMENT ON COLUMN grouper_rpt_group_field_v.GROUP_DISPLAYNAME IS 'GROUP_DISPLAYNAME: display name of the group where the list and members are, e.g. My school:The stem1:My group';

COMMENT ON COLUMN grouper_rpt_group_field_v.FIELD_TYPE IS 'FIELD_TYPE: membership field type, e.g. list or access';

COMMENT ON COLUMN grouper_rpt_group_field_v.FIELD_NAME IS 'FIELD_NAME: membership field name, e.g. members, admins, readers';

COMMENT ON COLUMN grouper_rpt_group_field_v.MEMBER_COUNT IS 'MEMBER_COUNT: number of unique members in the group/field';

CREATE VIEW grouper_rpt_groups_v (GROUP_NAME, GROUP_DISPLAYNAME, TYPE_OF_GROUP, IMMEDIATE_MEMBERSHIP_COUNT, MEMBERSHIP_COUNT, ATTRIBUTE_COUNT, GROUPS_TYPES_COUNT, ISA_COMPOSITE_FACTOR_COUNT, ISA_MEMBER_COUNT, GROUP_ID) AS select  gg.name as group_name, gg.display_name as group_displayname, gg.type_of_group, (select count(distinct gms.MEMBER_ID) from grouper_memberships_all_v gms where gms.OWNER_group_ID = gg.id and gms.MSHIP_TYPE = 'immediate') as immediate_membership_count, (select count(distinct gms.MEMBER_ID) from grouper_memberships_all_v gms where gms.OWNER_group_ID = gg.id) as membership_count, (select count(*) from grouper_attributes ga where ga.GROUP_ID = gg.id) as attribute_count, (select count(*) from grouper_groups_types ggt where ggt.GROUP_UUID = gg.id) as groups_types_count, (select count(*) from grouper_composites gc where gc.LEFT_FACTOR = gg.id or gc.RIGHT_FACTOR = gg.id) as isa_composite_factor_count, (select count(distinct gms.OWNER_group_ID) from grouper_memberships_all_v gms, grouper_members gm where gm.SUBJECT_ID = gg.ID and gms.MEMBER_ID = gm.ID ) as isa_member_count, gg.ID as group_id from grouper_groups gg ;

COMMENT ON VIEW grouper_rpt_groups_v IS 'GROUPER_RPT_GROUPS_V: report with a line for each group and some counts of immediate and effective members etc';

COMMENT ON COLUMN grouper_rpt_groups_v.GROUP_NAME IS 'GROUP_NAME: name of group which has the stats, e.g. school:stem1:theGroup';

COMMENT ON COLUMN grouper_rpt_groups_v.GROUP_DISPLAYNAME IS 'GROUP_DISPLAYNAME: display name of the group which has the stats, e.g. My school:The stem1:The group';

COMMENT ON COLUMN grouper_rpt_groups_v.TYPE_OF_GROUP IS 'TYPE_OF_GROUP: group if it is a group, role if it is a role';

COMMENT ON COLUMN grouper_rpt_groups_v.IMMEDIATE_MEMBERSHIP_COUNT IS 'IMMEDIATE_MEMBERSHIP_COUNT: number of unique immediate members, directly assigned to this group';

COMMENT ON COLUMN grouper_rpt_groups_v.MEMBERSHIP_COUNT IS 'MEMBERSHIP_COUNT: total number of unique members, immediate or effective';

COMMENT ON COLUMN grouper_rpt_groups_v.ATTRIBUTE_COUNT IS 'ATTRIBUTE_COUNT: number of attributes defined for this group';

COMMENT ON COLUMN grouper_rpt_groups_v.GROUPS_TYPES_COUNT IS 'GROUPS_TYPES_COUNT: number of group types associated with this group';

COMMENT ON COLUMN grouper_rpt_groups_v.ISA_COMPOSITE_FACTOR_COUNT IS 'ISA_COMPOSITE_FACTOR_COUNT: number of composites this group is a factor of';

COMMENT ON COLUMN grouper_rpt_groups_v.ISA_MEMBER_COUNT IS 'ISA_MEMBER_COUNT: number of groups this group is an immediate or effective member of';

COMMENT ON COLUMN grouper_rpt_groups_v.GROUP_ID IS 'GROUP_ID: uuid unique id of this group';

CREATE VIEW grouper_rpt_roles_v (ROLE_NAME, ROLE_DISPLAYNAME, IMMEDIATE_MEMBERSHIP_COUNT, MEMBERSHIP_COUNT, ATTRIBUTE_COUNT, ROLES_TYPES_COUNT, ISA_COMPOSITE_FACTOR_COUNT, ISA_MEMBER_COUNT, ROLE_ID) AS select  gg.name as role_name, gg.display_name as role_displayname, (select count(distinct gms.member_id) from grouper_memberships_all_v gms where gms.OWNER_group_ID = gg.id and gms.mship_type = 'immediate') as immediate_membership_count, (select count(distinct gms.member_id) from grouper_memberships_all_v gms where gms.OWNER_group_ID = gg.id) as membership_count, (select count(*) from grouper_attributes ga where ga.GROUP_ID = gg.id) as attribute_count, (select count(*) from grouper_groups_types ggt where ggt.GROUP_UUID = gg.id) as roles_types_count, (select count(*) from grouper_composites gc where gc.LEFT_FACTOR = gg.id or gc.RIGHT_FACTOR = gg.id) as isa_composite_factor_count, (select count(distinct gms.OWNER_group_ID) from grouper_memberships_all_v gms, grouper_members gm where gm.SUBJECT_ID = gg.ID and gms.MEMBER_ID = gm.ID ) as isa_member_count, gg.ID as role_id from grouper_groups gg  where gg.type_of_group = 'role' ;

COMMENT ON VIEW grouper_rpt_roles_v IS 'GROUPER_RPT_ROLES_V: report with a line for each role and some counts of immediate and effective members etc';

COMMENT ON COLUMN grouper_rpt_roles_v.ROLE_NAME IS 'ROLE_NAME: name of group which has the stats, e.g. school:stem1:theGroup';

COMMENT ON COLUMN grouper_rpt_roles_v.ROLE_DISPLAYNAME IS 'ROLE_DISPLAYNAME: display name of the group which has the stats, e.g. My school:The stem1:The group';

COMMENT ON COLUMN grouper_rpt_roles_v.IMMEDIATE_MEMBERSHIP_COUNT IS 'IMMEDIATE_MEMBERSHIP_COUNT: number of unique immediate members, directly assigned to this group';

COMMENT ON COLUMN grouper_rpt_roles_v.MEMBERSHIP_COUNT IS 'MEMBERSHIP_COUNT: total number of unique members, immediate or effective';

COMMENT ON COLUMN grouper_rpt_roles_v.ATTRIBUTE_COUNT IS 'ATTRIBUTE_COUNT: number of attributes defined for this group';

COMMENT ON COLUMN grouper_rpt_roles_v.ROLES_TYPES_COUNT IS 'ROLES_TYPES_COUNT: number of group types associated with this group';

COMMENT ON COLUMN grouper_rpt_roles_v.ISA_COMPOSITE_FACTOR_COUNT IS 'ISA_COMPOSITE_FACTOR_COUNT: number of composites this group is a factor of';

COMMENT ON COLUMN grouper_rpt_roles_v.ISA_MEMBER_COUNT IS 'ISA_MEMBER_COUNT: number of groups this group is an immediate or effective member of';

COMMENT ON COLUMN grouper_rpt_roles_v.ROLE_ID IS 'ROLE_ID: uuid unique id of this group';

CREATE VIEW grouper_rpt_members_v (SUBJECT_ID, SUBJECT_SOURCE, MEMBERSHIP_COUNT, MEMBER_ID) AS select gm.SUBJECT_ID, gm.SUBJECT_SOURCE, (select count(distinct gms.owner_group_id) from grouper_memberships gms where gms.MEMBER_ID = gm.ID) as membership_count, gm.ID as member_id from grouper_members gm ;

COMMENT ON VIEW grouper_rpt_members_v IS 'GROUPER_RPT_MEMBERS_V: report for each member in grouper_members and some stats like how many groups they are in';

COMMENT ON COLUMN grouper_rpt_members_v.SUBJECT_ID IS 'SUBJECT_ID: e.g. the school person id of the person e.g. 12345';

COMMENT ON COLUMN grouper_rpt_members_v.SUBJECT_SOURCE IS 'SUBJECT_SOURCE: subject source where the subject is from, e.g. schoolAllPeople';

COMMENT ON COLUMN grouper_rpt_members_v.MEMBERSHIP_COUNT IS 'MEMBERSHIP_COUNT: number of distinct groups or stems this member has a membership with';

COMMENT ON COLUMN grouper_rpt_members_v.MEMBER_ID IS 'MEMBER_ID: uuid unique id of the member in grouper_members';

CREATE VIEW grouper_rpt_stems_v (STEM_NAME, STEM_DISPLAYNAME, GROUP_IMMEDIATE_COUNT, STEM_IMMEDIATE_COUNT, GROUP_COUNT, STEM_COUNT, THIS_STEM_MEMBERSHIP_COUNT, CHILD_GROUP_MEMBERSHIP_COUNT, GROUP_MEMBERSHIP_COUNT, STEM_ID) AS select gs.name as stem_name, gs.display_name as stem_displayname, (select count(*) from grouper_groups gg where gg.parent_stem = gs.ID) as group_immediate_count, (select count(*) from grouper_stems gs2 where gs.id = gs2.parent_stem ) as stem_immediate_count, (select count(*) from grouper_groups gg where gg.name like gs.name || '%') as group_count, (select count(*) from grouper_stems gs2 where gs2.name like gs.name || '%') as stem_count, (select count(distinct gm.member_id) from grouper_memberships_all_v gm where gm.owner_stem_id = gs.id) as this_stem_membership_count,  (select count(distinct gm.member_id) from grouper_memberships_all_v gm, grouper_groups gg where gg.parent_stem = gs.id and gm.owner_stem_id = gg.id) as child_group_membership_count,  (select count(distinct gm.member_id) from grouper_memberships_all_v gm, grouper_groups gg where gm.owner_group_id = gg.id and gg.name like gs.name || '%') as group_membership_count, gs.ID as stem_id from grouper_stems gs ;

COMMENT ON VIEW grouper_rpt_stems_v IS 'GROUPER_RPT_STEMS_V: report with a row for each stem and stats on many groups or members are inside';

COMMENT ON COLUMN grouper_rpt_stems_v.STEM_NAME IS 'STEM_NAME: name of the stem in report, e.g. school:stem1';

COMMENT ON COLUMN grouper_rpt_stems_v.STEM_DISPLAYNAME IS 'STEM_DISPLAYNAME: display name of the stem in report, e.g. My school:The stem 1';

COMMENT ON COLUMN grouper_rpt_stems_v.GROUP_IMMEDIATE_COUNT IS 'GROUP_IMMEDIATE_COUNT: number of groups directly inside this stem';

COMMENT ON COLUMN grouper_rpt_stems_v.STEM_IMMEDIATE_COUNT IS 'STEM_IMMEDIATE_COUNT: number of stems directly inside this stem';

COMMENT ON COLUMN grouper_rpt_stems_v.GROUP_COUNT IS 'GROUP_COUNT: number of groups inside this stem, or in a stem inside this stem etc';

COMMENT ON COLUMN grouper_rpt_stems_v.STEM_COUNT IS 'STEM_COUNT: number of stems inside this stem or in a stem inside this stem etc';

COMMENT ON COLUMN grouper_rpt_stems_v.THIS_STEM_MEMBERSHIP_COUNT IS 'THIS_STEM_MEMBERSHIP_COUNT: number of access memberships related to this stem (e.g. how many people can create groups/stems inside)';

COMMENT ON COLUMN grouper_rpt_stems_v.CHILD_GROUP_MEMBERSHIP_COUNT IS 'CHILD_GROUP_MEMBERSHIP_COUNT: number of memberships in groups immediately in this stem';

COMMENT ON COLUMN grouper_rpt_stems_v.GROUP_MEMBERSHIP_COUNT IS 'GROUP_MEMBERSHIP_COUNT: number of memberships in groups in this stem or in stems in this stem etc';

COMMENT ON COLUMN grouper_rpt_stems_v.STEM_ID IS 'STEM_ID: uuid unique id of this stem';

CREATE VIEW grouper_rpt_types_v (GROUP_TYPE_NAME, GROUP_COUNT, GROUP_TYPE_ID) AS select gt.NAME as group_type_name, (select count(*) from grouper_groups_types ggt where ggt.TYPE_UUID = gt.ID) as group_count, gt.id as group_type_id from grouper_types gt ;

COMMENT ON VIEW grouper_rpt_types_v IS 'GROUPER_RPT_TYPES_V: report on group types and how many groups have that type';

COMMENT ON COLUMN grouper_rpt_types_v.GROUP_TYPE_NAME IS 'GROUP_TYPE_NAME: friendly name of this group type';

COMMENT ON COLUMN grouper_rpt_types_v.GROUP_COUNT IS 'GROUP_COUNT: number of groups that have this group type';

COMMENT ON COLUMN grouper_rpt_types_v.GROUP_TYPE_ID IS 'GROUP_TYPE_ID: uuid unique id of this group type';

CREATE VIEW grouper_role_set_v (if_has_role_name, then_has_role_name, depth, type, parent_if_has_name, parent_then_has_name, id, if_has_role_id, then_has_role_id, parent_role_set_id) AS select ifHas.name as if_has_role_name, thenHas.name as then_has_role_name,  grs.depth,   grs.type, grParentIfHas.name as parent_if_has_name, grParentThenHas.name as parent_then_has_name,   grs.id, ifHas.id as if_has_role_id, thenHas.id as then_has_role_id,   grs.parent_role_set_id  from grouper_role_set grs,   grouper_role_set grsParent,   grouper_groups grParentIfHas,   grouper_groups grParentThenHas,   grouper_groups ifHas, grouper_groups thenHas   where  thenHas.id = grs.then_has_role_id   and ifHas.id = grs.if_has_role_id   and grs.parent_role_set_id = grsParent.id   and grParentIfHas.id = grsParent.if_has_role_id   and grParentThenHas.id = grsParent.then_has_role_id   ;

COMMENT ON VIEW grouper_role_set_v IS 'grouper_role_set_v: shows all role set relationships';

COMMENT ON COLUMN grouper_role_set_v.if_has_role_name IS 'if_has_role_name: name of the set role';

COMMENT ON COLUMN grouper_role_set_v.then_has_role_name IS 'then_has_role_name: name of the member role';

COMMENT ON COLUMN grouper_role_set_v.depth IS 'depth: number of hops in the directed graph';

COMMENT ON COLUMN grouper_role_set_v.type IS 'type: self, immediate, effective';

COMMENT ON COLUMN grouper_role_set_v.parent_if_has_name IS 'parent_if_has_name: name of the role set record which is the parent ifHas on effective path (everything but last hop)';

COMMENT ON COLUMN grouper_role_set_v.parent_then_has_name IS 'parent_then_has_name: name of the role set record which is the parent thenHas on effective path (everything but last hop)';

COMMENT ON COLUMN grouper_role_set_v.id IS 'id: id of the set record';

COMMENT ON COLUMN grouper_role_set_v.if_has_role_id IS 'if_has_role_id: id of the set role';

COMMENT ON COLUMN grouper_role_set_v.then_has_role_id IS 'then_has_role_id: id of the member role';

COMMENT ON COLUMN grouper_role_set_v.parent_role_set_id IS 'parent_role_set_id: id of the role set record which is the parent on effective path (everything but last hop)';

CREATE VIEW grouper_attr_def_name_set_v (if_has_attr_def_name_name, then_has_attr_def_name_name, depth, type, parent_if_has_name, parent_then_has_name, id, if_has_attr_def_name_id, then_has_attr_def_name_id, parent_attr_def_name_set_id) AS select ifHas.name as if_has_attr_def_name_name, thenHas.name as then_has_attr_def_name_name,  gadns.depth,  gadns.type, gadnParentIfHas.name as parent_if_has_name, gadnParentThenHas.name as parent_then_has_name,  gadns.id,  ifHas.id as if_has_attr_def_name_id, thenHas.id as then_has_attr_def_name_id,  gadns.parent_attr_def_name_set_id from grouper_attribute_def_name_set gadns,  grouper_attribute_def_name_set gadnsParent,  grouper_attribute_def_name gadnParentIfHas,  grouper_attribute_def_name gadnParentThenHas,  grouper_attribute_def_name ifHas, grouper_attribute_def_name thenHas  where  thenHas.id = gadns.then_has_attribute_def_name_id  and ifHas.id = gadns.if_has_attribute_def_name_id  and gadns.parent_attr_def_name_set_id = gadnsParent.id  and gadnParentIfHas.id = gadnsParent.if_has_attribute_def_name_id  and gadnParentThenHas.id = gadnsParent.then_has_attribute_def_name_id  ;

COMMENT ON VIEW grouper_attr_def_name_set_v IS 'grouper_attr_def_name_set_v: shows all attribute def name set relationships';

COMMENT ON COLUMN grouper_attr_def_name_set_v.if_has_attr_def_name_name IS 'if_has_attr_def_name_name: name of the set attribute def name';

COMMENT ON COLUMN grouper_attr_def_name_set_v.then_has_attr_def_name_name IS 'then_has_attr_def_name_name: name of the member attribute def name';

COMMENT ON COLUMN grouper_attr_def_name_set_v.depth IS 'depth: number of hops in the directed graph';

COMMENT ON COLUMN grouper_attr_def_name_set_v.type IS 'type: self, immediate, effective';

COMMENT ON COLUMN grouper_attr_def_name_set_v.parent_if_has_name IS 'parent_if_has_name: name of the attribute def name set record which is the parent ifHas on effective path (everything but last hop)';

COMMENT ON COLUMN grouper_attr_def_name_set_v.parent_then_has_name IS 'parent_then_has_name: name of the attribute def name set record which is the parent thenHas on effective path (everything but last hop)';

COMMENT ON COLUMN grouper_attr_def_name_set_v.id IS 'id: id of the set record';

COMMENT ON COLUMN grouper_attr_def_name_set_v.if_has_attr_def_name_id IS 'if_has_attr_def_name_id: id of the set attribute def name';

COMMENT ON COLUMN grouper_attr_def_name_set_v.then_has_attr_def_name_id IS 'then_has_attr_def_name_id: id of the member attribute def name';

COMMENT ON COLUMN grouper_attr_def_name_set_v.parent_attr_def_name_set_id IS 'parent_attr_def_name_set_id: id of the attribute def name set record which is the parent on effective path (everything but last hop)';

CREATE VIEW grouper_attr_assn_action_set_v (if_has_attr_assn_action_name, then_has_attr_assn_action_name, depth, type, parent_if_has_name, parent_then_has_name, id, if_has_attr_assn_action_id, then_has_attr_assn_action_id, parent_attr_assn_action_id) AS select ifHas.name as if_has_attr_assn_action_name , thenHas.name as then_has_attr_assn_action_name,   gaaas.depth,   gaaas.type, gaaaParentIfHas.name as parent_if_has_name, gaaaParentThenHas.name as parent_then_has_name,   gaaas.id,   ifHas.id as if_has_attr_assn_action_id, thenHas.id as then_has_attr_assn_action_id,   gaaas.parent_attr_assn_action_id  from grouper_attr_assign_action_set gaaas,   grouper_attr_assign_action_set gaaasParent,   grouper_attr_assign_action gaaaParentIfHas,   grouper_attr_assign_action gaaaParentThenHas,   grouper_attr_assign_action ifHas, grouper_attr_assign_action thenHas   where  thenHas.id = gaaas.then_has_attr_assn_action_id   and ifHas.id = gaaas.if_has_attr_assn_action_id   and gaaas.parent_attr_assn_action_id = gaaasParent.id   and gaaaParentIfHas.id = gaaasParent.if_has_attr_assn_action_id   and gaaaParentThenHas.id = gaaasParent.then_has_attr_assn_action_id   ;

COMMENT ON VIEW grouper_attr_assn_action_set_v IS 'grouper_attr_assn_action_set_v: shows all action set relationships';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.if_has_attr_assn_action_name IS 'if_has_attr_assn_action_name: name of the set attribute action';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.then_has_attr_assn_action_name IS 'then_has_attr_assn_action_name: name of the member attribute action';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.depth IS 'depth: number of hops in the directed graph';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.type IS 'type: self, immediate, effective';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.parent_if_has_name IS 'parent_if_has_name: name of the attribute def name set record which is the parent ifHas on effective path (everything but last hop)';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.parent_then_has_name IS 'parent_then_has_name: name of the attribute def name set record which is the parent thenHas on effective path (everything but last hop)';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.id IS 'id: id of the set record';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.if_has_attr_assn_action_id IS 'if_has_attr_assn_action_id: id of the set attribute assign name';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.then_has_attr_assn_action_id IS 'then_has_attr_assn_action_id: id of the member attribute action';

COMMENT ON COLUMN grouper_attr_assn_action_set_v.parent_attr_assn_action_id IS 'parent_attr_assn_action_id: id of the attribute action set record which is the parent on effective path (everything but last hop)';

CREATE VIEW grouper_attr_asn_group_v (group_name, action, attribute_def_name_name, group_display_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, attribute_assign_delegatable, enabled, enabled_time, disabled_time, group_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id) AS select gg.name as group_name, gaaa.name as action, gadn.name as attribute_def_name_name, gg.display_name as group_display_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gg.id as group_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id from grouper_attribute_assign gaa, grouper_groups gg, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa  where gaa.owner_group_id = gg.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.owner_member_id is null and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_attr_asn_group_v IS 'grouper_attr_asn_group_v: attribute assigned to a group, with related columns';

COMMENT ON COLUMN grouper_attr_asn_group_v.group_name IS 'group_name: name of group assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_group_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_group_v.group_display_name IS 'group_display_name: display name of the group assigned an attribute';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_group_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_attr_asn_group_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_group_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_group_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_group_v.group_id IS 'group_id: group id of the group assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_group_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_asn_group_v.action_id IS 'action_id: id of the attribute assign action';

CREATE VIEW grouper_attr_asn_efmship_v (group_name, subject_source_id, subject_id, action, attribute_def_name_name, group_display_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, list_name, attribute_assign_delegatable, enabled, enabled_time, disabled_time, group_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, member_id, action_id) AS select distinct gg.name as group_name, gm.subject_source as subject_source_id, gm.subject_id, gaaa.name as action, gadn.name as attribute_def_name_name, gg.display_name as group_display_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gf.name as list_name, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gg.id as group_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gm.id as member_id, gaaa.id as action_id from grouper_attribute_assign gaa, grouper_memberships_all_v gmav, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_groups gg, grouper_fields gf, grouper_members gm, grouper_attr_assign_action gaaa  where gaa.owner_group_id = gmav.owner_group_id and gaa.owner_member_id = gmav.member_id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gmav.immediate_mship_enabled = 'T' and gmav.owner_group_id = gg.id and gmav.field_id = gf.id and gf.type = 'list' and gmav.member_id = gm.id and gaa.owner_member_id is not null and gaa.owner_group_id is not null and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_attr_asn_efmship_v IS 'grouper_attr_asn_efmship_v: attribute assigned to an effective membership';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.group_name IS 'group_name: name of group assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.subject_source_id IS 'subject_source_id: source id of the subject being assigned';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.subject_id IS 'subject_id: subject id of the subject being assigned';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.group_display_name IS 'group_display_name: display name of the group assigned an attribute';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.list_name IS 'list_name: name of the membership list for this effective membership';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.group_id IS 'group_id: group id of the group assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.member_id IS 'member_id: id of the member assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_efmship_v.action_id IS 'action_id: attribute assign action id';

CREATE VIEW grouper_attr_asn_stem_v (stem_name, action, attribute_def_name_name, stem_display_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, enabled, enabled_time, disabled_time, stem_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id) AS select gs.name as stem_name, gaaa.name as action, gadn.name as attribute_def_name_name, gs.display_name as stem_display_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gs.id as stem_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id from grouper_attribute_assign gaa, grouper_stems gs, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa  where gaa.owner_stem_id = gs.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_attr_asn_stem_v IS 'grouper_attr_asn_stem_v: attribute assigned to a stem and related cols';

COMMENT ON COLUMN grouper_attr_asn_stem_v.stem_name IS 'stem_name: name of stem assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_stem_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_stem_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_stem_v.stem_display_name IS 'stem_display_name: display name of the stem assigned an attribute';

COMMENT ON COLUMN grouper_attr_asn_stem_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_stem_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_stem_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_stem_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_stem_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_stem_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_stem_v.stem_id IS 'stem_id: stem id of the stem assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_stem_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_stem_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_stem_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_asn_stem_v.action_id IS 'action_id: id of the attribute assign action';

CREATE VIEW grouper_attr_asn_member_v (source_id, subject_id, action, attribute_def_name_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, attribute_assign_delegatable, enabled, enabled_time, disabled_time, member_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id) AS select gm.subject_source as source_id, gm.subject_id, gaaa.name as action, gadn.name as attribute_def_name_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gm.id as member_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id from grouper_attribute_assign gaa, grouper_members gm, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa where gaa.owner_member_id = gm.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.owner_group_id is null  and gaa.attribute_assign_action_id = gaaa.id;

COMMENT ON VIEW grouper_attr_asn_member_v IS 'grouper_attr_asn_member_v: attribute assigned to a member and related cols';

COMMENT ON COLUMN grouper_attr_asn_member_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_member_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_member_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_member_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_attr_asn_member_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_member_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_member_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_member_v.member_id IS 'member_id: member id of the member assigned the attribute (this is an internal grouper uuid)';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_member_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_asn_member_v.action_id IS 'action_id: id of the attribute assign action';

CREATE VIEW grouper_attr_asn_mship_v (group_name, source_id, subject_id, action, attribute_def_name_name, attribute_def_name_disp_name, list_name, name_of_attribute_def, attribute_assign_notes, attribute_assign_delegatable, enabled, enabled_time, disabled_time, group_id, membership_id, member_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id) AS select gg.name as group_name, gm.subject_source as source_id, gm.subject_id, gaaa.name as action, gadn.name as attribute_def_name_name, gadn.display_name as attribute_def_name_disp_name, gf.name as list_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gg.id as group_id, gms.id as membership_id, gm.id as member_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id from grouper_attribute_assign gaa, grouper_groups gg, grouper_memberships gms, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_members gm, grouper_fields gf, grouper_attr_assign_action gaaa  where gaa.owner_membership_id = gms.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id  and gms.field_id = gf.id and gms.member_id = gm.id and gms.owner_group_id = gg.id  and gf.type = 'list' and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_attr_asn_mship_v IS 'grouper_attr_asn_mship_v: attribute assigned to an immediate memberships, and related cols';

COMMENT ON COLUMN grouper_attr_asn_mship_v.group_name IS 'group_name: name of group in membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_mship_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_mship_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_mship_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_mship_v.list_name IS 'list_name: name of list in membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_mship_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_attr_asn_mship_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_mship_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_mship_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_mship_v.group_id IS 'group_id: group id of the membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_mship_v.membership_id IS 'membership_id: membership id assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_mship_v.member_id IS 'member_id: internal grouper member uuid of the membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_mship_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_asn_mship_v.action_id IS 'action_id: id of the attribute assign action';

CREATE VIEW grouper_attr_asn_attrdef_v (name_of_attr_def_assigned_to, action, attribute_def_name_name, attribute_def_name_disp_name, name_of_attribute_def_assigned, attribute_assign_notes, enabled, enabled_time, disabled_time, id_of_attr_def_assigned_to, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id) AS select gad_assigned_to.name as name_of_attr_def_assigned_to, gaaa.name as action, gadn.name as attribute_def_name_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gad_assigned_to.id as id_of_attr_def_assigned_to, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id from grouper_attribute_assign gaa, grouper_attribute_def gad_assigned_to, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa  where gaa.owner_attribute_def_id = gad_assigned_to.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_attr_asn_attrdef_v IS 'grouper_attr_asn_attrdef_v: attribute assigned to an attribute definition, and related columns';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.name_of_attr_def_assigned_to IS 'name_of_attr_def_assigned_to: name of attribute def assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.name_of_attribute_def_assigned IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.id_of_attr_def_assigned_to IS 'id_of_attr_def_assigned_to: attrDef id of the attributeDef assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_asn_attrdef_v.action_id IS 'action_id: id of the attribute assign action';

CREATE VIEW grouper_attr_asn_asn_group_v (group_name, action1, action2, attribute_def_name_name1, attribute_def_name_name2, group_display_name, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, group_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2) AS select gg.name as group_name, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2, gg.display_name as group_display_name, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gg.id as group_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2 from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_groups gg, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2   where gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gg.id = gaa1.owner_group_id and gaa1.owner_member_id is null and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id;

COMMENT ON VIEW grouper_attr_asn_asn_group_v IS 'grouper_attr_asn_asn_group_v: attribute assigned to an assignment of attribute to a group, and related cols';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.group_name IS 'group_name: name of group assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.group_display_name IS 'group_display_name: display name of the group assigned an attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.group_id IS 'group_id: group id of the group assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_group_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

CREATE VIEW grouper_attr_asn_asn_efmship_v (group_name, source_id, subject_id, action1, action2, attribute_def_name_name1, attribute_def_name_name2, attribute_def_name_disp_name1, attribute_def_name_disp_name2, list_name, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, group_id, member_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2) AS select distinct gg.name as group_name, gm.subject_source as source_id, gm.subject_id, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gf.name as list_name, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gg.id as group_id, gm.id as member_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2 from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_groups gg, grouper_memberships_all_v gmav, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_members gm, grouper_fields gf, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2 where gaa1.owner_member_id = gmav.member_id and gaa1.owner_group_id = gmav.owner_group_id and gaa2.owner_attribute_assign_id = gaa1.id  and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gmav.immediate_mship_enabled = 'T' and gmav.field_id = gf.id and gmav.member_id = gm.id and gmav.owner_group_id = gg.id and gf.type = 'list' and gaa1.owner_member_id is not null  and gaa1.owner_group_id is not null and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_attr_asn_asn_efmship_v IS 'grouper_attr_asn_asn_efmship_v: attribute assigned to an assignment of an attribute to an effective membership, and related cols';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.group_name IS 'group_name: name of group in membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the new attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the original attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the new attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.list_name IS 'list_name: name of list in membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the original attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the new attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.group_id IS 'group_id: group id of the membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.member_id IS 'member_id: internal grouper member uuid of the membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_efmship_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

CREATE VIEW grouper_attr_asn_asn_stem_v (stem_name, action1, action2, attribute_def_name_name1, attribute_def_name_name2, stem_display_name, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, stem_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2) AS select gs.name as stem_name, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2, gs.display_name as stem_display_name, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gs.id as stem_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2 from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_stems gs, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2 where gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gs.id = gaa1.owner_stem_id and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_attr_asn_asn_stem_v IS 'grouper_attr_asn_asn_stem_v: attribute assigned to an assignment of attribute to a stem, and related cols';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.stem_name IS 'stem_name: name of stem assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.stem_display_name IS 'stem_display_name: display name of the stem assigned an attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.stem_id IS 'stem_id: stem id of the stem assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_stem_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

CREATE VIEW grouper_attr_asn_asn_member_v (source_id, subject_id, action1, action2, attribute_def_name_name1, attribute_def_name_name2, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, member_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2) AS select gm.subject_source as source_id, gm.subject_id, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gm.id as member_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2 from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_members gm, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2 where gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gm.id = gaa1.owner_member_id and gaa1.owner_group_id is null and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_attr_asn_asn_member_v IS 'grouper_attr_asn_asn_member_v: attribute assigned to an assignment of an attribute to a member, and related cols';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.source_id IS 'source_id: source id of the member assigned the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.subject_id IS 'subject_id: subject id of the member assigned the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.member_id IS 'member_id: member id of the member assigned the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_member_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

CREATE VIEW grouper_attr_asn_asn_mship_v (group_name, source_id, subject_id, action1, action2, attribute_def_name_name1, attribute_def_name_name2, attribute_def_name_disp_name1, attribute_def_name_disp_name2, list_name, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, group_id, membership_id, member_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2) AS select gg.name as group_name, gm.subject_source as source_id, gm.subject_id, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gf.name as list_name, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gg.id as group_id, gms.id as membership_id, gm.id as member_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2 from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_groups gg, grouper_memberships gms, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_members gm, grouper_fields gf, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2 where gaa1.owner_membership_id = gms.id and gaa2.owner_attribute_assign_id = gaa1.id  and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T'  and gms.field_id = gf.id and gms.member_id = gm.id and gms.owner_group_id = gg.id and gf.type = 'list' and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_attr_asn_asn_mship_v IS 'grouper_attr_asn_asn_mship_v: attribute assigned to an assignment of an attribute to a membership, and related cols';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.group_name IS 'group_name: name of group in membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the new attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the original attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the new attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.list_name IS 'list_name: name of list in membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the original attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the new attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.group_id IS 'group_id: group id of the membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.membership_id IS 'membership_id: membership id assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.member_id IS 'member_id: internal grouper member uuid of the membership assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_mship_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

CREATE VIEW grouper_attr_asn_asn_attrdef_v (name_of_attr_def_assigned_to, action1, action2, attribute_def_name_name1, attribute_def_name_name2, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, id_of_attr_def_assigned_to, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2) AS select gad.name as name_of_attr_def_assigned_to, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gad.id as id_of_attr_def_assigned_to, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2 from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_attribute_def gad, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2 , grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2 where gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gad.id = gaa1.owner_attribute_def_id and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_attr_asn_asn_attrdef_v IS 'grouper_attr_asn_asn_attrdef_v: attribute assigned to an assignment of an attribute to an attribute definition, and related cols';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.name_of_attr_def_assigned_to IS 'name_of_attr_def_assigned_to: name of attribute_def originally assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.id_of_attr_def_assigned_to IS 'id_of_attr_def_assigned_to: id of the attribute def assigned the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_attr_asn_asn_attrdef_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

CREATE VIEW grouper_aval_asn_group_v (group_name, action, attribute_def_name_name, value_string, value_integer, value_floating, value_member_id, group_display_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, attribute_assign_delegatable, enabled, enabled_time, disabled_time, group_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id, attribute_assign_value_id) AS select gg.name as group_name, gaaa.name as action, gadn.name as attribute_def_name_name,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gg.display_name as group_display_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gg.id as group_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa, grouper_groups gg, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa, grouper_attribute_assign_value gaav   where gaav.attribute_assign_id = gaa.id  and gaa.owner_group_id = gg.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.owner_member_id is null and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_aval_asn_group_v IS 'grouper_aval_asn_group_v: attribute assigned to a group with related columns and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_group_v.group_name IS 'group_name: name of group assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_group_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_group_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_group_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_group_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_group_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_group_v.group_display_name IS 'group_display_name: display name of the group assigned an attribute';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_group_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_aval_asn_group_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_group_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_group_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_group_v.group_id IS 'group_id: group id of the group assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_aval_asn_group_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_aval_asn_group_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_efmship_v (group_name, subject_source_id, subject_id, action, attribute_def_name_name, value_string, value_integer, value_floating, value_member_id, group_display_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, list_name, attribute_assign_delegatable, enabled, enabled_time, disabled_time, group_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, member_id, action_id, attribute_assign_value_id) AS select distinct gg.name as group_name, gm.subject_source as subject_source_id, gm.subject_id, gaaa.name as action, gadn.name as attribute_def_name_name,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gg.display_name as group_display_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gf.name as list_name, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gg.id as group_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gm.id as member_id, gaaa.id as action_id,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa, grouper_memberships_all_v gmav, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_groups gg, grouper_fields gf, grouper_members gm, grouper_attr_assign_action gaaa, grouper_attribute_assign_value gaav  where gaav.attribute_assign_id = gaa.id  and gaa.owner_group_id = gmav.owner_group_id and gaa.owner_member_id = gmav.member_id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gmav.immediate_mship_enabled = 'T' and gmav.owner_group_id = gg.id and gmav.field_id = gf.id and gf.type = 'list' and gmav.member_id = gm.id and gaa.owner_member_id is not null and gaa.owner_group_id is null and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_aval_asn_efmship_v IS 'grouper_aval_asn_efmship_v: attribute assigned to an effective membership and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.group_name IS 'group_name: name of group assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.subject_source_id IS 'subject_source_id: source id of the subject being assigned';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.subject_id IS 'subject_id: subject id of the subject being assigned';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.group_display_name IS 'group_display_name: display name of the group assigned an attribute';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.list_name IS 'list_name: name of the membership list for this effective membership';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.group_id IS 'group_id: group id of the group assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.member_id IS 'member_id: id of the member assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.action_id IS 'action_id: attribute assign action id';

COMMENT ON COLUMN grouper_aval_asn_efmship_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_stem_v (stem_name, action, attribute_def_name_name, value_string, value_integer, value_floating, value_member_id, stem_display_name, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, enabled, enabled_time, disabled_time, stem_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id, attribute_assign_value_id) AS select gs.name as stem_name, gaaa.name as action, gadn.name as attribute_def_name_name,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gs.display_name as stem_display_name, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gs.id as stem_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa, grouper_stems gs, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa, grouper_attribute_assign_value gaav  where gaav.attribute_assign_id = gaa.id  and gaa.owner_stem_id = gs.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_aval_asn_stem_v IS 'grouper_aval_asn_stem_v: attribute assigned to a stem and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_stem_v.stem_name IS 'stem_name: name of stem assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_stem_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_stem_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_stem_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_stem_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_stem_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_stem_v.stem_display_name IS 'stem_display_name: display name of the stem assigned an attribute';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_stem_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_stem_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_stem_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_stem_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_stem_v.stem_id IS 'stem_id: stem id of the stem assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_aval_asn_stem_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_aval_asn_stem_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_member_v (source_id, subject_id, action, attribute_def_name_name, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name, name_of_attribute_def, attribute_assign_notes, attribute_assign_delegatable, enabled, enabled_time, disabled_time, member_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id, attribute_assign_value_id) AS select gm.subject_source as source_id, gm.subject_id, gaaa.name as action, gadn.name as attribute_def_name_name,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gm.id as member_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa, grouper_members gm, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa, grouper_attribute_assign_value gaav where gaav.attribute_assign_id = gaa.id  and gaa.owner_member_id = gm.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.owner_group_id is null  and gaa.attribute_assign_action_id = gaaa.id;

COMMENT ON VIEW grouper_aval_asn_member_v IS 'grouper_aval_asn_member_v: attribute assigned to a member and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_member_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_member_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_member_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_member_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_member_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_member_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_member_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_member_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_aval_asn_member_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_member_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_member_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_member_v.member_id IS 'member_id: member id of the member assigned the attribute (this is an internal grouper uuid)';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_aval_asn_member_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_aval_asn_member_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_mship_v (group_name, source_id, subject_id, action, attribute_def_name_name, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name, list_name, name_of_attribute_def, attribute_assign_notes, attribute_assign_delegatable, enabled, enabled_time, disabled_time, group_id, membership_id, member_id, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id, attribute_assign_value_id) AS select gg.name as group_name, gm.subject_source as source_id, gm.subject_id, gaaa.name as action, gadn.name as attribute_def_name_name,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn.display_name as attribute_def_name_disp_name, gf.name as list_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gg.id as group_id, gms.id as membership_id, gm.id as member_id, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa, grouper_groups gg, grouper_memberships gms, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_members gm, grouper_fields gf, grouper_attr_assign_action gaaa, grouper_attribute_assign_value gaav  where gaav.attribute_assign_id = gaa.id  and gaa.owner_membership_id = gms.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id  and gms.field_id = gf.id and gms.member_id = gm.id and gms.owner_group_id = gg.id  and gf.type = 'list' and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_aval_asn_mship_v IS 'grouper_aval_asn_mship_v: attribute assigned to an immediate memberships, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_mship_v.group_name IS 'group_name: name of group in membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_mship_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_mship_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_mship_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_mship_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_mship_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_mship_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_mship_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_mship_v.list_name IS 'list_name: name of list in membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_mship_v.name_of_attribute_def IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_aval_asn_mship_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_mship_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_mship_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_mship_v.group_id IS 'group_id: group id of the membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_mship_v.membership_id IS 'membership_id: membership id assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_mship_v.member_id IS 'member_id: internal grouper member uuid of the membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_aval_asn_mship_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_aval_asn_mship_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_attrdef_v (name_of_attr_def_assigned_to, action, attribute_def_name_name, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name, name_of_attribute_def_assigned, attribute_assign_notes, enabled, enabled_time, disabled_time, id_of_attr_def_assigned_to, attribute_assign_id, attribute_def_name_id, attribute_def_id, action_id, attribute_assign_value_id) AS select gad_assigned_to.name as name_of_attr_def_assigned_to, gaaa.name as action, gadn.name as attribute_def_name_name,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn.display_name as attribute_def_name_disp_name, gad.name as name_of_attribute_def, gaa.notes as attribute_assign_notes, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gad_assigned_to.id as id_of_attr_def_assigned_to, gaa.id as attribute_assign_id, gadn.id as attribute_def_name_id, gad.id as attribute_def_id, gaaa.id as action_id,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa, grouper_attribute_def gad_assigned_to, grouper_attribute_def_name gadn, grouper_attribute_def gad, grouper_attr_assign_action gaaa, grouper_attribute_assign_value gaav  where gaav.attribute_assign_id = gaa.id  and gaa.owner_attribute_def_id = gad_assigned_to.id and gaa.attribute_def_name_id = gadn.id and gadn.attribute_def_id = gad.id and gaa.attribute_assign_action_id = gaaa.id ;

COMMENT ON VIEW grouper_aval_asn_attrdef_v IS 'grouper_aval_asn_attrdef_v: attribute assigned to an attribute definition, and related columns and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.name_of_attr_def_assigned_to IS 'name_of_attr_def_assigned_to: name of attribute def assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.name_of_attribute_def_assigned IS 'name_of_attribute_def: name of the attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_assign_notes IS 'attribute_assign_notes: notes related to the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.id_of_attr_def_assigned_to IS 'id_of_attr_def_assigned_to: attrDef id of the attributeDef assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_aval_asn_attrdef_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_asn_group_v (group_name, action1, action2, attribute_def_name_name1, attribute_def_name_name2, value_string, value_integer, value_floating, value_member_id, group_display_name, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, group_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2, attribute_assign_value_id) AS select gg.name as group_name, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gg.display_name as group_display_name, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gg.id as group_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_groups gg, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2, grouper_attribute_assign_value gaav   where gaav.attribute_assign_id = gaa2.id  and gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gg.id = gaa1.owner_group_id and gaa1.owner_member_id is null and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id;

COMMENT ON VIEW grouper_aval_asn_asn_group_v IS 'grouper_aval_asn_asn_group_v: attribute assigned to an assignment of attribute to a group, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.group_name IS 'group_name: name of group assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.group_display_name IS 'group_display_name: display name of the group assigned an attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.group_id IS 'group_id: group id of the group assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_group_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_asn_efmship_v (group_name, source_id, subject_id, action1, action2, attribute_def_name_name1, attribute_def_name_name2, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name1, attribute_def_name_disp_name2, list_name, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, group_id, member_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2, attribute_assign_value_id) AS select distinct gg.name as group_name, gm.subject_source as source_id, gm.subject_id, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gf.name as list_name, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gg.id as group_id, gm.id as member_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_groups gg, grouper_memberships_all_v gmav, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_members gm, grouper_fields gf, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2, grouper_attribute_assign_value gaav where gaav.attribute_assign_id = gaa2.id  and gaa1.owner_member_id = gmav.member_id and gaa1.owner_group_id = gmav.owner_group_id and gaa2.owner_attribute_assign_id = gaa1.id  and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gmav.immediate_mship_enabled = 'T' and gmav.field_id = gf.id and gmav.member_id = gm.id and gmav.owner_group_id = gg.id and gf.type = 'list' and gaa1.owner_member_id is not null  and gaa1.owner_group_id is not null and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_aval_asn_asn_efmship_v IS 'grouper_aval_asn_asn_efmship_v: attribute assigned to an assignment of an attribute to an effective membership, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.group_name IS 'group_name: name of group in membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the new attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the original attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the new attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.list_name IS 'list_name: name of list in membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the original attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the new attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.group_id IS 'group_id: group id of the membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.member_id IS 'member_id: internal grouper member uuid of the membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_efmship_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_asn_stem_v (stem_name, action1, action2, attribute_def_name_name1, attribute_def_name_name2, value_string, value_integer, value_floating, value_member_id, stem_display_name, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, stem_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2, attribute_assign_value_id) AS select gs.name as stem_name, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gs.display_name as stem_display_name, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gs.id as stem_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_stems gs, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2, grouper_attribute_assign_value gaav where gaav.attribute_assign_id = gaa2.id  and gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gs.id = gaa1.owner_stem_id and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_aval_asn_asn_stem_v IS 'grouper_aval_asn_asn_stem_v: attribute assigned to an assignment of attribute to a stem, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.stem_name IS 'stem_name: name of stem assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.stem_display_name IS 'stem_display_name: display name of the stem assigned an attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.stem_id IS 'stem_id: stem id of the stem assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_stem_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_asn_member_v (source_id, subject_id, action1, action2, attribute_def_name_name1, attribute_def_name_name2, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, member_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2, attribute_assign_value_id) AS select gm.subject_source as source_id, gm.subject_id, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gm.id as member_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_members gm, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2, grouper_attribute_assign_value gaav where gaav.attribute_assign_id = gaa2.id  and gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gm.id = gaa1.owner_member_id and gaa1.owner_group_id is null and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_aval_asn_asn_member_v IS 'grouper_aval_asn_asn_member_v: attribute assigned to an assignment of an attribute to a member, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.source_id IS 'source_id: source id of the member assigned the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.subject_id IS 'subject_id: subject id of the member assigned the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.member_id IS 'member_id: member id of the member assigned the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_member_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_asn_mship_v (group_name, source_id, subject_id, action1, action2, attribute_def_name_name1, attribute_def_name_name2, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name1, attribute_def_name_disp_name2, list_name, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, group_id, membership_id, member_id, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2, attribute_assign_value_id) AS select gg.name as group_name, gm.subject_source as source_id, gm.subject_id, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gf.name as list_name, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gg.id as group_id, gms.id as membership_id, gm.id as member_id, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_groups gg, grouper_memberships gms, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_members gm, grouper_fields gf, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2, grouper_attribute_assign_value gaav where gaav.attribute_assign_id = gaa2.id  and gaa1.owner_membership_id = gms.id and gaa2.owner_attribute_assign_id = gaa1.id  and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T'  and gms.field_id = gf.id and gms.member_id = gm.id and gms.owner_group_id = gg.id and gf.type = 'list' and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_aval_asn_asn_mship_v IS 'grouper_aval_asn_asn_mship_v: attribute assigned to an assignment of an attribute to a membership, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.group_name IS 'group_name: name of group in membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.source_id IS 'source_id: source of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.subject_id IS 'subject_id: subject_id of the subject that belongs to the member';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the new attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the original attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the new attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.list_name IS 'list_name: name of list in membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the original attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the new attribute definition associated with the attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.group_id IS 'group_id: group id of the membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.membership_id IS 'membership_id: membership id assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.member_id IS 'member_id: internal grouper member uuid of the membership assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_mship_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_aval_asn_asn_attrdef_v (name_of_attr_def_assigned_to, action1, action2, attribute_def_name_name1, attribute_def_name_name2, value_string, value_integer, value_floating, value_member_id, attribute_def_name_disp_name1, attribute_def_name_disp_name2, name_of_attribute_def1, name_of_attribute_def2, attribute_assign_notes1, attribute_assign_notes2, enabled2, enabled_time2, disabled_time2, id_of_attr_def_assigned_to, attribute_assign_id1, attribute_assign_id2, attribute_def_name_id1, attribute_def_name_id2, attribute_def_id1, attribute_def_id2, action_id1, action_id2, attribute_assign_value_id) AS select gad.name as name_of_attr_def_assigned_to, gaaa1.name as action1, gaaa2.name as action2,  gadn1.name as attribute_def_name_name1, gadn2.name as attribute_def_name_name2,  gaav.value_string AS value_string,  gaav.value_integer AS value_integer,  gaav.value_floating AS value_floating,  gaav.value_member_id AS value_member_id, gadn1.display_name as attribute_def_name_disp_name1, gadn2.display_name as attribute_def_name_disp_name2, gad1.name as name_of_attribute_def1, gad2.name as name_of_attribute_def2, gaa1.notes as attribute_assign_notes1, gaa2.notes as attribute_assign_notes2, gaa2.enabled as enabled2, gaa2.enabled_time as enabled_time2, gaa2.disabled_time as disabled_time2, gad.id as id_of_attr_def_assigned_to, gaa1.id as attribute_assign_id1, gaa2.id as attribute_assign_id2, gadn1.id as attribute_def_name_id1, gadn2.id as attribute_def_name_id2, gad1.id as attribute_def_id1, gad2.id as attribute_def_id2, gaaa1.id as action_id1, gaaa2.id as action_id2,  gaav.id AS attribute_assign_value_id from grouper_attribute_assign gaa1, grouper_attribute_assign gaa2, grouper_attribute_def gad, grouper_attribute_def_name gadn1, grouper_attribute_def_name gadn2, grouper_attribute_def gad1, grouper_attribute_def gad2, grouper_attr_assign_action gaaa1, grouper_attr_assign_action gaaa2, grouper_attribute_assign_value gaav where gaav.attribute_assign_id = gaa2.id  and gaa1.id = gaa2.owner_attribute_assign_id and gaa1.attribute_def_name_id = gadn1.id and gaa2.attribute_def_name_id = gadn2.id and gadn1.attribute_def_id = gad1.id and gadn2.attribute_def_id = gad2.id and gaa1.enabled = 'T' and gad.id = gaa1.owner_attribute_def_id and gaa1.attribute_assign_action_id = gaaa1.id and gaa2.attribute_assign_action_id = gaaa2.id ;

COMMENT ON VIEW grouper_aval_asn_asn_attrdef_v IS 'grouper_aval_asn_asn_attrdef_v: attribute assigned to an assignment of an attribute to an attribute definition, and related cols and values (multiple rows if multiple values, no rows if no values)';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.name_of_attr_def_assigned_to IS 'name_of_attr_def_assigned_to: name of attribute_def originally assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.action1 IS 'action1: the action associated with the original attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.action2 IS 'action2: the action associated with this attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_name_name1 IS 'attribute_def_name_name1: name of the original attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_name_name2 IS 'attribute_def_name_name2: name of the current attribute definition name which is assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.value_string IS 'value_string: if this is a string attributeDef, then this is the string';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.value_integer IS 'value_integer: if this is an integer attributeDef, then this is the integer';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.value_floating IS 'value_floating: if this is a floating attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.value_member_id IS 'value_member_id: if this is a memberId attributeDef, then this is the value';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_name_disp_name1 IS 'attribute_def_name_disp_name1: display name of the attribute definition name assigned to the original attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_name_disp_name2 IS 'attribute_def_name_disp_name2: display name of the attribute definition name assigned to the new attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.name_of_attribute_def1 IS 'name_of_attribute_def1: name of the attribute definition associated with the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.name_of_attribute_def2 IS 'name_of_attribute_def2: name of the attribute definition associated with the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_assign_notes1 IS 'attribute_assign_notes1: notes related to the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_assign_notes2 IS 'attribute_assign_notes2: notes related to the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.enabled2 IS 'enabled2: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.enabled_time2 IS 'enabled_time2: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.disabled_time2 IS 'disabled_time2: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.id_of_attr_def_assigned_to IS 'id_of_attr_def_assigned_to: id of the attribute def assigned the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_assign_id1 IS 'attribute_assign_id1: id of the original attribute assignment to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_assign_id2 IS 'attribute_assign_id2: id of the new attribute assignment to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_name_id1 IS 'attribute_def_name_id1: id of the original attribute definition name assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_name_id2 IS 'attribute_def_name_id2: id of the new attribute definition name assigned to the assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_id1 IS 'attribute_def_id1: id of the original attribute definition assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_def_id2 IS 'attribute_def_id2: id of the new attribute definition assigned to the attribute';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.action_id1 IS 'action_id1: id of the attribute assign action of the original assignment';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.action_id2 IS 'action_id2: id of the attribute assign action assigned to the group';

COMMENT ON COLUMN grouper_aval_asn_asn_attrdef_v.attribute_assign_value_id IS 'attribute_assign_value_id: the id of the value';

CREATE VIEW grouper_attr_def_priv_v (subject_id, subject_source_id, field_name, attribute_def_name, attribute_def_description, attribute_def_type, attribute_def_stem_id, attribute_def_id, member_id, field_id, immediate_membership_id, membership_id) AS select distinct gm.subject_id, gm.subject_source as subject_source_id,  gf.name as field_name, gad.name as attribute_def_name, gad.description as attribute_def_description,  gad.attribute_def_type, gad.stem_id as attribute_def_stem_id, gad.id as attribute_def_id,  gm.id as member_id, gmav.field_id, gmav.immediate_membership_id, gmav.membership_id  from grouper_memberships_all_v gmav, grouper_attribute_def gad, grouper_fields gf, grouper_members gm where gmav.owner_attr_def_id = gad.id and gmav.field_id = gf.id and gmav.immediate_mship_enabled = 'T' and gmav.member_id = gm.id ;

COMMENT ON VIEW grouper_attr_def_priv_v IS 'grouper_attr_def_priv_v: shows all privileges internal to grouper of attribute defs';

COMMENT ON COLUMN grouper_attr_def_priv_v.subject_id IS 'subject_id: of who has the priv';

COMMENT ON COLUMN grouper_attr_def_priv_v.subject_source_id IS 'subject_source_id: source id of the subject with the priv';

COMMENT ON COLUMN grouper_attr_def_priv_v.field_name IS 'field_name: field name of priv, e.g. attrView, attrRead, attrAdmin, attrUpdate, attrOptin, attrOptout';

COMMENT ON COLUMN grouper_attr_def_priv_v.attribute_def_name IS 'attribute_def_name: name of attribute definition';

COMMENT ON COLUMN grouper_attr_def_priv_v.attribute_def_description IS 'attribute_def_description: description of the attribute def';

COMMENT ON COLUMN grouper_attr_def_priv_v.attribute_def_type IS 'attribute_def_type: type of attribute, e.g. attribute, privilege, domain';

COMMENT ON COLUMN grouper_attr_def_priv_v.attribute_def_stem_id IS 'attribute_def_stem_id: id of stem the attribute def is in';

COMMENT ON COLUMN grouper_attr_def_priv_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_attr_def_priv_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_attr_def_priv_v.field_id IS 'field_id: id of the field of membership';

COMMENT ON COLUMN grouper_attr_def_priv_v.immediate_membership_id IS 'immediate_membership_id: id of the membership in the memberships table';

COMMENT ON COLUMN grouper_attr_def_priv_v.membership_id IS 'membership_id: id of the membership in the membership all view';

CREATE VIEW grouper_perms_assigned_role_v (role_name, action, attribute_def_name_name, attribute_def_name_disp_name, role_display_name, attribute_assign_delegatable, enabled, enabled_time, disabled_time, role_id, attribute_def_id, attribute_def_name_id, action_id, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, attribute_assign_id, assignment_notes, disallowed, permission_type) AS SELECT distinct gr.name AS role_name,      gaaa.name AS action,     gadn.name AS attribute_def_name_name,     gadn.display_name AS attribute_def_name_disp_name,     gr.display_name AS role_display_name,     gaa.attribute_assign_delegatable,      gaa.enabled,     gaa.enabled_time,      gaa.disabled_time,      gr.ID AS role_id,     gadn.attribute_def_id,     gadn.ID AS attribute_def_name_id,      gaaa.ID AS action_id,     grs.DEPTH AS role_set_depth,     gadns.DEPTH AS attr_def_name_set_depth,     gaaas.DEPTH AS attr_assign_action_set_depth,     gaa.ID AS attribute_assign_id,     gaa.notes AS assignment_notes,     gaa.disallowed,     'role' AS permission_type FROM grouper_groups gr,     grouper_role_set grs,     grouper_attribute_def gad,     grouper_attribute_assign gaa,     grouper_attribute_def_name gadn,     grouper_attribute_def_name_set gadns,     grouper_attr_assign_action gaaa,     grouper_attr_assign_action_set gaaas WHERE grs.if_has_role_id = gr.id and gr.type_of_group = 'role'  AND gadn.attribute_def_id = gad.id AND gad.attribute_def_type = 'perm' AND gaa.owner_group_id = grs.then_has_role_id AND gaa.attribute_def_name_id = gadns.if_has_attribute_def_name_id AND gadn.id = gadns.then_has_attribute_def_name_id AND gaa.attribute_assign_type = 'group' AND gaa.attribute_assign_action_id = gaaas.if_has_attr_assn_action_id AND gaaa.id = gaaas.then_has_attr_assn_action_id ;

COMMENT ON VIEW grouper_perms_assigned_role_v IS 'grouper_perms_assigned_role_v: shows all permissions assigned to roles';

COMMENT ON COLUMN grouper_perms_assigned_role_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_perms_assigned_role_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_perms_assigned_role_v.role_display_name IS 'role_display_name: display name of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_perms_assigned_role_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_perms_assigned_role_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_perms_assigned_role_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_perms_assigned_role_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_perms_assigned_role_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_perms_assigned_role_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_assigned_role_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_perms_assigned_role_v.assignment_notes IS 'assignment_notes: notes on this assignment';

COMMENT ON COLUMN grouper_perms_assigned_role_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

COMMENT ON COLUMN grouper_perms_assigned_role_v.permission_type IS 'permission_type: role since these are role assignments';

CREATE VIEW grouper_perms_role_v (role_name, subject_source_id, subject_id, action, attribute_def_name_name, attribute_def_name_disp_name, role_display_name, attribute_assign_delegatable, enabled, enabled_time, disabled_time, role_id, attribute_def_id, member_id, attribute_def_name_id, action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, attribute_assign_id, permission_type, assignment_notes, immediate_mship_enabled_time, immediate_mship_disabled_time, disallowed) AS select distinct gr.name as role_name,  gm.subject_source as subject_source_id,  gm.subject_id,  gaaa.name as action, gadn.name as attribute_def_name_name,  gadn.display_name as attribute_def_name_disp_name,  gr.display_name as role_display_name,  gaa.attribute_assign_delegatable, gaa.enabled, gaa.enabled_time, gaa.disabled_time, gr.id as role_id,  gadn.attribute_def_id,  gm.id as member_id,  gadn.id as attribute_def_name_id,  gaaa.id as action_id, gmav.depth AS membership_depth, grs.depth AS role_set_depth, gadns.depth AS attr_def_name_set_depth, gaaas.depth AS attr_assign_action_set_depth, gmav.membership_id as membership_id, gaa.id AS attribute_assign_id, 'role' as permission_type, gaa.notes as assignment_notes, gmav.immediate_mship_enabled_time, gmav.immediate_mship_disabled_time, gaa.disallowed from grouper_groups gr,  grouper_memberships_all_v gmav,  grouper_members gm,  grouper_fields gf,  grouper_role_set grs,  grouper_attribute_def gad,  grouper_attribute_assign gaa,  grouper_attribute_def_name gadn,  grouper_attribute_def_name_set gadns, grouper_attr_assign_action gaaa, grouper_attr_assign_action_set gaaas where gmav.owner_group_id = gr.id  and gmav.field_id = gf.id  and gr.type_of_group = 'role' and gf.type = 'list'  and gf.name = 'members'  and gmav.immediate_mship_enabled = 'T'  and gmav.member_id = gm.id  and grs.if_has_role_id = gr.id  and gadn.attribute_def_id = gad.id  and gad.attribute_def_type = 'perm'  and gaa.owner_group_id = grs.then_has_role_id  and gaa.attribute_def_name_id = gadns.if_has_attribute_def_name_id  and gadn.id = gadns.then_has_attribute_def_name_id  and gaa.attribute_assign_type = 'group' and gaa.attribute_assign_action_id = gaaas.if_has_attr_assn_action_id and gaaa.id = gaaas.then_has_attr_assn_action_id ;

COMMENT ON VIEW grouper_perms_role_v IS 'grouper_perms_role_v: shows all permissions assigned to users due to the users being in a role, and the role being assigned the permission';

COMMENT ON COLUMN grouper_perms_role_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_perms_role_v.subject_source_id IS 'subject_source_id: source id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_perms_role_v.subject_id IS 'subject_id: subject id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_perms_role_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_perms_role_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_perms_role_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_perms_role_v.role_display_name IS 'role_display_name: display name of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_role_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_perms_role_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_perms_role_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_perms_role_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_perms_role_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_role_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_perms_role_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_perms_role_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_perms_role_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_perms_role_v.membership_depth IS 'membership_depth: depth of membership, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_v.membership_id IS 'membership_id: id of the underlying membership';

COMMENT ON COLUMN grouper_perms_role_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_perms_role_v.permission_type IS 'permission_type: role or role_subject for assignment to role or to role subject pair';

COMMENT ON COLUMN grouper_perms_role_v.assignment_notes IS 'assignment_notes: notes on this assignment';

COMMENT ON COLUMN grouper_perms_role_v.immediate_mship_enabled_time IS 'immediate_mship_enabled_time: time this membership was enabled';

COMMENT ON COLUMN grouper_perms_role_v.immediate_mship_disabled_time IS 'immediate_mship_disabled_time: time this membership will be disabled';

COMMENT ON COLUMN grouper_perms_role_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

CREATE VIEW grouper_perms_role_subject_v (role_name, subject_source_id, subject_id, action, attribute_def_name_name, attribute_def_name_disp_name, role_display_name, attribute_assign_delegatable, enabled, enabled_time, disabled_time, role_id, attribute_def_id, member_id, attribute_def_name_id, action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, attribute_assign_id, permission_type, assignment_notes, immediate_mship_enabled_time, immediate_mship_disabled_time, disallowed) AS SELECT DISTINCT gr.name AS role_name,   gm.subject_source AS subject_source_id,   gm.subject_id,   gaaa.name AS ACTION,  gadn.name AS attribute_def_name_name,   gadn.display_name AS attribute_def_name_disp_name,   gr.display_name AS role_display_name,   gaa.attribute_assign_delegatable,  gaa.enabled,  gaa.enabled_time,  gaa.disabled_time,  gr.id AS role_id,   gadn.attribute_def_id,   gm.id AS member_id,   gadn.id AS attribute_def_name_id,   gaaa.id AS action_id, gmav.depth AS membership_depth, -1 AS role_set_depth, gadns.depth AS attr_def_name_set_depth, gaaas.depth AS attr_assign_action_set_depth, gmav.membership_id as membership_id, gaa.id as attribute_assign_id, 'role_subject' as permission_type, gaa.notes as assignment_notes, gmav.immediate_mship_enabled_time, gmav.immediate_mship_disabled_time, gaa.disallowed FROM grouper_groups gr,   grouper_memberships_all_v gmav,   grouper_members gm,   grouper_fields gf,   grouper_attribute_def gad,  grouper_attribute_assign gaa,   grouper_attribute_def_name gadn,   grouper_attribute_def_name_set gadns,   grouper_attr_assign_action gaaa,  grouper_attr_assign_action_set gaaas  WHERE gmav.owner_group_id = gr.id  and gr.type_of_group = 'role' and gmav.field_id = gf.id  and gmav.owner_group_id = gaa.owner_group_id  AND gmav.member_id = gaa.owner_member_id   AND gf.type = 'list'   AND gf.name = 'members'   AND gmav.immediate_mship_enabled = 'T'   AND gmav.member_id = gm.id   AND gadn.attribute_def_id = gad.id  AND gad.attribute_def_type = 'perm'  AND gaa.attribute_assign_type = 'any_mem'  AND gaa.attribute_def_name_id = gadns.if_has_attribute_def_name_id   AND gadn.id = gadns.then_has_attribute_def_name_id  AND gaa.attribute_assign_action_id = gaaas.if_has_attr_assn_action_id  AND gaaa.id = gaaas.then_has_attr_assn_action_id  ;

COMMENT ON VIEW grouper_perms_role_subject_v IS 'grouper_perms_role_subject_v: shows all permissions assigned to users directly while in a role';

COMMENT ON COLUMN grouper_perms_role_subject_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_perms_role_subject_v.subject_source_id IS 'subject_source_id: source id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_perms_role_subject_v.subject_id IS 'subject_id: subject id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_perms_role_subject_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_perms_role_subject_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_perms_role_subject_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_perms_role_subject_v.role_display_name IS 'role_display_name: display name of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_role_subject_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_perms_role_subject_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_perms_role_subject_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_perms_role_subject_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_perms_role_subject_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_role_subject_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_perms_role_subject_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_perms_role_subject_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_perms_role_subject_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_perms_role_subject_v.membership_depth IS 'membership_depth: depth of membership, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_subject_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_subject_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_subject_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_role_subject_v.membership_id IS 'membership_id: id of the underlying membership';

COMMENT ON COLUMN grouper_perms_role_subject_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_perms_role_subject_v.permission_type IS 'permission_type: role or role_subject for assignment to role or to role subject pair';

COMMENT ON COLUMN grouper_perms_role_subject_v.assignment_notes IS 'assignment_notes: notes on this assignment';

COMMENT ON COLUMN grouper_perms_role_subject_v.immediate_mship_enabled_time IS 'immediate_mship_enabled_time: time this membership was enabled';

COMMENT ON COLUMN grouper_perms_role_subject_v.immediate_mship_disabled_time IS 'immediate_mship_disabled_time: time this membership will be disabled';

COMMENT ON COLUMN grouper_perms_role_subject_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

CREATE VIEW grouper_perms_all_v (role_name, subject_source_id, subject_id, action, attribute_def_name_name, attribute_def_name_disp_name, role_display_name, attribute_assign_delegatable, enabled, enabled_time, disabled_time, role_id, attribute_def_id, member_id, attribute_def_name_id, action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, attribute_assign_id, permission_type, assignment_notes, immediate_mship_enabled_time, immediate_mship_disabled_time, disallowed) AS select role_name,  subject_source_id,  subject_id,  action,  attribute_def_name_name,  attribute_def_name_disp_name,  role_display_name,  attribute_assign_delegatable, enabled, enabled_time, disabled_time, role_id,  attribute_def_id,  member_id,  attribute_def_name_id,  action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, attribute_assign_id, permission_type, assignment_notes, immediate_mship_enabled_time, immediate_mship_disabled_time, disallowed from grouper_perms_role_v  union  select role_name,  subject_source_id,  subject_id,  action,  attribute_def_name_name,  attribute_def_name_disp_name,  role_display_name,  attribute_assign_delegatable, enabled, enabled_time, disabled_time, role_id,  attribute_def_id,  member_id,  attribute_def_name_id,  action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, attribute_assign_id, permission_type, assignment_notes, immediate_mship_enabled_time, immediate_mship_disabled_time, disallowed from grouper_perms_role_subject_v  ;

COMMENT ON VIEW grouper_perms_all_v IS 'grouper_perms_all_v: shows all permissions assigned to users directly while in a role, or assigned to roles (and users in the role)';

COMMENT ON COLUMN grouper_perms_all_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_perms_all_v.subject_source_id IS 'subject_source_id: source id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_perms_all_v.subject_id IS 'subject_id: subject id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_perms_all_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_perms_all_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_perms_all_v.attribute_def_name_disp_name IS 'attribute_def_name_disp_name: display name of the attribute definition name assigned to the attribute';

COMMENT ON COLUMN grouper_perms_all_v.role_display_name IS 'role_display_name: display name of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_all_v.attribute_assign_delegatable IS 'attribute_assign_delegatable: if this assignment is delegatable or grantable: TRUE, FALSE, GRANT';

COMMENT ON COLUMN grouper_perms_all_v.enabled IS 'enabled: if this assignment is enabled: T, F';

COMMENT ON COLUMN grouper_perms_all_v.enabled_time IS 'enabled_time: the time (seconds since 1970) that this assignment will be enabled';

COMMENT ON COLUMN grouper_perms_all_v.disabled_time IS 'disabled_time: the time (seconds since 1970) that this assignment will be disabled';

COMMENT ON COLUMN grouper_perms_all_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_perms_all_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_perms_all_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_perms_all_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_perms_all_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_perms_all_v.membership_depth IS 'membership_depth: depth of membership, 0 is immediate';

COMMENT ON COLUMN grouper_perms_all_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_all_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_all_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_perms_all_v.membership_id IS 'membership_id: id of the underlying membership';

COMMENT ON COLUMN grouper_perms_all_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_perms_all_v.permission_type IS 'permission_type: role or role_subject for assignment to role or to role subject pair';

COMMENT ON COLUMN grouper_perms_all_v.assignment_notes IS 'assignment_notes: notes on this assignment';

COMMENT ON COLUMN grouper_perms_all_v.immediate_mship_enabled_time IS 'immediate_mship_enabled_time: time this membership was enabled';

COMMENT ON COLUMN grouper_perms_all_v.immediate_mship_disabled_time IS 'immediate_mship_disabled_time: time this membership will be disabled';

COMMENT ON COLUMN grouper_perms_all_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

CREATE VIEW grouper_pit_perms_role_v (role_name, subject_source_id, subject_id, action, attribute_def_name_name, role_id, attribute_def_id, member_id, attribute_def_name_id, action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, group_set_id, role_set_id, attribute_def_name_set_id, action_set_id, attribute_assign_id, permission_type, group_set_active, group_set_start_time, group_set_end_time, membership_active, membership_start_time, membership_end_time, role_set_active, role_set_start_time, role_set_end_time, action_set_active, action_set_start_time, action_set_end_time, attr_def_name_set_active, attr_def_name_set_start_time, attr_def_name_set_end_time, attribute_assign_active, attribute_assign_start_time, attribute_assign_end_time, disallowed, action_source_id, role_source_id, attribute_def_name_source_id, attribute_def_source_id, member_source_id, membership_source_id, attribute_assign_source_id) AS select distinct gr.name as role_name,  gm.subject_source as subject_source_id,  gm.subject_id,  gaaa.name as action, gadn.name as attribute_def_name_name,  gr.id as role_id,  gadn.attribute_def_id,  gm.id as member_id,  gadn.id as attribute_def_name_id,  gaaa.id as action_id, gmav.depth AS membership_depth, grs.depth AS role_set_depth, gadns.depth AS attr_def_name_set_depth, gaaas.depth AS attr_assign_action_set_depth, gmav.membership_id as membership_id, gmav.group_set_id as group_set_id, grs.id as role_set_id, gadns.id as attribute_def_name_set_id, gaaas.id as action_set_id, gaa.id AS attribute_assign_id, 'role' as permission_type, gmav.group_set_active, gmav.group_set_start_time, gmav.group_set_end_time, gmav.membership_active, gmav.membership_start_time, gmav.membership_end_time, grs.active as role_set_active, grs.start_time as role_set_start_time, grs.end_time as role_set_end_time, gaaas.active as action_set_active, gaaas.start_time as action_set_start_time, gaaas.end_time as action_set_end_time, gadns.active as attr_def_name_set_active, gadns.start_time as attr_def_name_set_start_time, gadns.end_time as attr_def_name_set_end_time, gaa.active as attribute_assign_active, gaa.start_time as attribute_assign_start_time, gaa.end_time as attribute_assign_end_time, gaa.disallowed,gaaa.source_id as action_source_id, gr.source_id as role_source_id, gadn.source_id as attribute_def_name_source_id, gad.source_id as attribute_def_source_id, gm.source_id as member_source_id, gmav.membership_source_id as membership_source_id, gaa.source_id as attribute_assign_source_id from grouper_pit_groups gr,  grouper_pit_memberships_all_v gmav,  grouper_pit_members gm,  grouper_pit_fields gf,  grouper_pit_role_set grs,  grouper_pit_attribute_def gad,  grouper_pit_attribute_assign gaa,  grouper_pit_attr_def_name gadn,  grouper_pit_attr_def_name_set gadns, grouper_pit_attr_assn_actn gaaa, grouper_pit_attr_assn_actn_set gaaas where gmav.owner_group_id = gr.id  and gmav.field_id = gf.id  and gf.type = 'list'  and gf.name = 'members'  and gmav.member_id = gm.id  and grs.if_has_role_id = gr.id  and gadn.attribute_def_id = gad.id  and gad.attribute_def_type = 'perm'  and gaa.owner_group_id = grs.then_has_role_id  and gaa.attribute_def_name_id = gadns.if_has_attribute_def_name_id  and gadn.id = gadns.then_has_attribute_def_name_id  and gaa.attribute_assign_type = 'group' and gaa.attribute_assign_action_id = gaaas.if_has_attr_assn_action_id and gaaa.id = gaaas.then_has_attr_assn_action_id ;

COMMENT ON VIEW grouper_pit_perms_role_v IS 'grouper_pit_perms_role_v: shows all permissions assigned to users due to the users being in a role, and the role being assigned the permission';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_pit_perms_role_v.subject_source_id IS 'subject_source_id: source id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_pit_perms_role_v.subject_id IS 'subject_id: subject id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_pit_perms_role_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_pit_perms_role_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_pit_perms_role_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_pit_perms_role_v.membership_depth IS 'membership_depth: depth of membership, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_v.membership_id IS 'membership_id: id of the immediate or composite membership in grouper_pit_memberships';

COMMENT ON COLUMN grouper_pit_perms_role_v.group_set_id IS 'group_set_id: id of the group set';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_set_id IS 'role_set_id: id of the role set';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_def_name_set_id IS 'attribute_def_name_set_id: id of the attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_role_v.action_set_id IS 'action_set_id: id of the action set';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_pit_perms_role_v.permission_type IS 'permission_type: role or role_subject for assignment to role or to role subject pair';

COMMENT ON COLUMN grouper_pit_perms_role_v.group_set_active IS 'group_set_active: whether the group set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_v.group_set_start_time IS 'group_set_start_time: start time of group set';

COMMENT ON COLUMN grouper_pit_perms_role_v.group_set_end_time IS 'group_set_end_time: end time of group set';

COMMENT ON COLUMN grouper_pit_perms_role_v.membership_active IS 'membership_active: whether the membership is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_v.membership_start_time IS 'membership_start_time: start time of membership';

COMMENT ON COLUMN grouper_pit_perms_role_v.membership_end_time IS 'membership_end_time: end time of membership';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_set_active IS 'role_set_active: whether the role set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_set_start_time IS 'role_set_start_time: start time of role set';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_set_end_time IS 'role_set_end_time: end time of role set';

COMMENT ON COLUMN grouper_pit_perms_role_v.action_set_active IS 'action_set_active: whether the action set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_v.action_set_start_time IS 'action_set_start_time: start time of action set';

COMMENT ON COLUMN grouper_pit_perms_role_v.action_set_end_time IS 'action_set_end_time: end time of action set';

COMMENT ON COLUMN grouper_pit_perms_role_v.attr_def_name_set_active IS 'attr_def_name_set_active: whether the attribute def name set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_v.attr_def_name_set_start_time IS 'attr_def_name_set_start_time: start time of attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_role_v.attr_def_name_set_end_time IS 'attr_def_name_set_end_time: end time of attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_assign_active IS 'attribute_assign_active: whether the attribute assign is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_assign_start_time IS 'attribute_assign_start_time: start time of attribute assign';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_assign_end_time IS 'attribute_assign_end_time: end time of attribute assign';

COMMENT ON COLUMN grouper_pit_perms_role_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

COMMENT ON COLUMN grouper_pit_perms_role_v.action_source_id IS 'action_source_id: id of the actual (non-pit) attribute assign action';

COMMENT ON COLUMN grouper_pit_perms_role_v.role_source_id IS 'role_source_id: id of the actual (non-pit) role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_def_name_source_id IS 'attribute_def_name_source_id: id of the actual (non-pit) attribute definition name';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_def_source_id IS 'attribute_def_source_id: id of the actual (non-pit) attribute definition';

COMMENT ON COLUMN grouper_pit_perms_role_v.member_source_id IS 'member_source_id: id of the actual (non-pit) subject in the members table';

COMMENT ON COLUMN grouper_pit_perms_role_v.membership_source_id IS 'membership_source_id: id of the actual (non-pit) immediate or composite membership';

COMMENT ON COLUMN grouper_pit_perms_role_v.attribute_assign_source_id IS 'attribute_assign_source_id: id of the actual (non-pit) attribute assign';

CREATE VIEW grouper_pit_perms_role_subj_v (role_name, subject_source_id, subject_id, action, attribute_def_name_name, role_id, attribute_def_id, member_id, attribute_def_name_id, action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, group_set_id, role_set_id, attribute_def_name_set_id, action_set_id, attribute_assign_id, permission_type, group_set_active, group_set_start_time, group_set_end_time, membership_active, membership_start_time, membership_end_time, role_set_active, role_set_start_time, role_set_end_time, action_set_active, action_set_start_time, action_set_end_time, attr_def_name_set_active, attr_def_name_set_start_time, attr_def_name_set_end_time, attribute_assign_active, attribute_assign_start_time, attribute_assign_end_time, disallowed, action_source_id, role_source_id, attribute_def_name_source_id, attribute_def_source_id, member_source_id, membership_source_id, attribute_assign_source_id) AS SELECT DISTINCT gr.name AS role_name,   gm.subject_source AS subject_source_id,   gm.subject_id,   gaaa.name AS ACTION,  gadn.name AS attribute_def_name_name,   gr.id AS role_id,   gadn.attribute_def_id,   gm.id AS member_id,   gadn.id AS attribute_def_name_id,   gaaa.id AS action_id, gmav.depth AS membership_depth, -1 AS role_set_depth, gadns.depth AS attr_def_name_set_depth, gaaas.depth AS attr_assign_action_set_depth, gmav.membership_id as membership_id, gmav.group_set_id as group_set_id, grs.id as role_set_id, gadns.id as attribute_def_name_set_id, gaaas.id as action_set_id, gaa.id as attribute_assign_id, 'role_subject' as permission_type, gmav.group_set_active, gmav.group_set_start_time, gmav.group_set_end_time, gmav.membership_active, gmav.membership_start_time, gmav.membership_end_time, grs.active as role_set_active, grs.start_time as role_set_start_time, grs.end_time as role_set_end_time, gaaas.active as action_set_active, gaaas.start_time as action_set_start_time, gaaas.end_time as action_set_end_time, gadns.active as attr_def_name_set_active, gadns.start_time as attr_def_name_set_start_time, gadns.end_time as attr_def_name_set_end_time, gaa.active as attribute_assign_active, gaa.start_time as attribute_assign_start_time, gaa.end_time as attribute_assign_end_time, gaa.disallowed, gaaa.source_id as action_source_id, gr.source_id as role_source_id, gadn.source_id as attribute_def_name_source_id, gad.source_id as attribute_def_source_id, gm.source_id as member_source_id, gmav.membership_source_id as membership_source_id, gaa.source_id as attribute_assign_source_id FROM grouper_pit_groups gr,   grouper_pit_memberships_all_v gmav,   grouper_pit_members gm,   grouper_pit_fields gf,   grouper_pit_role_set grs,  grouper_pit_attribute_def gad,  grouper_pit_attribute_assign gaa,   grouper_pit_attr_def_name gadn,   grouper_pit_attr_def_name_set gadns,   grouper_pit_attr_assn_actn gaaa,  grouper_pit_attr_assn_actn_set gaaas  WHERE gmav.owner_group_id = gr.id  and gmav.field_id = gf.id  and gmav.owner_group_id = gaa.owner_group_id  AND gmav.member_id = gaa.owner_member_id   AND gf.type = 'list'   AND gf.name = 'members'   AND gmav.member_id = gm.id   AND gadn.attribute_def_id = gad.id  AND gad.attribute_def_type = 'perm'  AND gaa.attribute_assign_type = 'any_mem'  AND gaa.attribute_def_name_id = gadns.if_has_attribute_def_name_id   AND gadn.id = gadns.then_has_attribute_def_name_id  AND gaa.attribute_assign_action_id = gaaas.if_has_attr_assn_action_id  AND gaaa.id = gaaas.then_has_attr_assn_action_id  AND grs.if_has_role_id = gr.id and grs.depth='0'  ;

COMMENT ON VIEW grouper_pit_perms_role_subj_v IS 'grouper_pit_perms_role_subj_v: shows all permissions assigned to users directly while in a role';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.subject_source_id IS 'subject_source_id: source id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.subject_id IS 'subject_id: subject id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.membership_depth IS 'membership_depth: depth of membership, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.membership_id IS 'membership_id: id of the immediate or composite membership in grouper_pit_memberships';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.group_set_id IS 'group_set_id: id of the group set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_set_id IS 'role_set_id: id of the role set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_def_name_set_id IS 'attribute_def_name_set_id: id of the attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action_set_id IS 'action_set_id: id of the action set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.permission_type IS 'permission_type: role or role_subject for assignment to role or to role subject pair';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.group_set_active IS 'group_set_active: whether the group set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.group_set_start_time IS 'group_set_start_time: start time of group set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.group_set_end_time IS 'group_set_end_time: end time of group set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.membership_active IS 'membership_active: whether the membership is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.membership_start_time IS 'membership_start_time: start time of membership';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.membership_end_time IS 'membership_end_time: end time of membership';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_set_active IS 'role_set_active: whether the role set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_set_start_time IS 'role_set_start_time: start time of role set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_set_end_time IS 'role_set_end_time: end time of role set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action_set_active IS 'action_set_active: whether the action set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action_set_start_time IS 'action_set_start_time: start time of action set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action_set_end_time IS 'action_set_end_time: end time of action set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attr_def_name_set_active IS 'attr_def_name_set_active: whether the attribute def name set is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attr_def_name_set_start_time IS 'attr_def_name_set_start_time: start time of attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attr_def_name_set_end_time IS 'attr_def_name_set_end_time: end time of attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_assign_active IS 'attribute_assign_active: whether the attribute assign is currently active';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_assign_start_time IS 'attribute_assign_start_time: start time of attribute assign';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_assign_end_time IS 'attribute_assign_end_time: end time of attribute assign';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.action_source_id IS 'action_source_id: id of the actual (non-pit) attribute assign action';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.role_source_id IS 'role_source_id: id of the actual (non-pit) role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_def_name_source_id IS 'attribute_def_name_source_id: id of the actual (non-pit) attribute definition name';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_def_source_id IS 'attribute_def_source_id: id of the actual (non-pit) attribute definition';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.member_source_id IS 'member_source_id: id of the actual (non-pit) subject in the members table';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.membership_source_id IS 'membership_source_id: id of the actual (non-pit) immediate or composite membership';

COMMENT ON COLUMN grouper_pit_perms_role_subj_v.attribute_assign_source_id IS 'attribute_assign_source_id: id of the actual (non-pit) attribute assign';

CREATE VIEW grouper_pit_perms_all_v (role_name, subject_source_id, subject_id, action, attribute_def_name_name, role_id, attribute_def_id, member_id, attribute_def_name_id, action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, group_set_id, role_set_id, attribute_def_name_set_id, action_set_id, attribute_assign_id, permission_type, group_set_active, group_set_start_time, group_set_end_time, membership_active, membership_start_time, membership_end_time, role_set_active, role_set_start_time, role_set_end_time, action_set_active, action_set_start_time, action_set_end_time, attr_def_name_set_active, attr_def_name_set_start_time, attr_def_name_set_end_time, attribute_assign_active, attribute_assign_start_time, attribute_assign_end_time, disallowed, action_source_id, role_source_id, attribute_def_name_source_id, attribute_def_source_id, member_source_id, membership_source_id, attribute_assign_source_id) AS select role_name,  subject_source_id,  subject_id,  action,  attribute_def_name_name,  role_id,  attribute_def_id,  member_id,  attribute_def_name_id,  action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, group_set_id, role_set_id, attribute_def_name_set_id, action_set_id, attribute_assign_id, permission_type, group_set_active, group_set_start_time, group_set_end_time, membership_active, membership_start_time, membership_end_time, role_set_active, role_set_start_time, role_set_end_time, action_set_active, action_set_start_time, action_set_end_time, attr_def_name_set_active, attr_def_name_set_start_time, attr_def_name_set_end_time, attribute_assign_active, attribute_assign_start_time, attribute_assign_end_time, disallowed, action_source_id, role_source_id, attribute_def_name_source_id, attribute_def_source_id, member_source_id, membership_source_id, attribute_assign_source_id from grouper_pit_perms_role_v  union  select role_name,  subject_source_id,  subject_id,  action,  attribute_def_name_name,  role_id,  attribute_def_id,  member_id,  attribute_def_name_id,  action_id, membership_depth, role_set_depth, attr_def_name_set_depth, attr_assign_action_set_depth, membership_id, group_set_id, role_set_id, attribute_def_name_set_id, action_set_id, attribute_assign_id, permission_type, group_set_active, group_set_start_time, group_set_end_time, membership_active, membership_start_time, membership_end_time, role_set_active, role_set_start_time, role_set_end_time, action_set_active, action_set_start_time, action_set_end_time, attr_def_name_set_active, attr_def_name_set_start_time, attr_def_name_set_end_time, attribute_assign_active, attribute_assign_start_time, attribute_assign_end_time, disallowed, action_source_id, role_source_id, attribute_def_name_source_id, attribute_def_source_id, member_source_id, membership_source_id, attribute_assign_source_id from grouper_pit_perms_role_subj_v  ;

COMMENT ON VIEW grouper_pit_perms_all_v IS 'grouper_pit_perms_all_v: shows all permissions assigned to users directly while in a role, or assigned to roles (and users in the role)';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_name IS 'role_name: name of the role that the user is in and that has the permission';

COMMENT ON COLUMN grouper_pit_perms_all_v.subject_source_id IS 'subject_source_id: source id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_pit_perms_all_v.subject_id IS 'subject_id: subject id of the subject which is in the role and thus has the permission';

COMMENT ON COLUMN grouper_pit_perms_all_v.action IS 'action: the action associated with the attribute assignment (default is assign)';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_def_name_name IS 'attribute_def_name_name: name of the attribute definition name which is assigned to the group';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_id IS 'role_id: id of role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_def_id IS 'attribute_def_id: id of the attribute definition';

COMMENT ON COLUMN grouper_pit_perms_all_v.member_id IS 'member_id: id of the subject in the members table';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_pit_perms_all_v.action_id IS 'action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_pit_perms_all_v.membership_depth IS 'membership_depth: depth of membership, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_set_depth IS 'role_set_depth: depth of role hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_all_v.attr_def_name_set_depth IS 'attr_def_name_set_depth: depth of attribute def name set hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_all_v.attr_assign_action_set_depth IS 'attr_assign_action_set_depth: depth of action hierarchy, 0 is immediate';

COMMENT ON COLUMN grouper_pit_perms_all_v.membership_id IS 'membership_id: id of the immediate or composite membership in grouper_pit_memberships';

COMMENT ON COLUMN grouper_pit_perms_all_v.group_set_id IS 'group_set_id: id of the group set';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_set_id IS 'role_set_id: id of the role set';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_def_name_set_id IS 'attribute_def_name_set_id: id of the attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_all_v.action_set_id IS 'action_set_id: id of the action set';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_assign_id IS 'attribute_assign_id: id of the underlying attribute assign';

COMMENT ON COLUMN grouper_pit_perms_all_v.permission_type IS 'permission_type: role or role_subject for assignment to role or to role subject pair';

COMMENT ON COLUMN grouper_pit_perms_all_v.group_set_active IS 'group_set_active: whether the group set is currently active';

COMMENT ON COLUMN grouper_pit_perms_all_v.group_set_start_time IS 'group_set_start_time: start time of group set';

COMMENT ON COLUMN grouper_pit_perms_all_v.group_set_end_time IS 'group_set_end_time: end time of group set';

COMMENT ON COLUMN grouper_pit_perms_all_v.membership_active IS 'membership_active: whether the membership is currently active';

COMMENT ON COLUMN grouper_pit_perms_all_v.membership_start_time IS 'membership_start_time: start time of membership';

COMMENT ON COLUMN grouper_pit_perms_all_v.membership_end_time IS 'membership_end_time: end time of membership';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_set_active IS 'role_set_active: whether the role set is currently active';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_set_start_time IS 'role_set_start_time: start time of role set';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_set_end_time IS 'role_set_end_time: end time of role set';

COMMENT ON COLUMN grouper_pit_perms_all_v.action_set_active IS 'action_set_active: whether the action set is currently active';

COMMENT ON COLUMN grouper_pit_perms_all_v.action_set_start_time IS 'action_set_start_time: start time of action set';

COMMENT ON COLUMN grouper_pit_perms_all_v.action_set_end_time IS 'action_set_end_time: end time of action set';

COMMENT ON COLUMN grouper_pit_perms_all_v.attr_def_name_set_active IS 'attr_def_name_set_active: whether the attribute def name set is currently active';

COMMENT ON COLUMN grouper_pit_perms_all_v.attr_def_name_set_start_time IS 'attr_def_name_set_start_time: start time of attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_all_v.attr_def_name_set_end_time IS 'attr_def_name_set_end_time: end time of attribute def name set';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_assign_active IS 'attribute_assign_active: whether the attribute assign is currently active';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_assign_start_time IS 'attribute_assign_start_time: start time of attribute assign';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_assign_end_time IS 'attribute_assign_end_time: end time of attribute assign';

COMMENT ON COLUMN grouper_pit_perms_all_v.disallowed IS 'disallowed: if permission is disallowed from a wider allow, null means false';

COMMENT ON COLUMN grouper_pit_perms_all_v.action_source_id IS 'action_source_id: id of the actual (non-pit) attribute assign action';

COMMENT ON COLUMN grouper_pit_perms_all_v.role_source_id IS 'role_source_id: id of the actual (non-pit) role the subject is in, and that the permissions are assigned to';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_def_name_source_id IS 'attribute_def_name_source_id: id of the actual (non-pit) attribute definition name';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_def_source_id IS 'attribute_def_source_id: id of the actual (non-pit) attribute definition';

COMMENT ON COLUMN grouper_pit_perms_all_v.member_source_id IS 'member_source_id: id of the actual (non-pit) subject in the members table';

COMMENT ON COLUMN grouper_pit_perms_all_v.membership_source_id IS 'membership_source_id: id of the actual (non-pit) immediate or composite membership';

COMMENT ON COLUMN grouper_pit_perms_all_v.attribute_assign_source_id IS 'attribute_assign_source_id: id of the actual (non-pit) attribute assign';

CREATE VIEW grouper_pit_attr_asn_value_v (attribute_assign_value_id, attribute_assign_id, attribute_def_name_id, attribute_assign_action_id, attribute_assign_type, owner_attribute_assign_id, owner_attribute_def_id, owner_group_id, owner_member_id, owner_membership_id, owner_stem_id, value_integer, value_floating, value_string, value_member_id, active, start_time, end_time) AS select gpaav.id as attribute_assign_value_id,  gpaa.id as attribute_assign_id,  gpaa.attribute_def_name_id,  gpaa.attribute_assign_action_id,  gpaa.attribute_assign_type,  gpaa.owner_attribute_assign_id,  gpaa.owner_attribute_def_id,  gpaa.owner_group_id,  gpaa.owner_member_id,  gpaa.owner_membership_id, gpaa.owner_stem_id, gpaav.value_integer, gpaav.value_floating, gpaav.value_string, gpaav.value_member_id, gpaav.active, gpaav.start_time, gpaav.end_time from grouper_pit_attribute_assign gpaa, grouper_pit_attr_assn_value gpaav where gpaa.id = gpaav.attribute_assign_id;

COMMENT ON VIEW grouper_pit_attr_asn_value_v IS 'grouper_pit_attr_asn_value_v: joins attribute values with their assignments';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.attribute_assign_value_id IS 'attribute_assign_value_id: id of the attribute assign value';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.attribute_assign_id IS 'attribute_assign_id: id of the attribute assignment';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.attribute_def_name_id IS 'attribute_def_name_id: id of the attribute definition name';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.attribute_assign_action_id IS 'attribute_assign_action_id: id of the attribute assign action';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.attribute_assign_type IS 'attribute_assign_type: type of assignment';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.owner_attribute_assign_id IS 'owner_attribute_assign_id: owner id of the attribute assignment if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.owner_attribute_def_id IS 'owner_attribute_def_id: owner id of the attribute definition if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.owner_group_id IS 'owner_group_id: owner id of the group if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.owner_member_id IS 'owner_member_id: owner id of the member if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.owner_membership_id IS 'owner_membership_id: owner id of the membership if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.owner_stem_id IS 'owner_stem_id: owner id of the stem if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.value_integer IS 'value_integer: integer value if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.value_floating IS 'value_floating: floating point value if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.value_string IS 'value_string: string value if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.value_member_id IS 'value_member_id: member id value if applicable';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.active IS 'active: whether the value is currently active';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.start_time IS 'start_time: start time of value';

COMMENT ON COLUMN grouper_pit_attr_asn_value_v.end_time IS 'end_time: end time of value';

CREATE VIEW grouper_ext_subj_invite_v (invite_id, invite_member_id, invite_date, email_address, invite_email_when_registered, invite_group_uuids, invite_expire_date, email_body, expire_attr_expire_date, expire_attr_enabled, assignment_expire_date, assignment_enabled, attribute_assign_id) AS SELECT (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteUuid'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS invite_id, (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteMemberId'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS invite_member_id,  (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteDate'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS invite_date,  (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectEmailAddress'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS email_address, (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteEmailWhenRegistered'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS invite_email_when_registered,  (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteGroupUuids'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS invite_group_uuids,  (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteExpireDate'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS invite_expire_date,  (SELECT gaav.value_string  FROM grouper_attr_asn_asn_stem_v gaaasv, grouper_attribute_assign_value gaav  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteEmail'  AND gaav.attribute_assign_id = gaaasv.attribute_assign_id2  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS email_body,  (SELECT gaaasv.disabled_time2  FROM grouper_attr_asn_asn_stem_v gaaasv  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteExpireDate'  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS expire_attr_expire_date,  (SELECT gaaasv.enabled2  FROM grouper_attr_asn_asn_stem_v gaaasv  WHERE gaaasv.attribute_def_name_name2 = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInviteExpireDate'  AND gaaasv.attribute_assign_id1 = gaasv.attribute_assign_id) AS expire_attr_enabled,  gaasv.disabled_time AS assignment_expire_date,  gaasv.enabled AS assignment_enabled,  gaasv.attribute_assign_id  FROM grouper_attr_asn_stem_v gaasv  WHERE gaasv.attribute_def_name_name = 'etc:attribute:attrExternalSubjectInvite:externalSubjectInvite';

COMMENT ON VIEW grouper_ext_subj_invite_v IS 'External subject invites pending, waiting for someone to respond';

COMMENT ON COLUMN grouper_ext_subj_invite_v.invite_id IS 'invite_id: id of the invite, in the url of the link';

COMMENT ON COLUMN grouper_ext_subj_invite_v.invite_member_id IS 'invite_member_id: member id of who invited the user';

COMMENT ON COLUMN grouper_ext_subj_invite_v.invite_date IS 'invite_date: date of the invite';

COMMENT ON COLUMN grouper_ext_subj_invite_v.email_address IS 'email_address: email address where the invite went';

COMMENT ON COLUMN grouper_ext_subj_invite_v.invite_email_when_registered IS 'invite_email_when_registered: email sent to this address when person registered';

COMMENT ON COLUMN grouper_ext_subj_invite_v.invite_group_uuids IS 'invite_group_uuids: group uuids that the user should be provisioned to when accepting the invite';

COMMENT ON COLUMN grouper_ext_subj_invite_v.invite_expire_date IS 'invite_expire_date: when the invite expires, attribute value';

COMMENT ON COLUMN grouper_ext_subj_invite_v.email_body IS 'email_body: email body sent to user, might be truncated if too long';

COMMENT ON COLUMN grouper_ext_subj_invite_v.expire_attr_expire_date IS 'expire_attr_expire_date: expire date of the expire attribute assignment';

COMMENT ON COLUMN grouper_ext_subj_invite_v.expire_attr_enabled IS 'expire_attr_enabled: if the expire attribute is enabled';

COMMENT ON COLUMN grouper_ext_subj_invite_v.assignment_expire_date IS 'assignment_expire_date: expire date of the attribute assignment on the stem';

COMMENT ON COLUMN grouper_ext_subj_invite_v.assignment_enabled IS 'assignment_enabled: if the attribute assignment on the stem is enabled';

COMMENT ON COLUMN grouper_ext_subj_invite_v.attribute_assign_id IS 'attribute_assign_id: attribute assign id of the attribute assignment on the stem';

CREATE VIEW grouper_rules_v (assigned_to_type, assigned_to_group_name, assigned_to_stem_name, assigned_to_member_subject_id, assigned_to_attribute_def_name, rule_check_type, rule_check_owner_id, rule_check_owner_name, rule_check_stem_scope, rule_check_arg0, rule_check_arg1, rule_if_condition_el, rule_if_condition_enum, rule_if_condition_enum_arg0, rule_if_condition_enum_arg1, rule_if_owner_id, rule_if_owner_name, rule_if_stem_scope, rule_then_el, rule_then_enum, rule_then_enum_arg0, rule_then_enum_arg1, rule_then_enum_arg2, rule_valid, rule_run_daemon, rule_act_as_subject_id, rule_act_as_subject_identifier, rule_act_as_subject_source_id, assignment_enabled, attribute_assign_id) AS SELECT main_gaa.attribute_assign_type AS assigned_to_type,  (SELECT gg.name  FROM grouper_groups gg WHERE gg.id = main_gaa.owner_group_id  ) AS assigned_to_group_name,  (SELECT gs.name  FROM grouper_stems gs WHERE gs.id = main_gaa.owner_stem_id  ) AS assigned_to_stem_name,  (SELECT gm.subject_id  FROM grouper_members gm WHERE gm.id = main_gaa.owner_member_id  ) AS assigned_to_member_subject_id,  (SELECT gad.name  FROM grouper_attribute_def gad WHERE gad.id = main_gaa.owner_attribute_def_id  ) AS assigned_to_attribute_def_name,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleCheckType'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_check_type,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleCheckOwnerId'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_check_owner_id,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleCheckOwnerName'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_check_owner_name,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleCheckStemScope'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_check_stem_scope,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleCheckArg0'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_check_arg0,  (SELECT gaav.value_string  FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleCheckArg1'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_check_arg1,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfConditionEl'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_condition_el,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfConditionEnum'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_condition_enum,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfConditionEnumArg0'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_condition_enum_arg0,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfConditionEnumArg1'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_condition_enum_arg1,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfOwnerId'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_owner_id,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfOwnerName'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_owner_name,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleIfStemScope'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_if_stem_scope,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleThenEl'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_then_el,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleThenEnum'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_then_enum,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleThenEnumArg0'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_then_enum_arg0,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleThenEnumArg1'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_then_enum_arg1,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleThenEnumArg2'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_then_enum_arg2,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleValid'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_valid,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleRunDaemon'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_run_daemon,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleActAsSubjectId'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_act_as_subject_id,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleActAsSubjectIdentifier'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_act_as_subject_identifier,  (SELECT gaav.value_string   FROM grouper_attribute_assign gaa, grouper_attribute_assign_value gaav, grouper_attribute_def_name gadn   WHERE gadn.name = 'etc:attribute:rules:ruleActAsSubjectSourceId'   AND gaav.attribute_assign_id = gaa.id   AND gaa.attribute_def_name_id = gadn.id   AND gaa.owner_attribute_assign_id = main_gaa.id   AND gaa.enabled = 'T') AS rule_act_as_subject_source_id,   main_gaa.enabled AS assignment_enabled,  main_gaa.id AS attribute_assign_id  FROM grouper_attribute_assign main_gaa, grouper_attribute_def_name main_gadn  WHERE main_gadn.name = 'etc:attribute:rules:rule'  AND main_gaa.attribute_def_name_id = main_gadn.id ;

COMMENT ON VIEW grouper_rules_v IS 'Rules setup in grouper';

COMMENT ON COLUMN grouper_rules_v.assigned_to_type IS 'assigned_to_type: attribute_assign_type of rule assignment, e.g. group, stem, etc';

COMMENT ON COLUMN grouper_rules_v.assigned_to_group_name IS 'assigned_to_group_name: if rule is assigned to group, this is the group name';

COMMENT ON COLUMN grouper_rules_v.assigned_to_stem_name IS 'assigned_to_stem_name: if rule is assigned to stem, this is the stem name';

COMMENT ON COLUMN grouper_rules_v.assigned_to_member_subject_id IS 'assigned_to_member_subject_id: if rule is assigned to member, this is the subject id';

COMMENT ON COLUMN grouper_rules_v.assigned_to_attribute_def_name IS 'assigned_to_attribute_def_name: if rule is assigned to attribute_def, this is the name of the attribute_def';

COMMENT ON COLUMN grouper_rules_v.rule_check_type IS 'rule_check_type: RuleCheckType enum of when this rule is fired and how to decides which rules are affected';

COMMENT ON COLUMN grouper_rules_v.rule_check_owner_id IS 'rule_check_owner_id: If the owner is not the object where the rule is assigned, specify id here.  Check owner affects when rule is fired.  Mutually exclusive with rule_check_owner_name';

COMMENT ON COLUMN grouper_rules_v.rule_check_owner_name IS 'rule_check_owner_name: If the owner is not the object where the rule is assigned, specify name here.  Check owner affects when rule is fired.  Mutually exclusive with rule_check_owner_id';

COMMENT ON COLUMN grouper_rules_v.rule_check_stem_scope IS 'rule_check_stem_scope: If the owner type is stem, then this is the scope: ONE or SUB';

COMMENT ON COLUMN grouper_rules_v.rule_check_arg0 IS 'rule_check_arg0: If the rule check type has arguments, this is the first';

COMMENT ON COLUMN grouper_rules_v.rule_check_arg1 IS 'rule_check_arg1: If the rule check type has arguments, this is the second';

COMMENT ON COLUMN grouper_rules_v.rule_if_condition_el IS 'rule_if_condition_el: If there is expression language to decide if the rule should fire, it is here.  Mutually exclusive with if_condition_enum';

COMMENT ON COLUMN grouper_rules_v.rule_if_condition_enum IS 'rule_if_condition_enum: If the if condition is a built in enum, that IfConditionEnum should be here.  Mutually exclusive with if_condition_el';

COMMENT ON COLUMN grouper_rules_v.rule_if_condition_enum_arg0 IS 'rule_if_condition_enum_arg0: If the if_condition_enum has arguments, this is the first';

COMMENT ON COLUMN grouper_rules_v.rule_if_condition_enum_arg1 IS 'rule_if_condition_enum_arg1: If the if_condition_enum has arguments, this is the second';

COMMENT ON COLUMN grouper_rules_v.rule_if_owner_id IS 'rule_if_owner_id: If the if condition enum has an owner, the id is here.  Mutually exclusive with rule_if_owner_name';

COMMENT ON COLUMN grouper_rules_v.rule_if_owner_name IS 'rule_if_owner_name: If the if condition enum has an owner, the name is here.  Mutually exclusive with rule_if_owner_id';

COMMENT ON COLUMN grouper_rules_v.rule_if_stem_scope IS 'rule_if_stem_scope: If the if condition enum is a stem type, this is the scope, ONE or SUB';

COMMENT ON COLUMN grouper_rules_v.rule_then_el IS 'rule_then_el: Then condition expression language if the rule fires.  Mutually exclusive with rule_then_enum';

COMMENT ON COLUMN grouper_rules_v.rule_then_enum IS 'rule_then_enum: then condition built in enum: ThenConditionEnum.  Mutually exclusive with rule_then_el';

COMMENT ON COLUMN grouper_rules_v.rule_then_enum_arg0 IS 'rule_then_enum_arg0: If the then condition enum has arguments, this is the first';

COMMENT ON COLUMN grouper_rules_v.rule_then_enum_arg1 IS 'rule_then_enum_arg1: If the then condition enum has arguments, this is the second';

COMMENT ON COLUMN grouper_rules_v.rule_then_enum_arg2 IS 'rule_then_enum_arg2: If the then condition enum has arguments, this is the third';

COMMENT ON COLUMN grouper_rules_v.rule_valid IS 'rule_valid: If the rule is valid, this will be T, else it is the error message';

COMMENT ON COLUMN grouper_rules_v.rule_run_daemon IS 'rule_run_daemon: If this rule should run a daemon.  Needs to be daemonable...';

COMMENT ON COLUMN grouper_rules_v.rule_act_as_subject_id IS 'rule_act_as_subject_id: Who this rule should act as when firing.  Mutually exclusive with rule_act_as_subject_identifier';

COMMENT ON COLUMN grouper_rules_v.rule_act_as_subject_identifier IS 'rule_act_as_subject_identifier: Who this rule should act as when firing.  Mutually exclusive with rule_act_as_subject_id';

COMMENT ON COLUMN grouper_rules_v.rule_act_as_subject_source_id IS 'rule_act_as_subject_source_id: Optional, source id of who this rule should act as';

COMMENT ON COLUMN grouper_rules_v.assignment_enabled IS 'assignment_enabled: If the rule assignment is enabled';

COMMENT ON COLUMN grouper_rules_v.attribute_assign_id IS 'attribute_assign_id: The attribute assign id in the grouper_attribute_assign table for the main rule definition';

