
SELECT pg_catalog.set_config('search_path', '', false);

--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


--
-- Name: accreq_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.accreq_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "accreq" set date = now() where "accreq".ikey = old.okey;
end if;
IF (TG_OP != 'DELETE') then
update "accreq"  set date = now() where "accreq".ikey = new.okey;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: address_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.address_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "address" set date = now() where "address".ikey = old.okey;
end if;
IF (TG_OP != 'DELETE') then
update "address"  set date = now() where "address".ikey = new.okey;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: address_sort_fields(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.address_sort_fields() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN

IF (TG_OP='INSERT') then
IF (new.attr='site') THEN
insert into address_attributes_site VALUES (new.*);
RETURN NULL;
END IF;

IF (new.attr = 'isMainAddress') then
-- remove isMainAddress from other address
-- for of the user
delete from address_attributes_base where
attr = 'isMainAddress' and
okey in (
select addr.ikey from address as addr join
  address on addr.user = address.user
  where 
  address.ikey = new.okey and addr.ikey != new.okey
);
END IF;
end if;

if (TG_OP='DELETE') THEN
RETURN old;
else
RETURN new;
end if;
END;$$;


--
-- Name: address_update_user_rev(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.address_update_user_rev() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP = 'DELETE') THEN
update "user" set "date" = now() where "name" = old."user";
return old;
ELSE
update "user" set "date" = now() where "name" = new."user";
return new;
end if;

end;$$;


--
-- Name: aliases_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.aliases_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

            IF (TG_OP != 'INSERT') then
            update "aliases" set date = now() where "aliases".ikey = old.okey;
            end if;
            IF (TG_OP != 'DELETE') then
            update "aliases"  set date = now() where "aliases".ikey = new.okey;
            end if;

            IF (TG_OP = 'DELETE') then
            return old;
            ELSE
            return new;
            END IF;

            END;$$;


--
-- Name: aliases_nickname(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.aliases_nickname() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF TG_OP='DELETE' THEN
delete from user_attributes where attr='nickname' and value=old.name;
RETURN old;
END IF;

IF TG_OP='UPDATE' THEN
IF new.forward <> old.forward THEN
delete from user_attributes where attr='nickname' and value=old.name;
RETURN new;
END IF;
END IF;

IF TG_OP='DELETE' then
return old;
ELSE
return new;
END IF;
END;$$;


--
-- Name: department_group_upd_f(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.department_group_upd_f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN

IF (new.attr = 'department') then
  BEGIN
  insert into group_attributes (okey, attr, value)
  select "group"."ikey", 'memberUID', "user"."name"
  from "user", "group"
  where "group"."name" = new."value" and "user".ikey = new.okey;
  EXCEPTION WHEN unique_violation THEN
  END;
END IF;

RETURN new;
END;$$;


--
-- Name: employment_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.employment_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

            IF (TG_OP != 'INSERT') then
            update "employment" set date = now() where "employment".ikey = old.okey;
            end if;
            IF (TG_OP != 'DELETE') then
            update "employment"  set date = now() where "employment".ikey = new.okey;
            end if;

            IF (TG_OP = 'DELETE') then
            return old;
            ELSE
            return new;
            END IF;

            END;$$;


--
-- Name: fmt_macaddr(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.fmt_macaddr() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

new.value := new.value::macaddr::text;

return new;
end;$$;


--
-- Name: group_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.group_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "group"  set date = now() where "group"."ikey" = old.okey;
end if;
IF (TG_OP != 'DELETE') then
update "group"  set date = now() where "group"."ikey" = new.okey;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: group_attr_user_update_user_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.group_attr_user_update_user_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "user"  set date = now() where "user"."name" = old.value;
end if;
IF (TG_OP != 'DELETE') then
update "user"  set date = now() where "user"."name" = new.value;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: group_sort_fields(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.group_sort_fields() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN

              IF (TG_OP='INSERT') then
              IF (new.attr='managedBy'
                  OR  new.attr='managedAlsoBy'
                  OR  new.attr='member'
                  OR  new.attr='memberUID') THEN
              insert into group_attributes_users VALUES (new.*);
              RETURN NULL;
              END IF;

              IF (new.attr='sutype') THEN
              insert into group_attributes_sutypes VALUES (new.*);
              RETURN NULL;
              END IF;
              end if;


              IF (TG_OP = 'UPDATE') THEN
              IF (new.attr='gidNumber') then
              update "group" set gidnumber = new.value::integer where
              "group".ikey = new.okey;
              RETURN NULL;
              END IF;
              END IF;

              IF (TG_OP = 'DELETE') THEN
              IF (old.attr='exported') then
              update "group" set exported = false where "group".ikey = old.okey;
              return null;
              end if;
              else
              IF (new.attr='exported') then
              update "group" set exported = true where "group".ikey = new.okey;
              RETURN NULL;
              end if;
              END IF;

              if (TG_OP='DELETE') THEN
              RETURN old;
              else
              RETURN new;
              end if;
              END;$$;


--
-- Name: nethost_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.nethost_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "nethost" set date = now() where "nethost".ikey = old.okey;
end if;
IF (TG_OP != 'DELETE') then
update "nethost"  set date = now() where "nethost".ikey = new.okey;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: nethost_sort_fields(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.nethost_sort_fields() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN

              IF (TG_OP='INSERT') then
              IF (new.attr='ip') THEN
              insert into nethost_attributes_ips VALUES (new.*);
              RETURN NULL;
              END IF;

              IF (new.attr='macaddr') THEN
              insert into nethost_attributes_macs VALUES (new.*);
              RETURN NULL;
              END IF;

              IF (new.attr='owner') THEN
              insert into nethost_attributes_users VALUES (new.*);
              RETURN NULL;
              END IF;

              IF (new.attr='user') THEN
              insert into nethost_attributes_users VALUES (new.*);
              RETURN NULL;
              END IF;

	      IF (new.attr='related') THEN
              insert into nethost_attributes_nethosts VALUES (new.*);
              RETURN NULL;
              END IF;
              end if;

              if (TG_OP='DELETE') THEN
              RETURN old;
              else
              RETURN new;
              end if;
              END;$$;


--
-- Name: nethost_upd_zone(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.nethost_upd_zone() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

  IF (TG_OP = 'DELETE') THEN
    update netzone set date=now() where ikey in
    (
    select okey from netzone_attributes where attr='allow_dyn'
    union
    select netzone_attributes.okey from netzone_attributes join
    nethost_attributes_ips on netzone_attributes.attr='net' and 
    nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet
    where nethost_attributes_ips.okey = old.ikey
    );
  END IF;
  IF (TG_OP = 'INSERT' or TG_OP = 'UPDATE') THEN
    update netzone set date=now() where ikey in
    (
    select okey from netzone_attributes where attr='allow_dyn'
    union
    select netzone_attributes.okey from netzone_attributes join
    nethost_attributes_ips on netzone_attributes.attr='net' and 
    nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet
    where nethost_attributes_ips.okey = new.ikey
    );
  END IF;

 IF (TG_OP = 'DELETE') THEN
   return old;
 ELSE
   return new;
 END IF;

END;$$;


--
-- Name: nethostipdel_upd_zone(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.nethostipdel_upd_zone() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin


    update netzone set date=now() where ikey in
    (
    select okey from netzone_attributes where attr='allow_dyn'
    union
    select okey from netzone_attributes where attr='net' and
    old.value::inet <<= netzone_attributes.value::inet
    );

   return old;
 
END;$$;


--
-- Name: netzone_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.netzone_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "netzone" set date = now() where "netzone".ikey = old.okey;
end if;
IF (TG_OP != 'DELETE') then
update "netzone"  set date = now() where "netzone".ikey = new.okey;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: netzone_sort_fields(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.netzone_sort_fields() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN

IF (TG_OP='INSERT') then
IF (new.attr='site') THEN
insert into netzone_attributes_site VALUES (new.*);
RETURN NULL;
END IF;

IF (new.attr='dynFrom') THEN
insert into netzone_attributes_netzone VALUES (new.*);
RETURN NULL;
END IF;

end if;

if (TG_OP='DELETE') THEN
RETURN old;
else
RETURN new;
end if;
END;$$;


--
-- Name: person_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.person_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "user" set date = now() where "user".ikey = old.okey;
update "group" set date = now() where "group".name = old.value;
end if;
IF (TG_OP != 'DELETE') then
update "user"  set date = now() where "user".ikey = new.okey;
update "group" set date = now() where "group".name = new.value;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: rev_tg_aliases_f(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.rev_tg_aliases_f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

            IF (TG_OP = 'DELETE') THEN
            update "user" set rev = nextval('revisions_rev_seq'::regclass), "date" = now() where "name" = ANY (old.forward);
            return old;
            ELSE
                IF (TG_OP = 'UPDATE') THEN
                update "user" set rev = nextval('revisions_rev_seq'::regclass), "date" = now() where "name" = ANY (old.forward);
                END IF;
            update "user" set rev = nextval('revisions_rev_seq'::regclass), "date" = now() where "name" = ANY (new.forward);
            return new;
            END IF;

            end;$$;


--
-- Name: rev_tg_f(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.rev_tg_f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP = 'DELETE') THEN
  update settings set val = old.ikey where varname = 'last-delete';
  IF NOT FOUND THEN
    insert into settings (varname, val) values ('last-delete', old.ikey);
  END IF;
  return old;
else
  IF (TG_OP = 'INSERT') THEN
  new.rev := nextval('public.revisions_rev_seq'::regclass);
  new.date := now();
  ELSIF (old.rev = new.rev) THEN
  new.rev := nextval('public.revisions_rev_seq'::regclass);
  new.date := now();
  END IF;  
  return new;
END IF;

end;$$;


--
-- Name: service_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.service_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

            IF (TG_OP != 'INSERT') then
            update "service" set date = now() where "service".ikey = old.okey;
            end if;
            IF (TG_OP != 'DELETE') then
            update "service"  set date = now() where "service".ikey = new.okey;
            end if;

            IF (TG_OP = 'DELETE') then
            return old;
            ELSE
            return new;
            END IF;

            END;$$;


--
-- Name: service_sort_fields(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.service_sort_fields() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN

              if (TG_OP='INSERT' or TG_OP='UPDATE') THEN
              IF (new.attr='manager') THEN
              insert into service_attributes_users VALUES (new.*);
              RETURN NULL;
              END IF;
              END IF;

              if (TG_OP='DELETE') THEN
              RETURN old;
              else
              RETURN new;
              end if;
              END;$$;


--
-- Name: site_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.site_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP != 'INSERT') then
update "site" set date = now() where "site".ikey = old.okey;
end if;
IF (TG_OP != 'DELETE') then
update "site"  set date = now() where "site".ikey = new.okey;
end if;

IF (TG_OP = 'DELETE') then
  return old;
ELSE
  return new;
END IF;

END;$$;


--
-- Name: stat_attr_update_ref(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.stat_attr_update_ref() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

            IF (TG_OP != 'INSERT') then
            update "stat" set date = now() where "stat".ikey = old.okey;
            end if;
            IF (TG_OP != 'DELETE') then
            update "stat"  set date = now() where "stat".ikey = new.okey;
            end if;

            IF (TG_OP = 'DELETE') then
            return old;
            ELSE
            return new;
            END IF;

            END;$$;


--
-- Name: update_address_site(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_address_site() RETURNS trigger
    LANGUAGE plpgsql
    AS $$begin

IF (TG_OP='DELETE') then
update address set date = now() where ikey in
(select okey from address_attributes where attr = 'site' and
value = old.name);
return old;
ELSE
update address set date = now() where ikey in
(select okey from address_attributes where attr = 'site' and
value = new.name);
return new;
end if;

end;$$;


--
-- Name: user_sort_fields(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.user_sort_fields() RETURNS trigger
    LANGUAGE plpgsql
    AS $$DECLARE
            rec RECORD;
            BEGIN

            IF (TG_OP='UPDATE' or TG_OP='INSERT') THEN

            IF (new.attr='locked') THEN
            IF (TG_OP = 'INSERT') THEN
            new.value = now()::text;
            ELSIF (TG_OP='UPDATE') THEN
            new.value = old.value;
            END IF;
            END IF;

            IF (new.attr='nickname') THEN
            PERFORM 1 from "user" where "user".ikey = new.okey
                and new.value = "user".name;
            IF NOT FOUND THEN
            select aliases.name into rec from aliases join "user"
            on array["user".name] = aliases.forward
            where "user".ikey = new.okey and aliases.name = new.value;
            IF NOT FOUND THEN
            insert into aliases ("name", "forward", "description", exported)
            select new.value, array["user".name], 'Forward for ' || "user".name || ' nickname', "user".exported from "user" where "user".ikey = new.okey;
            END IF;
            END IF;
            END IF;

            IF (new.attr='uidNumber') THEN
            update "user" set uidnumber = new.value::integer where ikey = new.okey;
            RETURN NULL;
            END IF;

            IF (new.attr='gidNumber') THEN
            update "user" set gidnumber = new.value::integer where ikey = new.okey;
            RETURN null;
            END IF;

            IF (new.attr='expire') THEN
            update "user" set expire = new.value::timestamp where ikey = new.okey;
            RETURN NULL;
            END IF;

            IF (new.attr='exported') THEN
            update "user" set exported = true where ikey = new.okey;
            RETURN NULL;
            END IF;

            END IF;

            IF (TG_OP = 'DELETE') THEN

            IF (old.attr='expire') THEN
            update "user" set expire = NULL where ikey = old.okey;
            RETURN NULL;
            END IF;

            IF (old.attr='exported') THEN
            update "user" set exported = false where ikey = old.okey;
            RETURN NULL;
            END IF;

            END IF;


            IF (TG_OP='INSERT') THEN
            IF (new.attr='manager') THEN
            insert into user_attributes_users VALUES (new.*);
            RETURN NULL;
            END IF;

            IF (new.attr='site') THEN
            insert into user_attributes_site VALUES (new.*);
            RETURN NULL;
            END IF;

            IF (new.attr='department') THEN
            insert into user_attributes_groups VALUES (new.*);
            RETURN NULL;
            END IF;

            IF (new.attr='contratType') THEN
            insert into user_attributes_groups VALUES (new.*);
            RETURN NULL;
            END IF;

            IF (new.attr='jobType') THEN
            insert into user_attributes_groups VALUES (new.*);
            RETURN NULL;
            END IF;

            END IF;

            IF (TG_OP='DELETE') then
            RETURN old;
            ELSE
            RETURN new;
            end if;
            END;$$;


--
-- Name: ikey_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.ikey_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;




--
-- Name: revisions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.revisions (
    rev integer NOT NULL,
    date timestamp with time zone DEFAULT now() NOT NULL,
    "create" timestamp with time zone DEFAULT now() NOT NULL,
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass) NOT NULL
);


--
-- Name: objects; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.objects (
    exported boolean DEFAULT true NOT NULL,
    name text NOT NULL,
    createdby text,
    modifiedby text,
    oalias text,
    internobject boolean DEFAULT false NOT NULL,
    nodelete boolean DEFAULT false NOT NULL,
    oaliascache text
)
INHERITS (public.revisions);


--
-- Name: accreq; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.accreq (
)
INHERITS (public.objects);


--
-- Name: attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.attributes (
    value text NOT NULL,
    attr_key integer NOT NULL,
    okey integer NOT NULL,
    attr text NOT NULL
);


--
-- Name: accreq_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.accreq_attributes (
)
INHERITS (public.attributes);


--
-- Name: attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.attributes_list (
    canonical text NOT NULL,
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass) NOT NULL,
    description text
);


--
-- Name: COLUMN attributes_list.canonical; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.attributes_list.canonical IS 'Nom de l''attribut';


--
-- Name: COLUMN attributes_list.ikey; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.attributes_list.ikey IS 'Clef interne à la base';


--
-- Name: revisions_rev_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.revisions_rev_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: revisions_rev_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.revisions_rev_seq OWNED BY public.revisions.rev;


--
-- Name: accreq_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.accreq_attributes_list (
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass),
    rev integer DEFAULT nextval('public.revisions_rev_seq'::regclass) NOT NULL,
    date timestamp with time zone DEFAULT now() NOT NULL,
    "create" timestamp with time zone DEFAULT now() NOT NULL
)
INHERITS (public.attributes_list);


--
-- Name: address_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.address_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: address; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.address (
    name text DEFAULT ('address'::text || (nextval('public.address_seq'::regclass))::text),
    "user" text NOT NULL,
    expire timestamp with time zone
)
INHERITS (public.objects);


--
-- Name: address_attributes_base; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.address_attributes_base (
)
INHERITS (public.attributes);


--
-- Name: user; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."user" (
    name text,
    uidnumber integer NOT NULL,
    gidnumber integer NOT NULL,
    expire timestamp with time zone,
    endcircuit timestamp with time zone,
    CONSTRAINT uid_not_empty CHECK ((name <> ''::text))
)
INHERITS (public.objects);


--
-- Name: address_attributes; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.address_attributes AS
 SELECT address."user" AS value,
    'user'::text AS attr,
    address.rev AS attr_key,
    address.ikey AS okey
   FROM public.address
UNION ALL
 SELECT address.name AS value,
    'name'::text AS attr,
    address.rev AS attr_key,
    address.ikey AS okey
   FROM public.address
UNION ALL
 SELECT address_attributes.value,
    address_attributes.attr,
    address_attributes.attr_key,
    address_attributes.okey
   FROM public.address_attributes_base address_attributes
UNION ALL
 SELECT '1'::text AS value,
    'active'::text AS attr,
    address.rev AS attr_key,
    address.ikey AS okey
   FROM (public."user"
     JOIN public.address ON (("user".name = address."user")))
  WHERE ("user".exported AND address.exported AND (("user".expire IS NULL) OR ("user".expire > now())));


--
-- Name: address_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.address_attributes_list (
    rev integer DEFAULT nextval('public.revisions_rev_seq'::regclass),
    date timestamp with time zone DEFAULT now(),
    "create" timestamp with time zone DEFAULT now()
)
INHERITS (public.attributes_list, public.revisions);


--
-- Name: address_attributes_list_site; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.address_attributes_list_site (
)
INHERITS (public.address_attributes_list);


--
-- Name: address_attributes_site; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.address_attributes_site (
)
INHERITS (public.address_attributes_base);


--
-- Name: aliases; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.aliases (
    forward text[],
    expire timestamp with time zone,
    description text
)
INHERITS (public.objects);


--
-- Name: TABLE aliases; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.aliases IS 'Mail aliases';


--
-- Name: aliases_attributes_base; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.aliases_attributes_base (
)
INHERITS (public.attributes);


--
-- Name: aliases_attributes; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.aliases_attributes AS
 SELECT "user".name AS value,
    'user'::text AS attr,
    aliases.rev AS attr_key,
    aliases.ikey AS okey
   FROM (public.aliases
     JOIN public."user" ON (((aliases.name = "user".name) OR (aliases.forward = ARRAY["user".name]))))
UNION ALL
 SELECT aliases_attributes_base.value,
    aliases_attributes_base.attr,
    aliases_attributes_base.attr_key,
    aliases_attributes_base.okey
   FROM public.aliases_attributes_base
UNION ALL
 SELECT aliases.name AS value,
    'name'::text AS attr,
    aliases.rev AS attr_key,
    aliases.ikey AS okey
   FROM public.aliases;


--
-- Name: aliases_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.aliases_attributes_list (
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass),
    canonical text,
    description text
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: all_obj_attributes; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.all_obj_attributes AS
 SELECT pg_class.relname,
    objects.name,
    attributes_list.description,
    attributes.attr_key,
    attributes.attr,
    attributes.value
   FROM (((public.attributes_list
     JOIN public.attributes ON ((attributes.attr = attributes_list.canonical)))
     JOIN pg_class ON ((attributes.tableoid = pg_class.oid)))
     JOIN public.objects ON ((objects.ikey = attributes.okey)));


--
-- Name: attributes_attr_key_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.attributes_attr_key_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: attributes_attr_key_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.attributes_attr_key_seq OWNED BY public.attributes.attr_key;


--
-- Name: attributes_values; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.attributes_values (
    otype text NOT NULL,
    attributes text NOT NULL,
    value text NOT NULL
)
INHERITS (public.revisions);


--
-- Name: employment; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.employment (
    name text,
    "user" text NOT NULL,
    firstday date DEFAULT now() NOT NULL,
    lastday date,
    CONSTRAINT employment_check CHECK (((lastday IS NULL) OR (firstday <= lastday)))
)
INHERITS (public.objects);


--
-- Name: employment_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.employment_attributes (
)
INHERITS (public.attributes);


--
-- Name: employment_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.employment_attributes_list (
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: group; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."group" (
    name text,
    gidnumber integer NOT NULL,
    CONSTRAINT group_name_not_empty CHECK ((name <> ''::text))
)
INHERITS (public.objects);


--
-- Name: group_attributes_base; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.group_attributes_base (
)
INHERITS (public.attributes);


--
-- Name: user_attributes_base; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_attributes_base (
)
INHERITS (public.attributes);


--
-- Name: group_attributes; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.group_attributes AS
 SELECT ("group".gidnumber)::text AS value,
    'gidnumber'::text AS attr,
    "group".rev AS attr_key,
    "group".ikey AS okey
   FROM public."group"
UNION ALL
 SELECT "group".name AS value,
    'name'::text AS attr,
    "group".rev AS attr_key,
    "group".ikey AS okey
   FROM public."group"
UNION ALL
 SELECT '1'::text AS value,
    'exported'::text AS attr,
    "group".rev AS attr_key,
    "group".ikey AS okey
   FROM public."group"
  WHERE ("group".exported = true)
UNION ALL
 SELECT group_attributes.value,
    group_attributes.attr,
    group_attributes.attr_key,
    group_attributes.okey
   FROM public.group_attributes_base group_attributes
UNION ALL
 SELECT "user".name AS value,
    'memberUID'::text AS attr,
    user_attributes_base.attr_key,
    "group".ikey AS okey
   FROM ((public.user_attributes_base
     JOIN public."user" ON (("user".ikey = user_attributes_base.okey)))
     JOIN public."group" ON (("group".name = user_attributes_base.value)))
  WHERE (user_attributes_base.attr = 'contratType'::text);


--
-- Name: group_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.group_attributes_list (
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: group_attributes_sutypes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.group_attributes_sutypes (
)
INHERITS (public.group_attributes_base);


--
-- Name: group_attributes_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.group_attributes_users (
)
INHERITS (public.group_attributes_base);


--
-- Name: nethost; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost (
    expire timestamp with time zone
)
INHERITS (public.objects);


--
-- Name: nethost_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost_attributes (
)
INHERITS (public.attributes);


--
-- Name: nethost_attributes_macs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost_attributes_macs (
    CONSTRAINT nethost_valid_mac_address CHECK (((value)::macaddr <> '00:00:00:00:00:00'::macaddr))
)
INHERITS (public.nethost_attributes);


--
-- Name: macentry; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.macentry AS
 SELECT nethost.rev,
    nethost.date,
    nethost."create",
    nethost.ikey,
    nethost.exported,
    replace(nethost_attributes_macs.value, ':'::text, ''::text) AS name,
    nethost.createdby,
    nethost.modifiedby,
    nethost.expire,
    nethost.oalias,
    nethost.nodelete,
    nethost.internobject,
    nethost.oaliascache
   FROM (public.nethost_attributes_macs
     JOIN public.nethost ON ((nethost.ikey = nethost_attributes_macs.okey)))
  WHERE (nethost_attributes_macs.attr = 'macaddr'::text);


--
-- Name: macentry_attributes; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.macentry_attributes AS
 SELECT nethost_attributes.value,
    nethost_attributes.attr_key,
    nethost_attributes.okey,
    nethost_attributes.attr
   FROM public.nethost_attributes;


--
-- Name: nethost_attributes_ips; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost_attributes_ips (
)
INHERITS (public.nethost_attributes);


--
-- Name: nethost_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost_attributes_list (
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass),
    canonical text,
    description text
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: nethost_attributes_nethosts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost_attributes_nethosts (
)
INHERITS (public.nethost_attributes);


--
-- Name: netzone; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.netzone (
)
INHERITS (public.objects);


--
-- Name: netzone_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.netzone_attributes (
)
INHERITS (public.attributes);


--
-- Name: nethost_attributes_netzone; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.nethost_attributes_netzone AS
 SELECT netzone.name AS value,
    'netZone'::text AS attr,
    nethost_attributes_ips.attr_key,
    nethost_attributes_ips.okey
   FROM public.nethost_attributes_ips,
    public.netzone_attributes,
    public.netzone
  WHERE ((netzone.ikey = netzone_attributes.okey) AND (netzone_attributes.attr = 'net'::text) AND ((nethost_attributes_ips.value)::inet <<= (netzone_attributes.value)::inet))
EXCEPT
 SELECT netzone.name AS value,
    'netZone'::text AS attr,
    nethost_attributes_ips.attr_key,
    nethost_attributes_ips.okey
   FROM public.nethost_attributes_ips,
    public.netzone_attributes,
    public.netzone
  WHERE ((netzone.ikey = netzone_attributes.okey) AND (netzone_attributes.attr = 'netExclude'::text) AND ((nethost_attributes_ips.value)::inet <<= (netzone_attributes.value)::inet));


--
-- Name: nethost_attributes_read; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.nethost_attributes_read AS
 SELECT nethost_attributes.value,
    nethost_attributes.attr,
    nethost_attributes.attr_key,
    nethost_attributes.okey
   FROM public.nethost_attributes
UNION
 SELECT nethost_attributes_netzone.value,
    nethost_attributes_netzone.attr,
    nethost_attributes_netzone.attr_key,
    nethost_attributes_netzone.okey
   FROM public.nethost_attributes_netzone;


--
-- Name: nethost_attributes_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.nethost_attributes_users (
)
INHERITS (public.nethost_attributes);


--
-- Name: netzone_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.netzone_attributes_list (
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass),
    canonical text,
    description text
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: netzone_attributes_netzone; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.netzone_attributes_netzone (
)
INHERITS (public.netzone_attributes);


--
-- Name: netzone_attributes_site; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.netzone_attributes_site (
)
INHERITS (public.netzone_attributes);


--
-- Name: objectslogs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.objectslogs (
    logkey bigint NOT NULL,
    ikey bigint NOT NULL,
    otype text NOT NULL,
    name text NOT NULL,
    changetype text NOT NULL,
    username text NOT NULL,
    message text NOT NULL,
    logdate timestamp with time zone DEFAULT now() NOT NULL,
    irev bigint
);


--
-- Name: objectlogs_logkey_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.objectlogs_logkey_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: objectlogs_logkey_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.objectlogs_logkey_seq OWNED BY public.objectslogs.logkey;


--
-- Name: objects_table; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.objects_table AS
 SELECT objects.rev,
    objects.date,
    objects."create",
    objects.ikey,
    pg_class.relname,
    objects.name,
    objects.exported
   FROM (public.objects
     JOIN pg_class ON ((objects.tableoid = pg_class.oid)));


--
-- Name: passwordreset; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.passwordreset (
    "user" text NOT NULL,
    id text NOT NULL
)
INHERITS (public.revisions);


--
-- Name: request; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.request (
    id integer NOT NULL,
    "create" timestamp with time zone DEFAULT now() NOT NULL,
    name text NOT NULL,
    object text,
    apply timestamp with time zone DEFAULT now() NOT NULL,
    done timestamp with time zone,
    "user" text,
    applied boolean,
    reason text,
    automated boolean DEFAULT false NOT NULL,
    objrev bigint
);


--
-- Name: request_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.request_attributes (
    reqid bigint,
    attribute text NOT NULL,
    value text
);


--
-- Name: request_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.request_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: request_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.request_id_seq OWNED BY public.request.id;


--
-- Name: revaliases; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.revaliases (
    "as" text NOT NULL,
    description text
)
INHERITS (public.objects);


--
-- Name: revisions_table; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.revisions_table AS
 SELECT revisions.rev,
    revisions.date,
    revisions."create",
    revisions.ikey,
    pg_class.relname
   FROM (public.revisions
     JOIN pg_class ON ((revisions.tableoid = pg_class.oid)));


--
-- Name: service; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.service (
    start date,
    "end" date
)
INHERITS (public.objects);


--
-- Name: service_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.service_attributes (
)
INHERITS (public.attributes);


--
-- Name: service_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.service_attributes_list (
    ikey integer DEFAULT nextval('public.ikey_seq'::regclass),
    canonical text,
    description text
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: service_attributes_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.service_attributes_users (
)
INHERITS (public.service_attributes);


--
-- Name: settings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.settings (
    varname text NOT NULL,
    val text
)
INHERITS (public.revisions);


--
-- Name: site; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.site (
    name text
)
INHERITS (public.objects);


--
-- Name: site_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.site_attributes (
)
INHERITS (public.attributes);


--
-- Name: site_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.site_attributes_list (
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: stat; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.stat (
    name text
)
INHERITS (public.objects);


--
-- Name: stat_attributes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.stat_attributes (
)
INHERITS (public.attributes);


--
-- Name: stat_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.stat_attributes_list (
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: statsentry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.statsentry (
    okey integer NOT NULL,
    id bigint DEFAULT nextval('public.revisions_rev_seq'::regclass) NOT NULL,
    tstamp timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: statvalues; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.statvalues (
    sid bigint NOT NULL,
    value text NOT NULL,
    count bigint NOT NULL
);


--
-- Name: su_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.su_type (
    name text,
    description text
)
INHERITS (public.objects);


--
-- Name: user_attributes; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.user_attributes AS
 SELECT ("user".uidnumber)::text AS value,
    'uidnumber'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
UNION ALL
 SELECT ("user".gidnumber)::text AS value,
    'gidnumber'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
UNION ALL
 SELECT "user".name AS value,
    'name'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
UNION ALL
 SELECT ("user".expire)::text AS value,
    'expire'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
  WHERE ("user".expire IS NOT NULL)
UNION ALL
 SELECT '1'::text AS value,
    'exported'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
  WHERE ("user".exported = true)
UNION ALL
 SELECT address_attributes_site.value,
    'allsite'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM ((public."user"
     JOIN public.address ON ((address."user" = "user".name)))
     JOIN public.address_attributes_site ON ((address_attributes_site.okey = address.ikey)))
  WHERE ((address_attributes_site.attr = 'site'::text) AND (address.exported = true))
UNION ALL
 SELECT "group".name AS value,
    'memberOf'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM ((public."user"
     JOIN public.group_attributes ON ((group_attributes.value = "user".name)))
     JOIN public."group" ON ((group_attributes.okey = "group".ikey)))
  WHERE (group_attributes.attr = 'memberUID'::text)
UNION ALL
 SELECT user_attributes.value,
    user_attributes.attr,
    user_attributes.attr_key,
    user_attributes.okey
   FROM public.user_attributes_base user_attributes
UNION ALL
 SELECT "group".name AS value,
    'departments'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM (((public."group"
     JOIN public.group_attributes_sutypes ON (("group".ikey = group_attributes_sutypes.okey)))
     JOIN public.group_attributes_users ON ((("group".ikey = group_attributes_users.okey) AND (group_attributes_users.attr = 'memberUID'::text))))
     JOIN public."user" ON (("user".name = group_attributes_users.value)))
  WHERE ((group_attributes_sutypes.value = 'dpmt'::text) AND (group_attributes_sutypes.attr = 'sutype'::text))
UNION ALL
 SELECT "group".name AS value,
    'cells'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM (((public."group"
     JOIN public.group_attributes_sutypes ON (("group".ikey = group_attributes_sutypes.okey)))
     JOIN public.group_attributes_users ON ((("group".ikey = group_attributes_users.okey) AND (group_attributes_users.attr = 'memberUID'::text))))
     JOIN public."user" ON (("user".name = group_attributes_users.value)))
  WHERE ((group_attributes_sutypes.value = 'cell'::text) AND (group_attributes_sutypes.attr = 'sutype'::text))
UNION ALL
 SELECT "group".name AS value,
    'managedObjects'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM ((public."user"
     JOIN public.group_attributes ON ((group_attributes.value = "user".name)))
     JOIN public."group" ON ((group_attributes.okey = "group".ikey)))
  WHERE (group_attributes.attr = 'managedBy'::text)
UNION ALL
 SELECT (justify_interval((now() - "user".expire)))::text AS value,
    'expired'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
  WHERE ("user".expire <= now())
UNION ALL
 SELECT (1)::text AS value,
    'active'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
  WHERE ((("user".expire IS NULL) OR ("user".expire >= now())) AND ("user".exported = true))
UNION ALL
 SELECT (0)::text AS value,
    'active'::text AS attr,
    "user".rev AS attr_key,
    "user".ikey AS okey
   FROM public."user"
  WHERE ((("user".expire IS NOT NULL) AND ("user".expire <= now())) OR ("user".exported = false));


--
-- Name: user_attributes_groups; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_attributes_groups (
)
INHERITS (public.user_attributes_base);


--
-- Name: user_attributes_list; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_attributes_list (
)
INHERITS (public.revisions, public.attributes_list);


--
-- Name: user_attributes_site; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_attributes_site (
)
INHERITS (public.user_attributes_base);


--
-- Name: user_attributes_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_attributes_users (
)
INHERITS (public.user_attributes_base);


--
-- Name: accreq rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: accreq date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN date SET DEFAULT now();


--
-- Name: accreq create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: accreq ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: accreq exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN exported SET DEFAULT true;


--
-- Name: accreq internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: accreq nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: accreq_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: address rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: address date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN date SET DEFAULT now();


--
-- Name: address create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: address ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: address exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN exported SET DEFAULT true;


--
-- Name: address internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: address nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: address_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: address_attributes_base attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_base ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: address_attributes_list ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: address_attributes_list_site ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list_site ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: address_attributes_list_site rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list_site ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: address_attributes_list_site date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list_site ALTER COLUMN date SET DEFAULT now();


--
-- Name: address_attributes_list_site create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list_site ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: address_attributes_site attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_site ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: aliases rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: aliases date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN date SET DEFAULT now();


--
-- Name: aliases create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: aliases ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: aliases exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN exported SET DEFAULT true;


--
-- Name: aliases internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: aliases nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: aliases_attributes_base attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_base ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: aliases_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: aliases_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: aliases_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: attributes_values rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes_values ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: attributes_values date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes_values ALTER COLUMN date SET DEFAULT now();


--
-- Name: attributes_values create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes_values ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: attributes_values ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes_values ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: employment rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: employment date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN date SET DEFAULT now();


--
-- Name: employment create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: employment ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: employment exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN exported SET DEFAULT true;


--
-- Name: employment internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: employment nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: employment_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: employment_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: employment_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: employment_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: employment_attributes_list ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes_list ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: group rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: group date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN date SET DEFAULT now();


--
-- Name: group create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: group ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: group exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN exported SET DEFAULT true;


--
-- Name: group internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: group nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group" ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: group_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: group_attributes_base attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_base ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: group_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: group_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: group_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: group_attributes_list ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_list ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: group_attributes_sutypes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_sutypes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: group_attributes_users attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_users ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: nethost rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: nethost date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN date SET DEFAULT now();


--
-- Name: nethost create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: nethost ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: nethost exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN exported SET DEFAULT true;


--
-- Name: nethost internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: nethost nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: nethost_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: nethost_attributes_ips attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_ips ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: nethost_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: nethost_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: nethost_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: nethost_attributes_macs attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_macs ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: nethost_attributes_nethosts attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_nethosts ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: nethost_attributes_users attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_users ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: netzone rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: netzone date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN date SET DEFAULT now();


--
-- Name: netzone create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: netzone ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: netzone exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN exported SET DEFAULT true;


--
-- Name: netzone internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: netzone nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: netzone_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: netzone_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: netzone_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: netzone_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: netzone_attributes_netzone attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_netzone ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: netzone_attributes_site attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_site ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: objects rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objects ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: objects date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objects ALTER COLUMN date SET DEFAULT now();


--
-- Name: objects create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objects ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: objects ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objects ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: objectslogs logkey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objectslogs ALTER COLUMN logkey SET DEFAULT nextval('public.objectlogs_logkey_seq'::regclass);


--
-- Name: passwordreset rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.passwordreset ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: passwordreset date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.passwordreset ALTER COLUMN date SET DEFAULT now();


--
-- Name: passwordreset create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.passwordreset ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: passwordreset ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.passwordreset ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: request id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.request ALTER COLUMN id SET DEFAULT nextval('public.request_id_seq'::regclass);


--
-- Name: revaliases rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: revaliases date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN date SET DEFAULT now();


--
-- Name: revaliases create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: revaliases ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: revaliases exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN exported SET DEFAULT true;


--
-- Name: revaliases internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: revaliases nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: revisions rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revisions ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: service rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: service date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN date SET DEFAULT now();


--
-- Name: service create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: service ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: service exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN exported SET DEFAULT true;


--
-- Name: service internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: service nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: service_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: service_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: service_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: service_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: service_attributes_users attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_users ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: settings rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settings ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: settings date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settings ALTER COLUMN date SET DEFAULT now();


--
-- Name: settings create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settings ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: settings ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settings ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: site rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: site date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN date SET DEFAULT now();


--
-- Name: site create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: site ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: site exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN exported SET DEFAULT true;


--
-- Name: site internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: site nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: site_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: site_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: site_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: site_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: site_attributes_list ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes_list ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: stat rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: stat date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN date SET DEFAULT now();


--
-- Name: stat create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: stat ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: stat exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN exported SET DEFAULT true;


--
-- Name: stat internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: stat nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: stat_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: stat_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: stat_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: stat_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: stat_attributes_list ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes_list ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: su_type rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: su_type date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN date SET DEFAULT now();


--
-- Name: su_type create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: su_type ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: su_type exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN exported SET DEFAULT true;


--
-- Name: su_type internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: su_type nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: user rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: user date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN date SET DEFAULT now();


--
-- Name: user create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: user ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: user exported; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN exported SET DEFAULT true;


--
-- Name: user internobject; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN internobject SET DEFAULT false;


--
-- Name: user nodelete; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user" ALTER COLUMN nodelete SET DEFAULT false;


--
-- Name: user_attributes attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: user_attributes_base attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_base ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: user_attributes_groups attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_groups ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: user_attributes_list rev; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_list ALTER COLUMN rev SET DEFAULT nextval('public.revisions_rev_seq'::regclass);


--
-- Name: user_attributes_list date; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_list ALTER COLUMN date SET DEFAULT now();


--
-- Name: user_attributes_list create; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_list ALTER COLUMN "create" SET DEFAULT now();


--
-- Name: user_attributes_list ikey; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_list ALTER COLUMN ikey SET DEFAULT nextval('public.ikey_seq'::regclass);


--
-- Name: user_attributes_site attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_site ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: user_attributes_users attr_key; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_users ALTER COLUMN attr_key SET DEFAULT nextval('public.attributes_attr_key_seq'::regclass);


--
-- Name: accreq_attributes_list acccreq_attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq_attributes_list
    ADD CONSTRAINT acccreq_attributes_list_pkey PRIMARY KEY (canonical);


--
-- Name: accreq_attributes accreq_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq_attributes
    ADD CONSTRAINT accreq_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: accreq accreq_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq
    ADD CONSTRAINT accreq_ikey_uniq UNIQUE (ikey);


--
-- Name: accreq accreq_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq
    ADD CONSTRAINT accreq_pkey PRIMARY KEY (name);


--
-- Name: address_attributes_base address_attr_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_base
    ADD CONSTRAINT address_attr_pkey PRIMARY KEY (attr_key);


--
-- Name: address_attributes_site address_attr_site_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_site
    ADD CONSTRAINT address_attr_site_pkey PRIMARY KEY (attr_key);


--
-- Name: address_attributes_list address_attributes_list_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list
    ADD CONSTRAINT address_attributes_list_c_uniq UNIQUE (canonical);


--
-- Name: address_attributes_list address_attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list
    ADD CONSTRAINT address_attributes_list_pkey PRIMARY KEY (ikey);


--
-- Name: address_attributes_list_site address_attributes_list_site_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list_site
    ADD CONSTRAINT address_attributes_list_site_c_uniq UNIQUE (canonical);


--
-- Name: address_attributes_list_site address_attributes_list_site_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_list_site
    ADD CONSTRAINT address_attributes_list_site_pkey PRIMARY KEY (ikey);


--
-- Name: address address_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT address_ikey_uniq UNIQUE (ikey);


--
-- Name: address address_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT address_pkey PRIMARY KEY (name);


--
-- Name: aliases_attributes_base aliases_attributes_base_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_base
    ADD CONSTRAINT aliases_attributes_base_pkey PRIMARY KEY (attr_key);


--
-- Name: aliases_attributes_list aliases_attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_list
    ADD CONSTRAINT aliases_attributes_list_pkey PRIMARY KEY (ikey);


--
-- Name: aliases aliases_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases
    ADD CONSTRAINT aliases_ikey_uniq UNIQUE (ikey);


--
-- Name: aliases aliases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases
    ADD CONSTRAINT aliases_pkey PRIMARY KEY (name);


--
-- Name: attributes_list attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes_list
    ADD CONSTRAINT attributes_list_pkey PRIMARY KEY (ikey);


--
-- Name: attributes attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes
    ADD CONSTRAINT attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: attributes_values attributes_values_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.attributes_values
    ADD CONSTRAINT attributes_values_pkey PRIMARY KEY (ikey);


--
-- Name: employment_attributes_list employment_attr_l_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes_list
    ADD CONSTRAINT employment_attr_l_c_uniq UNIQUE (canonical);


--
-- Name: employment_attributes_list employment_attr_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes_list
    ADD CONSTRAINT employment_attr_list_pkey PRIMARY KEY (ikey);


--
-- Name: employment_attributes employment_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes
    ADD CONSTRAINT employment_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: employment employment_okey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment
    ADD CONSTRAINT employment_okey_uniq UNIQUE (ikey);


--
-- Name: employment employment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment
    ADD CONSTRAINT employment_pkey PRIMARY KEY (name);


--
-- Name: aliases_attributes_list g_attr_l_aliases_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_list
    ADD CONSTRAINT g_attr_l_aliases_uniq UNIQUE (canonical);


--
-- Name: group_attributes_list g_attr_l_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_list
    ADD CONSTRAINT g_attr_l_c_uniq UNIQUE (canonical);


--
-- Name: nethost_attributes_list g_attr_l_nethost_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_list
    ADD CONSTRAINT g_attr_l_nethost_uniq UNIQUE (canonical);


--
-- Name: netzone_attributes_list g_attr_l_netzone_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_list
    ADD CONSTRAINT g_attr_l_netzone_uniq UNIQUE (canonical);


--
-- Name: service_attributes_list g_attr_l_service_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_list
    ADD CONSTRAINT g_attr_l_service_uniq UNIQUE (canonical);


--
-- Name: group_attributes_list g_attr_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_list
    ADD CONSTRAINT g_attr_list_pkey PRIMARY KEY (ikey);


--
-- Name: group goup_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group"
    ADD CONSTRAINT goup_pkey PRIMARY KEY (name);


--
-- Name: group_attributes_base group_attrbutes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_base
    ADD CONSTRAINT group_attrbutes_pkey PRIMARY KEY (attr_key);


--
-- Name: group_attributes_sutypes group_attributes_sutypes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_sutypes
    ADD CONSTRAINT group_attributes_sutypes_pkey PRIMARY KEY (attr_key);


--
-- Name: group_attributes_users group_attributes_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_users
    ADD CONSTRAINT group_attributes_user_pkey PRIMARY KEY (attr_key);


--
-- Name: group_attributes_users group_attributes_users_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_users
    ADD CONSTRAINT group_attributes_users_uniq UNIQUE (okey, attr, value);


--
-- Name: group group_gid_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group"
    ADD CONSTRAINT group_gid_uniq UNIQUE (gidnumber);


--
-- Name: group group_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."group"
    ADD CONSTRAINT group_ikey_uniq UNIQUE (ikey);


--
-- Name: nethost_attributes_ips nethost_attributes_ip_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_ips
    ADD CONSTRAINT nethost_attributes_ip_pkey PRIMARY KEY (attr_key);


--
-- Name: nethost_attributes_list nethost_attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_list
    ADD CONSTRAINT nethost_attributes_list_pkey PRIMARY KEY (ikey);


--
-- Name: nethost_attributes_macs nethost_attributes_mac_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_macs
    ADD CONSTRAINT nethost_attributes_mac_pkey PRIMARY KEY (attr_key);


--
-- Name: nethost_attributes_nethosts nethost_attributes_nethosts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_nethosts
    ADD CONSTRAINT nethost_attributes_nethosts_pkey PRIMARY KEY (attr_key);


--
-- Name: nethost_attributes nethost_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes
    ADD CONSTRAINT nethost_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: nethost_attributes_users nethost_attributes_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_users
    ADD CONSTRAINT nethost_attributes_user_pkey PRIMARY KEY (attr_key);


--
-- Name: nethost_attributes_users nethost_attributes_users_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_users
    ADD CONSTRAINT nethost_attributes_users_uniq UNIQUE (okey, attr, value);


--
-- Name: nethost nethost_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost
    ADD CONSTRAINT nethost_ikey_uniq UNIQUE (ikey);


--
-- Name: nethost nethost_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost
    ADD CONSTRAINT nethost_pkey PRIMARY KEY (name);


--
-- Name: netzone_attributes_netzone netzone_attr_netzone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_netzone
    ADD CONSTRAINT netzone_attr_netzone_pkey PRIMARY KEY (attr_key);


--
-- Name: netzone_attributes_site netzone_attr_site_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_site
    ADD CONSTRAINT netzone_attr_site_pkey PRIMARY KEY (attr_key);


--
-- Name: netzone_attributes_list netzone_attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_list
    ADD CONSTRAINT netzone_attributes_list_pkey PRIMARY KEY (ikey);


--
-- Name: netzone_attributes netzone_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes
    ADD CONSTRAINT netzone_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: netzone netzone_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone
    ADD CONSTRAINT netzone_ikey_uniq UNIQUE (ikey);


--
-- Name: netzone netzone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone
    ADD CONSTRAINT netzone_pkey PRIMARY KEY (name);


--
-- Name: objectslogs objectlogs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objectslogs
    ADD CONSTRAINT objectlogs_pkey PRIMARY KEY (logkey);


--
-- Name: objects objects_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.objects
    ADD CONSTRAINT objects_pkey PRIMARY KEY (ikey);


--
-- Name: user_attributes_list p_attr_l_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_list
    ADD CONSTRAINT p_attr_l_c_uniq UNIQUE (canonical);


--
-- Name: user_attributes_list p_attr_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_list
    ADD CONSTRAINT p_attr_list_pkey PRIMARY KEY (ikey);


--
-- Name: passwordreset passwordreset_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.passwordreset
    ADD CONSTRAINT passwordreset_pkey PRIMARY KEY (id);


--
-- Name: user person_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT person_pkey PRIMARY KEY (name);


--
-- Name: user person_uid_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT person_uid_key UNIQUE (uidnumber);


--
-- Name: request request_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.request
    ADD CONSTRAINT request_pkey PRIMARY KEY (id);


--
-- Name: revaliases revaliases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases
    ADD CONSTRAINT revaliases_pkey PRIMARY KEY (name);


--
-- Name: revisions revisions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revisions
    ADD CONSTRAINT revisions_pkey PRIMARY KEY (ikey);


--
-- Name: site_attributes_list s_attr_l_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes_list
    ADD CONSTRAINT s_attr_l_c_uniq UNIQUE (canonical);


--
-- Name: site_attributes_list s_attr_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes_list
    ADD CONSTRAINT s_attr_list_pkey PRIMARY KEY (ikey);


--
-- Name: service_attributes_list service_attributes_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_list
    ADD CONSTRAINT service_attributes_list_pkey PRIMARY KEY (ikey);


--
-- Name: service_attributes service_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes
    ADD CONSTRAINT service_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: service_attributes_users service_attributes_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_users
    ADD CONSTRAINT service_attributes_user_pkey PRIMARY KEY (attr_key);


--
-- Name: service_attributes_users service_attributes_users_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_users
    ADD CONSTRAINT service_attributes_users_uniq UNIQUE (okey, attr, value);


--
-- Name: service service_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service
    ADD CONSTRAINT service_ikey_uniq UNIQUE (ikey);


--
-- Name: service service_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service
    ADD CONSTRAINT service_pkey PRIMARY KEY (name);


--
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.settings
    ADD CONSTRAINT settings_pkey PRIMARY KEY (varname);


--
-- Name: site_attributes site_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes
    ADD CONSTRAINT site_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: site site_okey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site
    ADD CONSTRAINT site_okey_uniq UNIQUE (ikey);


--
-- Name: site site_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site
    ADD CONSTRAINT site_pkey PRIMARY KEY (name);


--
-- Name: stat_attributes_list stat_attr_l_c_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes_list
    ADD CONSTRAINT stat_attr_l_c_uniq UNIQUE (canonical);


--
-- Name: stat_attributes_list stat_attr_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes_list
    ADD CONSTRAINT stat_attr_list_pkey PRIMARY KEY (ikey);


--
-- Name: stat_attributes stat_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes
    ADD CONSTRAINT stat_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: stat stat_okey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat
    ADD CONSTRAINT stat_okey_uniq UNIQUE (ikey);


--
-- Name: stat stat_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat
    ADD CONSTRAINT stat_pkey PRIMARY KEY (name);


--
-- Name: statsentry statsentry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.statsentry
    ADD CONSTRAINT statsentry_pkey PRIMARY KEY (id);


--
-- Name: statvalues statvalues_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.statvalues
    ADD CONSTRAINT statvalues_pkey PRIMARY KEY (sid, value);


--
-- Name: su_type su_type_name_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type
    ADD CONSTRAINT su_type_name_uniq UNIQUE (name);


--
-- Name: su_type su_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.su_type
    ADD CONSTRAINT su_type_pkey PRIMARY KEY (ikey);


--
-- Name: user_attributes_groups user_attr_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_groups
    ADD CONSTRAINT user_attr_groups_pkey PRIMARY KEY (attr_key);


--
-- Name: user_attributes_site user_attr_site_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_site
    ADD CONSTRAINT user_attr_site_pkey PRIMARY KEY (attr_key);


--
-- Name: user_attributes_users user_attr_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_users
    ADD CONSTRAINT user_attr_user_pkey PRIMARY KEY (attr_key);


--
-- Name: user_attributes_base user_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_base
    ADD CONSTRAINT user_attributes_pkey PRIMARY KEY (attr_key);


--
-- Name: user user_ikey_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."user"
    ADD CONSTRAINT user_ikey_uniq UNIQUE (ikey);


--
-- Name: address_attr_base_attr_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX address_attr_base_attr_idx ON public.address_attributes_base USING btree (attr);


--
-- Name: address_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX address_exported_idx ON public.address USING btree (exported);


--
-- Name: aliases_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX aliases_attr_value_idx ON public.aliases_attributes_base USING btree (value);


--
-- Name: aliases_attributes_base_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX aliases_attributes_base_attr_fkey ON public.aliases_attributes_base USING btree (attr);


--
-- Name: aliases_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX aliases_exported_idx ON public.aliases USING btree (exported);


--
-- Name: aliases_forwards_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX aliases_forwards_idx ON public.aliases USING gin (forward);


--
-- Name: aliases_name_lower_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX aliases_name_lower_idx ON public.aliases USING btree (lower(name));


--
-- Name: aliases_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX aliases_rev_idx ON public.aliases USING btree (rev);


--
-- Name: attributes_values_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX attributes_values_idx ON public.attributes_values USING btree (otype, attributes, value);


--
-- Name: employment_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX employment_attr_value_idx ON public.employment_attributes USING btree (value);


--
-- Name: employment_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX employment_attributes_attr_fkey ON public.employment_attributes USING btree (attr);


--
-- Name: employment_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX employment_exported_idx ON public.employment USING btree (exported);


--
-- Name: employment_firstday_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX employment_firstday_idx ON public.employment USING btree (firstday NULLS FIRST);


--
-- Name: employment_lastday_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX employment_lastday_idx ON public.employment USING btree (lastday);


--
-- Name: employment_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX employment_rev_idx ON public.employment USING btree (rev);


--
-- Name: fki_accreq_attr_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_accreq_attr_okey_fkey ON public.accreq_attributes USING btree (okey);


--
-- Name: fki_accreq_attributes_list_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_accreq_attributes_list_attr_fkey ON public.accreq_attributes USING btree (attr);


--
-- Name: fki_address_attr_site_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_address_attr_site_okey_fkey ON public.address_attributes_site USING btree (okey);


--
-- Name: fki_address_attributes_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_address_attributes_okey_fkey ON public.address_attributes_base USING btree (okey);


--
-- Name: fki_address_attributes_site_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_address_attributes_site_attr_fkey ON public.address_attributes_site USING btree (attr);


--
-- Name: fki_address_attributes_site_value_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_address_attributes_site_value_fkey ON public.address_attributes_site USING btree (value);


--
-- Name: fki_address_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_address_user_fkey ON public.address USING btree ("user");


--
-- Name: fki_employment; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_employment ON public.employment_attributes USING btree (okey);


--
-- Name: fki_group_attr_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attr_okey_fkey ON public.group_attributes_base USING btree (okey);


--
-- Name: fki_group_attr_sutypes_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attr_sutypes_okey_fkey ON public.group_attributes_sutypes USING btree (okey);


--
-- Name: fki_group_attr_users_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attr_users_okey_fkey ON public.group_attributes_users USING btree (okey);


--
-- Name: fki_group_attributes_sutypes_attr; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attributes_sutypes_attr ON public.group_attributes_sutypes USING btree (attr);


--
-- Name: fki_group_attributes_sutypes_sutype_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attributes_sutypes_sutype_fkey ON public.group_attributes_sutypes USING btree (value);


--
-- Name: fki_group_attributes_users_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attributes_users_attr_fkey ON public.group_attributes_users USING btree (attr);


--
-- Name: fki_group_attributes_users_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_group_attributes_users_user_fkey ON public.group_attributes_users USING btree (value);


--
-- Name: fki_nethost_attr_ip_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attr_ip_fkey ON public.nethost_attributes_ips USING btree (okey);


--
-- Name: fki_nethost_attr_mac_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attr_mac_fkey ON public.nethost_attributes_macs USING btree (okey);


--
-- Name: fki_nethost_attr_nethosts_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attr_nethosts_fkey ON public.nethost_attributes_nethosts USING btree (okey);


--
-- Name: fki_nethost_attr_users_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attr_users_okey_fkey ON public.nethost_attributes_users USING btree (okey);


--
-- Name: fki_nethost_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attributes_attr_fkey ON public.nethost_attributes USING btree (attr);


--
-- Name: fki_nethost_attributes_users_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attributes_users_attr_fkey ON public.nethost_attributes_users USING btree (attr);


--
-- Name: fki_nethost_attributes_users_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_nethost_attributes_users_user_fkey ON public.nethost_attributes_users USING btree (value);


--
-- Name: fki_netzone_attr_netzone_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attr_netzone_okey_fkey ON public.netzone_attributes_netzone USING btree (okey);


--
-- Name: fki_netzone_attr_site_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attr_site_okey_fkey ON public.netzone_attributes_site USING btree (okey);


--
-- Name: fki_netzone_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attributes_attr_fkey ON public.netzone_attributes USING btree (attr);


--
-- Name: fki_netzone_attributes_netzone_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attributes_netzone_attr_fkey ON public.netzone_attributes_netzone USING btree (attr);


--
-- Name: fki_netzone_attributes_netzone_value_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attributes_netzone_value_fkey ON public.netzone_attributes_netzone USING btree (value);


--
-- Name: fki_netzone_attributes_site_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attributes_site_attr_fkey ON public.netzone_attributes_site USING btree (attr);


--
-- Name: fki_netzone_attributes_site_value_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_netzone_attributes_site_value_fkey ON public.netzone_attributes_site USING btree (value);


--
-- Name: fki_request_id_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_request_id_fkey ON public.request_attributes USING btree (reqid);


--
-- Name: fki_request_name_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_request_name_fkey ON public.request USING btree (name);


--
-- Name: fki_request_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_request_user_fkey ON public.request USING btree ("user");


--
-- Name: fki_revaliase_name_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_revaliase_name_user_fkey ON public.revaliases USING btree (name);


--
-- Name: fki_revaliases_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_revaliases_user_fkey ON public.revaliases USING btree (name);


--
-- Name: fki_service_attr_users_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_service_attr_users_okey_fkey ON public.service_attributes_users USING btree (okey);


--
-- Name: fki_service_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_service_attributes_attr_fkey ON public.nethost_attributes USING btree (attr);


--
-- Name: fki_service_attributes_users_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_service_attributes_users_attr_fkey ON public.service_attributes_users USING btree (attr);


--
-- Name: fki_service_attributes_users_user_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_service_attributes_users_user_fkey ON public.service_attributes_users USING btree (value);


--
-- Name: fki_site_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_site_attributes_attr_fkey ON public.site_attributes USING btree (attr);


--
-- Name: fki_user_attr_groups_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attr_groups_okey_fkey ON public.user_attributes_groups USING btree (okey);


--
-- Name: fki_user_attr_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attr_okey_fkey ON public.user_attributes_base USING btree (okey);


--
-- Name: fki_user_attr_site_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attr_site_okey_fkey ON public.user_attributes_site USING btree (okey);


--
-- Name: fki_user_attr_users_okey_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attr_users_okey_fkey ON public.user_attributes_users USING btree (okey);


--
-- Name: fki_user_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_attr_fkey ON public.user_attributes_base USING btree (attr);


--
-- Name: fki_user_attributes_groups_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_groups_attr_fkey ON public.user_attributes_groups USING btree (attr);


--
-- Name: fki_user_attributes_groups_value_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_groups_value_fkey ON public.user_attributes_groups USING btree (value);


--
-- Name: fki_user_attributes_site_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_site_attr_fkey ON public.user_attributes_site USING btree (attr);


--
-- Name: fki_user_attributes_site_value_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_site_value_fkey ON public.user_attributes_site USING btree (value);


--
-- Name: fki_user_attributes_users_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_users_attr_fkey ON public.user_attributes_users USING btree (attr);


--
-- Name: fki_user_attributes_users_value_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX fki_user_attributes_users_value_fkey ON public.user_attributes_users USING btree (value);


--
-- Name: group_attributes_base_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX group_attributes_base_value_idx ON public.group_attributes_base USING btree (value);


--
-- Name: group_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX group_exported_idx ON public."group" USING btree (exported);


--
-- Name: group_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX group_rev_idx ON public."group" USING btree (rev);


--
-- Name: nethost_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX nethost_attr_value_idx ON public.nethost_attributes USING btree (value);


--
-- Name: nethost_attributes_ip_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX nethost_attributes_ip_idx ON public.nethost_attributes_ips USING btree (((value)::inet));


--
-- Name: nethost_attributes_mac_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX nethost_attributes_mac_idx ON public.nethost_attributes_macs USING btree (((value)::macaddr));


--
-- Name: nethost_cname_uniq_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX nethost_cname_uniq_idx ON public.nethost_attributes USING btree (value, okey) WHERE (attr = 'cname'::text);


--
-- Name: netzone_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX netzone_attr_value_idx ON public.netzone_attributes USING btree (value);


--
-- Name: netzone_attributes_net_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX netzone_attributes_net_idx ON public.netzone_attributes USING btree (((value)::inet), attr, okey) WHERE (attr = 'net'::text);


--
-- Name: netzone_attributes_netexclude_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX netzone_attributes_netexclude_idx ON public.netzone_attributes USING btree (((value)::inet), attr, okey) WHERE (attr = 'netExclude'::text);


--
-- Name: objectlogs_name_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX objectlogs_name_idx ON public.objectslogs USING btree (name);


--
-- Name: objectslogs_ikey_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX objectslogs_ikey_idx ON public.objectslogs USING btree (ikey);


--
-- Name: objectslogs_otype_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX objectslogs_otype_idx ON public.objectslogs USING btree (otype);


--
-- Name: person_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX person_rev_idx ON public."user" USING btree (rev);


--
-- Name: revaliases_as_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX revaliases_as_idx ON public.revaliases USING btree ("as");


--
-- Name: revaliases_as_lower_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX revaliases_as_lower_idx ON public.revaliases USING btree (lower("as"));


--
-- Name: revaliases_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX revaliases_exported_idx ON public.revaliases USING btree (exported);


--
-- Name: revaliases_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX revaliases_rev_idx ON public.revaliases USING btree (rev);


--
-- Name: service_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX service_attr_value_idx ON public.nethost_attributes USING btree (value);


--
-- Name: site_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX site_attr_value_idx ON public.site_attributes USING btree (value);


--
-- Name: site_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX site_exported_idx ON public.site USING btree (exported);


--
-- Name: site_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX site_rev_idx ON public.site USING btree (rev);


--
-- Name: stat_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stat_attr_value_idx ON public.stat_attributes USING btree (value);


--
-- Name: stat_attributes_attr_fkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stat_attributes_attr_fkey ON public.stat_attributes USING btree (attr);


--
-- Name: stat_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stat_exported_idx ON public.stat USING btree (exported);


--
-- Name: stat_rev_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX stat_rev_idx ON public.stat USING btree (rev);


--
-- Name: user_attr_value_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX user_attr_value_idx ON public.user_attributes_base USING btree (value);


--
-- Name: user_expire_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX user_expire_idx ON public."user" USING btree (expire);


--
-- Name: user_exported_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX user_exported_idx ON public."user" USING btree (exported);


--
-- Name: address_attributes address_attributes_insert; Type: RULE; Schema: public; Owner: -
--

CREATE RULE address_attributes_insert AS
    ON INSERT TO public.address_attributes DO INSTEAD  INSERT INTO public.address_attributes_base (value, attr, attr_key, okey)
  VALUES (new.value, new.attr, new.attr_key, new.okey);


--
-- Name: address_attributes address_attributes_update; Type: RULE; Schema: public; Owner: -
--

CREATE RULE address_attributes_update AS
    ON UPDATE TO public.address_attributes DO INSTEAD  UPDATE public.address_attributes_base SET value = new.value, attr = new.attr, attr_key = new.attr_key, okey = new.okey
  WHERE ((address_attributes_base.attr_key = old.attr_key) AND (address_attributes_base.attr = old.attr));


--
-- Name: address_attributes address_atttributes_delete; Type: RULE; Schema: public; Owner: -
--

CREATE RULE address_atttributes_delete AS
    ON DELETE TO public.address_attributes DO INSTEAD  DELETE FROM public.address_attributes_base
  WHERE ((address_attributes_base.attr_key = old.attr_key) AND (address_attributes_base.attr = old.attr));


--
-- Name: aliases_attributes aliases_attributes_insert; Type: RULE; Schema: public; Owner: -
--

CREATE RULE aliases_attributes_insert AS
    ON INSERT TO public.aliases_attributes DO INSTEAD  INSERT INTO public.aliases_attributes_base (value, attr, okey)
  VALUES (new.value, new.attr, new.okey);


--
-- Name: aliases_attributes aliases_attributes_update; Type: RULE; Schema: public; Owner: -
--

CREATE RULE aliases_attributes_update AS
    ON UPDATE TO public.aliases_attributes DO INSTEAD  UPDATE public.aliases_attributes_base SET value = new.value, attr = new.attr, attr_key = new.attr_key, okey = new.okey
  WHERE ((aliases_attributes_base.attr_key = old.attr_key) AND (aliases_attributes_base.attr = old.attr));


--
-- Name: aliases_attributes aliases_atttributes_delete; Type: RULE; Schema: public; Owner: -
--

CREATE RULE aliases_atttributes_delete AS
    ON DELETE TO public.aliases_attributes DO INSTEAD  DELETE FROM public.aliases_attributes_base
  WHERE ((aliases_attributes_base.attr_key = old.attr_key) AND (aliases_attributes_base.attr = old.attr));


--
-- Name: group_attributes group_attributes_insert; Type: RULE; Schema: public; Owner: -
--

CREATE RULE group_attributes_insert AS
    ON INSERT TO public.group_attributes DO INSTEAD  INSERT INTO public.group_attributes_base (value, attr, attr_key, okey)
  VALUES (new.value, new.attr, new.attr_key, new.okey);


--
-- Name: group_attributes group_attributes_update; Type: RULE; Schema: public; Owner: -
--

CREATE RULE group_attributes_update AS
    ON UPDATE TO public.group_attributes DO INSTEAD  UPDATE public.group_attributes_base SET value = new.value, attr = new.attr, attr_key = new.attr_key, okey = new.okey
  WHERE ((group_attributes_base.attr_key = old.attr_key) AND (group_attributes_base.attr = old.attr));


--
-- Name: group_attributes group_atttributes_delete; Type: RULE; Schema: public; Owner: -
--

CREATE RULE group_atttributes_delete AS
    ON DELETE TO public.group_attributes DO INSTEAD  DELETE FROM public.group_attributes_base
  WHERE ((group_attributes_base.attr_key = old.attr_key) AND (group_attributes_base.attr = old.attr));


--
-- Name: user_attributes user_attributes_insert; Type: RULE; Schema: public; Owner: -
--

CREATE RULE user_attributes_insert AS
    ON INSERT TO public.user_attributes DO INSTEAD  INSERT INTO public.user_attributes_base (value, attr, attr_key, okey)
  VALUES (new.value, new.attr, new.attr_key, new.okey);


--
-- Name: user_attributes user_attributes_update; Type: RULE; Schema: public; Owner: -
--

CREATE RULE user_attributes_update AS
    ON UPDATE TO public.user_attributes DO INSTEAD  UPDATE public.user_attributes_base SET value = new.value, attr = new.attr, attr_key = new.attr_key, okey = new.okey
  WHERE ((user_attributes_base.attr_key = old.attr_key) AND (user_attributes_base.attr = old.attr));


--
-- Name: user_attributes user_atttributes_delete; Type: RULE; Schema: public; Owner: -
--

CREATE RULE user_atttributes_delete AS
    ON DELETE TO public.user_attributes DO INSTEAD  DELETE FROM public.user_attributes_base
  WHERE ((user_attributes_base.attr_key = old.attr_key) AND (user_attributes_base.attr = old.attr));


--
-- Name: accreq accreq_update_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER accreq_update_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.accreq FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: address_attributes_site address_attr_update_ref_a_s; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER address_attr_update_ref_a_s AFTER INSERT OR DELETE OR UPDATE ON public.address_attributes_site FOR EACH ROW EXECUTE PROCEDURE public.address_attr_update_ref();


--
-- Name: address_attributes_base address_attr_update_ref_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER address_attr_update_ref_tg AFTER INSERT OR DELETE OR UPDATE ON public.address_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.address_attr_update_ref();


--
-- Name: address_attributes_base address_sort_fields_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER address_sort_fields_tg BEFORE INSERT OR DELETE OR UPDATE ON public.address_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.address_sort_fields();


--
-- Name: address address_update_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER address_update_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.address FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: address address_update_user_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER address_update_user_rev_tg AFTER INSERT OR DELETE OR UPDATE ON public.address FOR EACH ROW EXECUTE PROCEDURE public.address_update_user_rev();


--
-- Name: aliases_attributes_base aliases_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER aliases_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.aliases_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.aliases_attr_update_ref();


--
-- Name: aliases aliases_nickname_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER aliases_nickname_tg AFTER DELETE OR UPDATE ON public.aliases FOR EACH ROW EXECUTE PROCEDURE public.aliases_nickname();


--
-- Name: aliases aliases_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER aliases_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.aliases FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: aliases aliases_user_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER aliases_user_tg AFTER INSERT OR DELETE OR UPDATE ON public.aliases FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_aliases_f();


--
-- Name: user_attributes_groups department_group_upd_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER department_group_upd_tg AFTER INSERT OR UPDATE ON public.user_attributes_groups FOR EACH ROW EXECUTE PROCEDURE public.department_group_upd_f();


--
-- Name: employment_attributes employment_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER employment_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.employment_attributes FOR EACH ROW EXECUTE PROCEDURE public.employment_attr_update_ref();


--
-- Name: nethost_attributes_macs fmt_macaddr_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER fmt_macaddr_tg BEFORE INSERT OR UPDATE ON public.nethost_attributes_macs FOR EACH ROW EXECUTE PROCEDURE public.fmt_macaddr();


--
-- Name: group_attributes_base group_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER group_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.group_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.group_attr_update_ref();


--
-- Name: group_attributes_users group_attr_user_update_user_ref_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER group_attr_user_update_user_ref_tg AFTER INSERT OR DELETE OR UPDATE ON public.group_attributes_users FOR EACH ROW EXECUTE PROCEDURE public.group_attr_user_update_user_ref();


--
-- Name: group_attributes_sutypes group_attributes_sutypes_update_ref; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER group_attributes_sutypes_update_ref AFTER INSERT OR DELETE OR UPDATE ON public.group_attributes_sutypes FOR EACH ROW EXECUTE PROCEDURE public.group_attr_update_ref();


--
-- Name: group_attributes_users group_attributes_users_update_ref; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER group_attributes_users_update_ref AFTER INSERT OR DELETE OR UPDATE ON public.group_attributes_users FOR EACH ROW EXECUTE PROCEDURE public.group_attr_update_ref();


--
-- Name: group group_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER group_rev_tg BEFORE DELETE OR UPDATE ON public."group" FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: group_attributes_base group_sort_field_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER group_sort_field_tg BEFORE INSERT OR DELETE OR UPDATE ON public.group_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.group_sort_fields();


--
-- Name: nethost_attributes_ips nethost_attr_ip_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_attr_ip_update AFTER INSERT OR DELETE OR UPDATE ON public.nethost_attributes_ips FOR EACH ROW EXECUTE PROCEDURE public.nethost_attr_update_ref();


--
-- Name: nethost_attributes_macs nethost_attr_mac_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_attr_mac_update AFTER INSERT OR DELETE OR UPDATE ON public.nethost_attributes_macs FOR EACH ROW EXECUTE PROCEDURE public.nethost_attr_update_ref();


--
-- Name: nethost_attributes_nethosts nethost_attr_nethosts_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_attr_nethosts_update AFTER INSERT OR DELETE OR UPDATE ON public.nethost_attributes_nethosts FOR EACH ROW EXECUTE PROCEDURE public.nethost_attr_update_ref();


--
-- Name: nethost_attributes nethost_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.nethost_attributes FOR EACH ROW EXECUTE PROCEDURE public.nethost_attr_update_ref();


--
-- Name: nethost_attributes_users nethost_attributes_users_update_ref; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_attributes_users_update_ref AFTER INSERT OR DELETE OR UPDATE ON public.nethost_attributes_users FOR EACH ROW EXECUTE PROCEDURE public.nethost_attr_update_ref();


--
-- Name: nethost_attributes nethost_sort_field_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_sort_field_tg BEFORE INSERT OR DELETE OR UPDATE ON public.nethost_attributes FOR EACH ROW EXECUTE PROCEDURE public.nethost_sort_fields();


--
-- Name: nethost nethost_upd_zone_tg_del; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_upd_zone_tg_del BEFORE DELETE ON public.nethost FOR EACH ROW EXECUTE PROCEDURE public.nethost_upd_zone();


--
-- Name: nethost nethost_upd_zone_tg_insupd; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_upd_zone_tg_insupd AFTER INSERT OR UPDATE ON public.nethost FOR EACH ROW EXECUTE PROCEDURE public.nethost_upd_zone();


--
-- Name: nethost nethost_update_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethost_update_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.nethost FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: nethost_attributes_ips nethostipdel_upd_zone_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER nethostipdel_upd_zone_tg BEFORE DELETE ON public.nethost_attributes_ips FOR EACH ROW EXECUTE PROCEDURE public.nethostipdel_upd_zone();


--
-- Name: netzone_attributes netzone_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER netzone_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.netzone_attributes FOR EACH ROW EXECUTE PROCEDURE public.netzone_attr_update_ref();


--
-- Name: netzone_attributes_site netzone_attr_update_ref_a_s; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER netzone_attr_update_ref_a_s AFTER INSERT OR DELETE OR UPDATE ON public.netzone_attributes_site FOR EACH ROW EXECUTE PROCEDURE public.netzone_attr_update_ref();


--
-- Name: netzone_attributes_netzone netzone_attr_update_ref_a_s; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER netzone_attr_update_ref_a_s AFTER INSERT OR DELETE OR UPDATE ON public.netzone_attributes_netzone FOR EACH ROW EXECUTE PROCEDURE public.netzone_attr_update_ref();


--
-- Name: netzone_attributes netzone_sort_fields_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER netzone_sort_fields_tg BEFORE INSERT OR DELETE OR UPDATE ON public.netzone_attributes FOR EACH ROW EXECUTE PROCEDURE public.netzone_sort_fields();


--
-- Name: netzone netzone_update_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER netzone_update_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.netzone FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: user_attributes_base person_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER person_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.user_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.person_attr_update_ref();


--
-- Name: user_attributes_groups person_attr_update_ref_a_g; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER person_attr_update_ref_a_g AFTER INSERT OR DELETE OR UPDATE ON public.user_attributes_groups FOR EACH ROW EXECUTE PROCEDURE public.person_attr_update_ref();


--
-- Name: user_attributes_site person_attr_update_ref_a_s; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER person_attr_update_ref_a_s AFTER INSERT OR DELETE OR UPDATE ON public.user_attributes_site FOR EACH ROW EXECUTE PROCEDURE public.person_attr_update_ref();


--
-- Name: user_attributes_users person_attr_update_ref_a_u; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER person_attr_update_ref_a_u AFTER INSERT OR DELETE OR UPDATE ON public.user_attributes_users FOR EACH ROW EXECUTE PROCEDURE public.person_attr_update_ref();


--
-- Name: user person_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER person_rev_tg BEFORE DELETE OR UPDATE ON public."user" FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: revaliases revaliases_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER revaliases_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.revaliases FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: revisions revisions_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER revisions_rev_tg AFTER DELETE OR UPDATE ON public.revisions FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: service_attributes serivce_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER serivce_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.service_attributes FOR EACH ROW EXECUTE PROCEDURE public.service_attr_update_ref();


--
-- Name: service_attributes_users service_attributes_users_update_ref; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER service_attributes_users_update_ref AFTER INSERT OR DELETE OR UPDATE ON public.service_attributes_users FOR EACH ROW EXECUTE PROCEDURE public.service_attr_update_ref();


--
-- Name: service service_rev_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER service_rev_tg BEFORE INSERT OR DELETE OR UPDATE ON public.service FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: service_attributes service_sort_field_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER service_sort_field_tg BEFORE INSERT OR DELETE OR UPDATE ON public.service_attributes FOR EACH ROW EXECUTE PROCEDURE public.service_sort_fields();


--
-- Name: settings settings_revision_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER settings_revision_tg BEFORE INSERT OR DELETE OR UPDATE ON public.settings FOR EACH ROW EXECUTE PROCEDURE public.rev_tg_f();


--
-- Name: site_attributes site_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER site_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.site_attributes FOR EACH ROW EXECUTE PROCEDURE public.site_attr_update_ref();


--
-- Name: stat_attributes stat_attr_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER stat_attr_update AFTER INSERT OR DELETE OR UPDATE ON public.stat_attributes FOR EACH ROW EXECUTE PROCEDURE public.stat_attr_update_ref();


--
-- Name: site update_address_site_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER update_address_site_tg BEFORE INSERT OR DELETE OR UPDATE ON public.site FOR EACH ROW EXECUTE PROCEDURE public.update_address_site();


--
-- Name: user_attributes_base user_sort_field_tg; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER user_sort_field_tg BEFORE INSERT OR DELETE OR UPDATE ON public.user_attributes_base FOR EACH ROW EXECUTE PROCEDURE public.user_sort_fields();


--
-- Name: accreq_attributes accreq_attr_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq_attributes
    ADD CONSTRAINT accreq_attr_okey_fkey FOREIGN KEY (okey) REFERENCES public.accreq(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: accreq_attributes accreq_attributes_list_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.accreq_attributes
    ADD CONSTRAINT accreq_attributes_list_attr_fkey FOREIGN KEY (attr) REFERENCES public.accreq_attributes_list(canonical);


--
-- Name: address_attributes_base address_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_base
    ADD CONSTRAINT address_attr_fkey FOREIGN KEY (attr) REFERENCES public.address_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: address_attributes_base address_attributes_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_base
    ADD CONSTRAINT address_attributes_okey_fkey FOREIGN KEY (okey) REFERENCES public.address(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: address_attributes_site address_attributes_site_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_site
    ADD CONSTRAINT address_attributes_site_attr_fkey FOREIGN KEY (attr) REFERENCES public.address_attributes_list_site(canonical) ON UPDATE CASCADE;


--
-- Name: address_attributes_site address_attributes_site_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_site
    ADD CONSTRAINT address_attributes_site_okey_fkey FOREIGN KEY (okey) REFERENCES public.address(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: address_attributes_site address_attributes_site_value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address_attributes_site
    ADD CONSTRAINT address_attributes_site_value_fkey FOREIGN KEY (value) REFERENCES public.site(name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;


--
-- Name: address address_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT address_user_fkey FOREIGN KEY ("user") REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: aliases_attributes_base aliases_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aliases_attributes_base
    ADD CONSTRAINT aliases_fkey FOREIGN KEY (okey) REFERENCES public.aliases(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: employment_attributes employment; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment_attributes
    ADD CONSTRAINT employment FOREIGN KEY (okey) REFERENCES public.employment(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: employment employment_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment
    ADD CONSTRAINT employment_user_fkey FOREIGN KEY ("user") REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: group_attributes_base group_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_base
    ADD CONSTRAINT group_attr_fkey FOREIGN KEY (attr) REFERENCES public.group_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: group_attributes_base group_attr_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_base
    ADD CONSTRAINT group_attr_okey_fkey FOREIGN KEY (okey) REFERENCES public."group"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: group_attributes_sutypes group_attr_sutypes_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_sutypes
    ADD CONSTRAINT group_attr_sutypes_okey_fkey FOREIGN KEY (okey) REFERENCES public."group"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: group_attributes_users group_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_users
    ADD CONSTRAINT group_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public."group"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: group_attributes_sutypes group_attributes_sutypes_attr; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_sutypes
    ADD CONSTRAINT group_attributes_sutypes_attr FOREIGN KEY (attr) REFERENCES public.group_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: group_attributes_sutypes group_attributes_sutypes_sutype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_sutypes
    ADD CONSTRAINT group_attributes_sutypes_sutype_fkey FOREIGN KEY (value) REFERENCES public.su_type(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: group_attributes_users group_attributes_users_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_users
    ADD CONSTRAINT group_attributes_users_attr_fkey FOREIGN KEY (attr) REFERENCES public.group_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: group_attributes_users group_attributes_users_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_attributes_users
    ADD CONSTRAINT group_attributes_users_user_fkey FOREIGN KEY (value) REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes_ips nethost_attr_ip_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_ips
    ADD CONSTRAINT nethost_attr_ip_fkey FOREIGN KEY (okey) REFERENCES public.nethost(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes_macs nethost_attr_mac_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_macs
    ADD CONSTRAINT nethost_attr_mac_fkey FOREIGN KEY (okey) REFERENCES public.nethost(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes_nethosts nethost_attr_nethosts_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_nethosts
    ADD CONSTRAINT nethost_attr_nethosts_fkey FOREIGN KEY (okey) REFERENCES public.nethost(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes_nethosts nethost_attr_nethosts_nethosts; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_nethosts
    ADD CONSTRAINT nethost_attr_nethosts_nethosts FOREIGN KEY (value) REFERENCES public.nethost(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes nethost_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes
    ADD CONSTRAINT nethost_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public.nethost(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes_users nethost_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_users
    ADD CONSTRAINT nethost_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public.nethost(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: nethost_attributes nethost_attributes_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes
    ADD CONSTRAINT nethost_attributes_attr_fkey FOREIGN KEY (attr) REFERENCES public.nethost_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: nethost_attributes_users nethost_attributes_users_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_users
    ADD CONSTRAINT nethost_attributes_users_attr_fkey FOREIGN KEY (attr) REFERENCES public.nethost_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: nethost_attributes_users nethost_attributes_users_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.nethost_attributes_users
    ADD CONSTRAINT nethost_attributes_users_user_fkey FOREIGN KEY (value) REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: netzone_attributes netzone_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes
    ADD CONSTRAINT netzone_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public.netzone(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: netzone_attributes netzone_attributes_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes
    ADD CONSTRAINT netzone_attributes_attr_fkey FOREIGN KEY (attr) REFERENCES public.netzone_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: netzone_attributes_netzone netzone_attributes_netzone_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_netzone
    ADD CONSTRAINT netzone_attributes_netzone_attr_fkey FOREIGN KEY (attr) REFERENCES public.netzone_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: netzone_attributes_netzone netzone_attributes_netzone_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_netzone
    ADD CONSTRAINT netzone_attributes_netzone_okey_fkey FOREIGN KEY (okey) REFERENCES public.netzone(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: netzone_attributes_netzone netzone_attributes_netzone_value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_netzone
    ADD CONSTRAINT netzone_attributes_netzone_value_fkey FOREIGN KEY (value) REFERENCES public.netzone(name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;


--
-- Name: netzone_attributes_site netzone_attributes_site_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_site
    ADD CONSTRAINT netzone_attributes_site_attr_fkey FOREIGN KEY (attr) REFERENCES public.netzone_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: netzone_attributes_site netzone_attributes_site_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_site
    ADD CONSTRAINT netzone_attributes_site_okey_fkey FOREIGN KEY (okey) REFERENCES public.netzone(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: netzone_attributes_site netzone_attributes_site_value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.netzone_attributes_site
    ADD CONSTRAINT netzone_attributes_site_value_fkey FOREIGN KEY (value) REFERENCES public.site(name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;


--
-- Name: passwordreset password_reset_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.passwordreset
    ADD CONSTRAINT password_reset_user_fkey FOREIGN KEY ("user") REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: request_attributes request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.request_attributes
    ADD CONSTRAINT request_id_fkey FOREIGN KEY (reqid) REFERENCES public.request(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: request request_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.request
    ADD CONSTRAINT request_name_fkey FOREIGN KEY (name) REFERENCES public.accreq(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: request request_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.request
    ADD CONSTRAINT request_user_fkey FOREIGN KEY ("user") REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: revaliases revaliase_name_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.revaliases
    ADD CONSTRAINT revaliase_name_user_fkey FOREIGN KEY (name) REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: service_attributes service_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes
    ADD CONSTRAINT service_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public.service(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: service_attributes_users service_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_users
    ADD CONSTRAINT service_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public.service(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: service_attributes service_attributes_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes
    ADD CONSTRAINT service_attributes_attr_fkey FOREIGN KEY (attr) REFERENCES public.service_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: service_attributes_users service_attributes_users_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_users
    ADD CONSTRAINT service_attributes_users_attr_fkey FOREIGN KEY (attr) REFERENCES public.service_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: service_attributes_users service_attributes_users_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.service_attributes_users
    ADD CONSTRAINT service_attributes_users_user_fkey FOREIGN KEY (value) REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: site_attributes site_attr_users_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes
    ADD CONSTRAINT site_attr_users_okey_fkey FOREIGN KEY (okey) REFERENCES public.site(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: site_attributes site_attributes_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.site_attributes
    ADD CONSTRAINT site_attributes_attr_fkey FOREIGN KEY (attr) REFERENCES public.site_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: stat_attributes stat; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stat_attributes
    ADD CONSTRAINT stat FOREIGN KEY (okey) REFERENCES public.stat(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: statsentry stat; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.statsentry
    ADD CONSTRAINT stat FOREIGN KEY (okey) REFERENCES public.stat(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: statvalues statvalues_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.statvalues
    ADD CONSTRAINT statvalues_fkey FOREIGN KEY (sid) REFERENCES public.statsentry(id);


--
-- Name: user_attributes_base user_attr_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_base
    ADD CONSTRAINT user_attr_okey_fkey FOREIGN KEY (okey) REFERENCES public."user"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: user_attributes_base user_attributes_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_base
    ADD CONSTRAINT user_attributes_attr_fkey FOREIGN KEY (attr) REFERENCES public.user_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: user_attributes_groups user_attributes_groups_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_groups
    ADD CONSTRAINT user_attributes_groups_attr_fkey FOREIGN KEY (attr) REFERENCES public.user_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: user_attributes_groups user_attributes_groups_value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_groups
    ADD CONSTRAINT user_attributes_groups_value_fkey FOREIGN KEY (value) REFERENCES public."group"(name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;


--
-- Name: user_attributes_site user_attributes_site_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_site
    ADD CONSTRAINT user_attributes_site_attr_fkey FOREIGN KEY (attr) REFERENCES public.user_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: user_attributes_site user_attributes_site_value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_site
    ADD CONSTRAINT user_attributes_site_value_fkey FOREIGN KEY (value) REFERENCES public.site(name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;


--
-- Name: user_attributes_users user_attributes_users_attr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_users
    ADD CONSTRAINT user_attributes_users_attr_fkey FOREIGN KEY (attr) REFERENCES public.user_attributes_list(canonical) ON UPDATE CASCADE;


--
-- Name: user_attributes_users user_attributes_users_value_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_users
    ADD CONSTRAINT user_attributes_users_value_fkey FOREIGN KEY (value) REFERENCES public."user"(name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;


--
-- Name: user_attributes_site user_site_attr_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_site
    ADD CONSTRAINT user_site_attr_okey_fkey FOREIGN KEY (okey) REFERENCES public."user"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: user_attributes_users user_users_attr_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_users
    ADD CONSTRAINT user_users_attr_okey_fkey FOREIGN KEY (okey) REFERENCES public."user"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: user_attributes_groups user_users_attr_okey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_attributes_groups
    ADD CONSTRAINT user_users_attr_okey_fkey FOREIGN KEY (okey) REFERENCES public."user"(ikey) ON UPDATE CASCADE ON DELETE CASCADE;


--
--


INSERT INTO public.settings (varname, val) VALUES ('schema_version', '28');
