--
-- PostgreSQL database dump
--

SET client_encoding = 'SQL_ASCII';
SET check_function_bodies = false;
SET client_min_messages = warning;

--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--


SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = true;

--
-- Name: tbl_default_preferences; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_default_preferences (
    identifier character varying(20) DEFAULT ''::character varying NOT NULL,
    value character varying(100) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE public.tbl_default_preferences OWNER TO helpdesk;

--
-- Name: tbl_domain_preferences; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_domain_preferences (
    identifier character varying(20) DEFAULT ''::character varying NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    value character varying(100) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE public.tbl_domain_preferences OWNER TO helpdesk;

--
-- Name: tbl_domains; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_domains (
    id integer DEFAULT nextval('tbl_domains_id_seq'::text) NOT NULL,
    "domain" character varying(200) DEFAULT ''::character varying NOT NULL,
    active integer DEFAULT 1 NOT NULL,
    css character varying(100) DEFAULT ''::character varying NOT NULL,
    notice character varying(500) DEFAULT ''::character varying NOT NULL,
    defaultdomain integer DEFAULT 0 NOT NULL,
    defaultpriority integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.tbl_domains OWNER TO helpdesk;

--
-- Name: tbl_domains_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_domains_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_domains_id_seq OWNER TO helpdesk;

--
-- Name: tbl_domains_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_domains_id_seq', 1, true);


--
-- Name: tbl_emailconfirmation; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_emailconfirmation (
    hash character varying(100) DEFAULT ''::character varying NOT NULL,
    userid integer DEFAULT 0 NOT NULL,
    email character varying(200) DEFAULT ''::character varying NOT NULL,
    date integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.tbl_emailconfirmation OWNER TO helpdesk;

--
-- Name: tbl_issues; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_issues (
    id integer DEFAULT nextval('"tbl_issues_id_seq"'::text) NOT NULL,
    reportedby integer DEFAULT 0 NOT NULL,
    createdby integer DEFAULT 0 NOT NULL,
    closedby integer DEFAULT 0 NOT NULL,
    assignedto integer DEFAULT 0 NOT NULL,
    status integer DEFAULT 0 NOT NULL,
    "level" integer DEFAULT 0 NOT NULL,
    priority integer DEFAULT 0 NOT NULL,
    site integer DEFAULT 0 NOT NULL,
    detail integer DEFAULT 0 NOT NULL,
    category integer DEFAULT 0 NOT NULL,
    "location" character varying(200) DEFAULT ''::character varying NOT NULL,
    contact character varying(100) DEFAULT ''::character varying NOT NULL,
    createdon bigint DEFAULT (0)::bigint NOT NULL,
    closedon bigint DEFAULT (0)::bigint NOT NULL,
    summary text DEFAULT ''::text NOT NULL,
    description text DEFAULT ''::text NOT NULL,
    solution text DEFAULT ''::text NOT NULL,
    published smallint DEFAULT (0)::smallint NOT NULL,
    publishedby integer DEFAULT 0 NOT NULL,
    publishedon bigint DEFAULT (0)::bigint NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    recalled smallint DEFAULT (0)::smallint NOT NULL
);


ALTER TABLE public.tbl_issues OWNER TO helpdesk;

--
-- Name: tbl_issues_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_issues_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_issues_id_seq OWNER TO helpdesk;

--
-- Name: tbl_issues_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_issues_id_seq', 1, false);


--
-- Name: tbl_levels; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_levels (
    id integer DEFAULT nextval('tbl_levels_id_seq'::text) NOT NULL,
    "level" character varying(100) DEFAULT ''::character varying NOT NULL,
    sortorder integer DEFAULT 0 NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    active integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.tbl_levels OWNER TO helpdesk;

--
-- Name: tbl_levels_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_levels_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_levels_id_seq OWNER TO helpdesk;

--
-- Name: tbl_levels_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_levels_id_seq', 1, false);


--
-- Name: tbl_link_categories; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_link_categories (
    id integer DEFAULT nextval('tbl_link_categories_id_seq'::text) NOT NULL,
    name character varying(100) DEFAULT ''::character varying NOT NULL,
    sortorder integer DEFAULT 0 NOT NULL,
    lang character(5) DEFAULT 'en_UK'::bpchar NOT NULL
);


ALTER TABLE public.tbl_link_categories OWNER TO helpdesk;

--
-- Name: tbl_link_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_link_categories_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_link_categories_id_seq OWNER TO helpdesk;

--
-- Name: tbl_link_categories_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_link_categories_id_seq', 2, true);


--
-- Name: tbl_links; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_links (
    id integer DEFAULT nextval('tbl_links_id_seq'::text) NOT NULL,
    text character varying(100) DEFAULT ''::character varying NOT NULL,
    link character varying(200) DEFAULT ''::character varying NOT NULL,
    category integer DEFAULT 0 NOT NULL,
    sortorder integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.tbl_links OWNER TO helpdesk;

--
-- Name: tbl_links_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_links_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_links_id_seq OWNER TO helpdesk;

--
-- Name: tbl_links_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_links_id_seq', 9, true);


--
-- Name: tbl_logs; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_logs (
    id integer DEFAULT nextval('"tbl_logs_id_seq"'::text) NOT NULL,
    userid integer DEFAULT 0 NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    "timestamp" bigint DEFAULT (0)::bigint,
    code character varying(50) DEFAULT ''::character varying NOT NULL,
    log text DEFAULT ''::text NOT NULL
);


ALTER TABLE public.tbl_logs OWNER TO helpdesk;

--
-- Name: tbl_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_logs_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_logs_id_seq OWNER TO helpdesk;

--
-- Name: tbl_logs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_logs_id_seq', 8, true);


--
-- Name: tbl_news; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_news (
    id integer DEFAULT nextval('tbl_news_id_seq'::text) NOT NULL,
    date date DEFAULT ('now'::text)::date NOT NULL,
    content character varying(1000) DEFAULT ''::character varying NOT NULL,
    frontpagepara integer DEFAULT 0 NOT NULL,
    lang character(5) DEFAULT 'en_UK'::bpchar NOT NULL,
    domain_id integer
);


ALTER TABLE public.tbl_news OWNER TO helpdesk;

--
-- Name: tbl_news_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_news_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_news_id_seq OWNER TO helpdesk;

--
-- Name: tbl_news_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_news_id_seq', 12, true);


--
-- Name: tbl_preference_descriptions; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_preference_descriptions (
    identifier character varying(20) DEFAULT ''::character varying NOT NULL,
    "type" character varying(20) DEFAULT ''::character varying NOT NULL,
    description character varying(100) DEFAULT ''::character varying NOT NULL,
    overridable smallint DEFAULT (0)::smallint NOT NULL
);


ALTER TABLE public.tbl_preference_descriptions OWNER TO helpdesk;

--
-- Name: tbl_priorities; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_priorities (
    id integer DEFAULT nextval('"tbl_priorities_id_seq"'::text) NOT NULL,
    priority character varying(100) DEFAULT ''::character varying NOT NULL,
    "class" integer DEFAULT 0 NOT NULL,
    sortorder integer DEFAULT 0 NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    active integer DEFAULT 1 NOT NULL,
    "notify" smallint DEFAULT (0)::smallint NOT NULL
);


ALTER TABLE public.tbl_priorities OWNER TO helpdesk;

--
-- Name: tbl_priorities_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_priorities_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_priorities_id_seq OWNER TO helpdesk;

--
-- Name: tbl_priorities_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_priorities_id_seq', 1, false);


--
-- Name: tbl_problemcategories; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_problemcategories (
    id integer DEFAULT nextval('"tbl_problemcategories_id_seq"'::text) NOT NULL,
    description character varying(100) DEFAULT ''::character varying NOT NULL,
    active smallint DEFAULT (1)::smallint NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.tbl_problemcategories OWNER TO helpdesk;

--
-- Name: tbl_problemcategories_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_problemcategories_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_problemcategories_id_seq OWNER TO helpdesk;

--
-- Name: tbl_problemcategories_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_problemcategories_id_seq', 1, false);


--
-- Name: tbl_problemdetails; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_problemdetails (
    id integer DEFAULT nextval('"tbl_problemdetails_id_seq"'::text) NOT NULL,
    category integer DEFAULT 0 NOT NULL,
    description character varying(100) DEFAULT ''::character varying NOT NULL,
    active smallint DEFAULT (1)::smallint NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.tbl_problemdetails OWNER TO helpdesk;

--
-- Name: tbl_problemdetails_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_problemdetails_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_problemdetails_id_seq OWNER TO helpdesk;

--
-- Name: tbl_problemdetails_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_problemdetails_id_seq', 1, false);


--
-- Name: tbl_remarks; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_remarks (
    id integer DEFAULT nextval('"tbl_remarks_id_seq"'::text) NOT NULL,
    issue integer DEFAULT 0 NOT NULL,
    reportedby integer DEFAULT 0 NOT NULL,
    reportedon bigint DEFAULT (0)::bigint,
    remark text DEFAULT ''::text NOT NULL,
    confidential integer DEFAULT 1 NOT NULL,
    "time" interval DEFAULT '00:00:00'::interval
);


ALTER TABLE public.tbl_remarks OWNER TO helpdesk;

--
-- Name: tbl_remarks_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_remarks_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_remarks_id_seq OWNER TO helpdesk;

--
-- Name: tbl_remarks_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_remarks_id_seq', 1, false);


--
-- Name: tbl_sites; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_sites (
    id integer DEFAULT nextval('"tbl_sites_id_seq"'::text) NOT NULL,
    site character varying(100) DEFAULT ''::character varying NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    active integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.tbl_sites OWNER TO helpdesk;

--
-- Name: tbl_sites_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_sites_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_sites_id_seq OWNER TO helpdesk;

--
-- Name: tbl_sites_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_sites_id_seq', 1, false);


--
-- Name: tbl_statuses; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_statuses (
    id integer DEFAULT nextval('"tbl_statuses_id_seq"'::text) NOT NULL,
    status character varying(100) DEFAULT ''::character varying NOT NULL,
    sortorder integer DEFAULT 0 NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    active integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.tbl_statuses OWNER TO helpdesk;

--
-- Name: tbl_statuses_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_statuses_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_statuses_id_seq OWNER TO helpdesk;

--
-- Name: tbl_statuses_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_statuses_id_seq', 1, false);


--
-- Name: tbl_system_preferences; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_system_preferences (
    id integer DEFAULT nextval('"tbl_system_preferences_id_seq"'::text) NOT NULL,
    identifier character varying(20) DEFAULT ''::character varying NOT NULL,
    value character varying(100) DEFAULT ''::character varying NOT NULL,
    "comment" character varying(100) DEFAULT ''::character varying NOT NULL,
    system smallint DEFAULT (0)::smallint NOT NULL
);


ALTER TABLE public.tbl_system_preferences OWNER TO helpdesk;

--
-- Name: tbl_system_preferences_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_system_preferences_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_system_preferences_id_seq OWNER TO helpdesk;

--
-- Name: tbl_system_preferences_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_system_preferences_id_seq', 5, true);


--
-- Name: tbl_thesaurus; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_thesaurus (
    id integer DEFAULT nextval('tbl_thesaurus_id_seq'::text) NOT NULL,
    term character varying(40) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE public.tbl_thesaurus OWNER TO helpdesk;

--
-- Name: tbl_thesaurus_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_thesaurus_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_thesaurus_id_seq OWNER TO helpdesk;

--
-- Name: tbl_thesaurus_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_thesaurus_id_seq', 1, false);


--
-- Name: tbl_thesaurus_mappings; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_thesaurus_mappings (
    term integer NOT NULL,
    issue integer NOT NULL
);


ALTER TABLE public.tbl_thesaurus_mappings OWNER TO helpdesk;

--
-- Name: tbl_times; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_times (
    issue integer DEFAULT 0 NOT NULL,
    userid integer DEFAULT 0 NOT NULL,
    "time" interval NOT NULL
);


ALTER TABLE public.tbl_times OWNER TO helpdesk;

--
-- Name: tbl_user_preferences; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_user_preferences (
    identifier character varying(20) DEFAULT ''::character varying NOT NULL,
    userid integer DEFAULT 0 NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    value character varying(100) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE public.tbl_user_preferences OWNER TO helpdesk;

--
-- Name: tbl_userdomains; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_userdomains (
    id integer DEFAULT nextval('"tbl_userdomains_id_seq"'::text) NOT NULL,
    userid integer DEFAULT 0 NOT NULL,
    "domain" integer DEFAULT 0 NOT NULL,
    defaultflag smallint DEFAULT (0)::smallint NOT NULL
);


ALTER TABLE public.tbl_userdomains OWNER TO helpdesk;

--
-- Name: tbl_userdomains_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_userdomains_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_userdomains_id_seq OWNER TO helpdesk;

--
-- Name: tbl_userdomains_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_userdomains_id_seq', 1, false);


--
-- Name: tbl_users; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_users (
    id integer DEFAULT nextval('"tbl_users_id_seq"'::text) NOT NULL,
    username character varying(20) DEFAULT ''::character varying NOT NULL,
    pass character varying(50) DEFAULT ''::character varying NOT NULL,
    name character varying(100) DEFAULT ''::character varying NOT NULL,
    email character varying(100) DEFAULT ''::character varying NOT NULL,
    available smallint DEFAULT (0)::smallint NOT NULL,
    active smallint DEFAULT (1)::smallint NOT NULL,
    root smallint DEFAULT (0)::smallint NOT NULL,
    restricted smallint DEFAULT (0)::smallint NOT NULL
);


ALTER TABLE public.tbl_users OWNER TO helpdesk;

--
-- Name: tbl_users_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_users_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_users_id_seq OWNER TO helpdesk;

--
-- Name: tbl_users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_users_id_seq', 1, true);


--
-- Name: tbl_usersites; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_usersites (
    userid integer DEFAULT 0 NOT NULL,
    site integer DEFAULT 0 NOT NULL,
    usertype integer DEFAULT 0 NOT NULL,
    defaultflag smallint DEFAULT (1)::smallint NOT NULL
);


ALTER TABLE public.tbl_usersites OWNER TO helpdesk;

--
-- Name: tbl_usertypes; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE TABLE tbl_usertypes (
    id integer DEFAULT nextval('"tbl_usertypes_id_seq"'::text) NOT NULL,
    "type" character varying(100) DEFAULT ''::character varying NOT NULL,
    sortorder integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.tbl_usertypes OWNER TO helpdesk;

--
-- Name: tbl_usertypes_id_seq; Type: SEQUENCE; Schema: public; Owner: helpdesk
--

CREATE SEQUENCE tbl_usertypes_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.tbl_usertypes_id_seq OWNER TO helpdesk;

--
-- Name: tbl_usertypes_id_seq; Type: SEQUENCE SET; Schema: public; Owner: helpdesk
--

SELECT pg_catalog.setval('tbl_usertypes_id_seq', 6, true);


--
-- Name: tbl_wrktimer; Type: TABLE; Schema: public; Owner: helpdesk; Tablespace:
--

CREATE TABLE tbl_wrktimer (
    issue int4 DEFAULT '0' NOT NULL REFERENCES tbl_Issues (id) ON DELETE CASCADE,
    userid int4 DEFAULT '0' NOT NULL REFERENCES tbl_Users (id) ON DELETE CASCADE,
    running bool DEFAULT '0' NOT NULL,
    "begin" timestamp NOT NULL,
    "end" timestamp NOT NULL,
    CONSTRAINT "tbl_wrktimer_pkey" PRIMARY KEY ("issue","userid")
);


ALTER TABLE public.tbl_wrktimer OWNER TO helpdesk;

--
-- Name: vw_default_preferences; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_default_preferences AS
    SELECT d.identifier, d."type", d.description, d.overridable, p.value FROM tbl_default_preferences p, tbl_preference_descriptions d WHERE ((p.identifier)::text = (d.identifier)::text);


ALTER TABLE public.vw_default_preferences OWNER TO helpdesk;

--
-- Name: vw_domain_preferences; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_domain_preferences AS
    SELECT d.identifier, d."type", d.description, d.overridable, p.value, p."domain" FROM tbl_domain_preferences p, tbl_preference_descriptions d WHERE ((p.identifier)::text = (d.identifier)::text);


ALTER TABLE public.vw_domain_preferences OWNER TO helpdesk;

--
-- Name: vw_issues; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_issues AS
    SELECT tbl_issues.id, tbl_issues.reportedby, tbl_issues.createdby, tbl_issues.closedby, tbl_issues.assignedto, tbl_issues.status, tbl_issues."level", tbl_issues.priority, tbl_issues.site, tbl_issues.detail, tbl_issues."location", tbl_issues.contact, tbl_issues.createdon, tbl_issues.closedon, tbl_issues.summary, tbl_issues.description, tbl_issues.solution, tbl_issues.published, tbl_issues.publishedon, tbl_issues.publishedby, tbl_issues.recalled, tbl_issues.category, tbl_issues."domain", tbl_users1.name AS createdbyname, tbl_users2.name AS reportedbyname, tbl_users3.name AS closedbyname, tbl_users4.name AS assignedtoname, tbl_users5.name AS publishedbyname, tbl_sites.site AS sitename, tbl_statuses.status AS statusname, tbl_statuses.sortorder AS statussortorder, tbl_priorities.priority AS priorityname, tbl_priorities.sortorder, tbl_priorities."class", tbl_levels."level" AS levelname, tbl_levels.sortorder AS levelsortorder, tbl_problemdetails.description AS detailname, tbl_problemcategories.description AS categoryname FROM (((((tbl_issues LEFT JOIN tbl_users tbl_users1 ON ((tbl_issues.createdby = tbl_users1.id))) LEFT JOIN tbl_users tbl_users2 ON ((tbl_issues.reportedby = tbl_users2.id))) LEFT JOIN tbl_users tbl_users3 ON ((tbl_issues.closedby = tbl_users3.id))) LEFT JOIN tbl_users tbl_users4 ON ((tbl_issues.assignedto = tbl_users4.id))) LEFT JOIN tbl_users tbl_users5 ON ((tbl_issues.publishedby = tbl_users5.id))), tbl_sites, tbl_statuses, tbl_priorities, tbl_levels, tbl_problemdetails, tbl_problemcategories WHERE ((((((tbl_issues.site = tbl_sites.id) AND (tbl_issues.status = tbl_statuses.id)) AND (tbl_issues.priority = tbl_priorities.id)) AND (tbl_issues."level" = tbl_levels.id)) AND (tbl_issues.detail = tbl_problemdetails.id)) AND (tbl_issues.category = tbl_problemcategories.id));


ALTER TABLE public.vw_issues OWNER TO helpdesk;

--
-- Name: vw_sites; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_sites AS
    SELECT tbl_sites.id, tbl_sites.site, tbl_sites."domain", tbl_sites.active, tbl_usersites.userid AS "user", tbl_usersites.usertype FROM (tbl_sites LEFT JOIN tbl_usersites ON ((tbl_usersites.site = tbl_sites.id)));


ALTER TABLE public.vw_sites OWNER TO helpdesk;

--
-- Name: vw_user_preferences; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_user_preferences AS
    SELECT d.identifier, d."type", d.description, d.overridable, p.value, p."domain", p.userid AS "user" FROM tbl_user_preferences p, tbl_preference_descriptions d WHERE ((p.identifier)::text = (d.identifier)::text);


ALTER TABLE public.vw_user_preferences OWNER TO helpdesk;

--
-- Name: vw_userdomains; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_userdomains AS
    SELECT tbl_domains."domain" AS domainname, tbl_userdomains.id, tbl_userdomains.userid AS "user", tbl_userdomains."domain", tbl_userdomains.defaultflag FROM tbl_domains, tbl_userdomains WHERE (tbl_userdomains."domain" = tbl_domains.id);


ALTER TABLE public.vw_userdomains OWNER TO helpdesk;

--
-- Name: vw_users; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_users AS
    SELECT tbl_users.id, tbl_users.username AS "user", tbl_users.pass, tbl_users.name, tbl_users.available, tbl_users.active, tbl_users.restricted, tbl_users.root, vw_userdomains.domainname, vw_userdomains."domain", vw_userdomains.defaultflag FROM tbl_users, vw_userdomains WHERE (tbl_users.id = vw_userdomains."user");


ALTER TABLE public.vw_users OWNER TO helpdesk;

--
-- Name: vw_usertypes; Type: VIEW; Schema: public; Owner: helpdesk
--

CREATE VIEW vw_usertypes AS
    SELECT tbl_users.id, tbl_users.username AS "user", tbl_users.pass, tbl_users.name, tbl_users.available, tbl_users.active, tbl_users.restricted, tbl_users.root, tbl_usersites.usertype, tbl_usersites.site, tbl_usertypes."type" AS usertypename, tbl_usertypes.sortorder AS usertypesortorder, vw_userdomains.domainname, vw_userdomains."domain", vw_userdomains.defaultflag FROM tbl_users, tbl_usersites, tbl_usertypes, vw_userdomains, tbl_sites WHERE (((((tbl_users.id = vw_userdomains."user") AND (tbl_users.id = tbl_usersites.userid)) AND (tbl_usersites.usertype = tbl_usertypes.id)) AND (vw_userdomains."domain" = tbl_sites."domain")) AND (tbl_usersites.site = tbl_sites.id));


ALTER TABLE public.vw_usertypes OWNER TO helpdesk;

--
-- Data for Name: tbl_default_preferences; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_default_preferences VALUES ('verify-email', 'true');
INSERT INTO tbl_default_preferences VALUES ('pub-hide-su', 'false');
INSERT INTO tbl_default_preferences VALUES ('pub-hide-remarks', 'false');
INSERT INTO tbl_default_preferences VALUES ('language', 'en_UK');
INSERT INTO tbl_default_preferences VALUES ('email-remark', 'false');
INSERT INTO tbl_default_preferences VALUES ('email-resolve', 'false');
INSERT INTO tbl_default_preferences VALUES ('newissue-email', '');
INSERT INTO tbl_default_preferences VALUES ('wrk-timer', 'true');


--
-- Data for Name: tbl_domain_preferences; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_domains; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_domains VALUES (0, 'System', 0, '', '', 0, 0);
INSERT INTO tbl_domains VALUES (1, 'Demo', 1, '', '', 0, 0);


--
-- Data for Name: tbl_emailconfirmation; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_issues; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_levels; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_levels VALUES (0, 'None', -1, 0, 0);


--
-- Data for Name: tbl_link_categories; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_link_categories VALUES (1, 'Helpdesk Issue Manager', 0, 'en_UK');
INSERT INTO tbl_link_categories VALUES (2, 'Sponsors', 1, 'en_UK');


--
-- Data for Name: tbl_links; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_links VALUES (1, 'Home', 'index.php', 1, 0);
INSERT INTO tbl_links VALUES (2, 'About', 'about.php', 1, 1);
INSERT INTO tbl_links VALUES (3, 'News', 'news.php', 1, 2);
INSERT INTO tbl_links VALUES (4, 'Documentation', 'docs/index.html', 1, 4);
INSERT INTO tbl_links VALUES (5, 'F.A.Q.', 'faq.php', 1, 5);
INSERT INTO tbl_links VALUES (6, 'Download', 'download.php', 1, 6);
INSERT INTO tbl_links VALUES (7, 'Features', 'features.php', 1, 7);
INSERT INTO tbl_links VALUES (8, 'Change Log', 'changelog.php', 1, 8);
INSERT INTO tbl_links VALUES (9, 'Central Mcr. CLC', 'http://www.centralmanclc.com/', 2, 0);
INSERT INTO tbl_links VALUES (10, 'Oxford Archeology', 'http://www.thehumanjourney.net/', 2, 1);
INSERT INTO tbl_links VALUES (11, 'European Electronique', 'http://www.euroele.co.uk/', 2, 2);

--
-- Data for Name: tbl_logs; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_logs VALUES (1, 0, 0, 1138753409, 'ATTEMPTED LOGIN - FAILURE', 'User: dave, with password: rutherford');
INSERT INTO tbl_logs VALUES (2, 0, 0, 1138753415, 'ATTEMPTED LOGIN - FAILURE', 'User: dave, with password: rutherford');
INSERT INTO tbl_logs VALUES (3, 0, 0, 1138753425, 'ATTEMPTED LOGIN - FAILURE', 'User: dave, with password: rutherford');
INSERT INTO tbl_logs VALUES (4, 0, 0, 1138753459, 'ATTEMPTED LOGIN - FAILURE', 'User: dave, with password: rutherford');
INSERT INTO tbl_logs VALUES (5, 0, 0, 1138754037, 'ATTEMPTED LOGIN - FAILURE', 'User: dave, with password: rutherford');
INSERT INTO tbl_logs VALUES (6, 0, 0, 1138754046, 'ATTEMPTED LOGIN - FAILURE', 'User: helpdesk, with password: helpdespass');
INSERT INTO tbl_logs VALUES (7, 1, 1, 1138754052, 'LOGIN', 'Project Admin has successfully logged in.');
INSERT INTO tbl_logs VALUES (8, 1, 1, 1138754295, 'LOGIN', 'Project Admin has successfully logged in.');


--
-- Data for Name: tbl_news; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_news VALUES (1, '2006-01-31', '    <h2 style="text-align:right;">[ PHP / PostgreSQL ]</h2>
    <p>This website allows you to find out more <a href="about.php">about the system</a>,
      to <a href="download.php">download the sources</a> and to demo the helpdesk. For some
      initial documentation (so far just installation instructions) go to the
      <a href="docs/index.html">documentation</a> page.</p>
', 1, 'en_UK', NULL);
INSERT INTO tbl_news VALUES (3, '2006-02-01', '', 3, 'en_UK', 0);
INSERT INTO tbl_news VALUES (4, '2006-02-01', '', 3, 'en_UK', 1);
INSERT INTO tbl_news VALUES (5, '2006-02-01', '', 3, 'en_UK', 0);
INSERT INTO tbl_news VALUES (6, '2006-02-01', '', 3, 'en_UK', 1);
INSERT INTO tbl_news VALUES (2, '2006-01-31', '    <h2>Take it for a test drive - help with beta testing</h2>
    <p>Just use the login form in the sidebar to take a tour.</p>

    <h3>Log in as a Client...</h3>
    <div class="labelfieldpair">
      <div class="label">Username:</div>
      <div class="text">client</div>
    </div>
    <div class="labelfieldpair">
      <div class="label">Password:</div>
      <div class="text">client</div>
    </div>

    <h3>Log in as a Support Agent...</h3>
    <div class="labelfieldpair">
      <div class="label">Username:</div>
      <div class="text">support</div>
    </div>
    <div class="labelfieldpair">
      <div class="label">Password:</div>
      <div class="text">support</div>
    </div>
    <p>Enjoy!</p>
', 2, 'en_UK', NULL);
INSERT INTO tbl_news VALUES (7, '2006-02-01', '', 3, 'en_UK', 0);
INSERT INTO tbl_news VALUES (8, '2006-02-01', '', 3, 'en_UK', 1);
INSERT INTO tbl_news VALUES (9, '2006-02-01', '', 3, 'en_UK', 0);
INSERT INTO tbl_news VALUES (10, '2006-02-01', '', 3, 'en_UK', 1);
INSERT INTO tbl_news VALUES (11, '2006-02-01', '', 3, 'en_UK', 0);
INSERT INTO tbl_news VALUES (12, '2006-02-01', '', 3, 'en_UK', 1);


--
-- Data for Name: tbl_preference_descriptions; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_preference_descriptions VALUES ('verify-email', 'boolean', 'Turn on email verification', 0);
INSERT INTO tbl_preference_descriptions VALUES ('pub-hide-su', 'boolean', 'Hide site and user names in published issues', 0);
INSERT INTO tbl_preference_descriptions VALUES ('pub-hide-remarks', 'boolean', 'Hide all remarks in published issues', 0);
INSERT INTO tbl_preference_descriptions VALUES ('language', 'langlist', 'The language in which to display all text', 1);
INSERT INTO tbl_preference_descriptions VALUES ('email-remark', 'boolean', 'Email notification of issue changes/remarks.', 1);
INSERT INTO tbl_preference_descriptions VALUES ('email-resolve', 'boolean', 'Email notification of issue resolutions.', 1);
INSERT INTO tbl_preference_descriptions VALUES ('newissue-email', 'text', 'Email address to receive new unassigned issues (or leave blank)', 0);
INSERT INTO tbl_preference_descriptions VALUES ('wrk-timer', 'boolean', 'Turn on usage of Timer', 0);


--
-- Data for Name: tbl_priorities; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_priorities VALUES (0, 'Ungraded', 0, -1, 0, 1, 0);


--
-- Data for Name: tbl_problemcategories; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_problemcategories VALUES (0, 'Unknown', 1, 0);


--
-- Data for Name: tbl_problemdetails; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_problemdetails VALUES (0, 0, 'Unknown', 1, 0);


--
-- Data for Name: tbl_remarks; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_sites; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_sites VALUES (0, 'None', 0, 0);


--
-- Data for Name: tbl_statuses; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_statuses VALUES (0, 'Ungraded', -1, 0, 0);


--
-- Data for Name: tbl_system_preferences; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_system_preferences VALUES (2, 'pagesize', '20', 'Page size for paging of issues', 0);
INSERT INTO tbl_system_preferences VALUES (3, 'closedpagesize', '10', 'Page size for restriction of closed issues', 0);
INSERT INTO tbl_system_preferences VALUES (4, 'maxupload', '10000', 'Maximum file upload size in bytes', 0);
INSERT INTO tbl_system_preferences VALUES (5, 'excessivehours', '10', 'Number of hours spent on a problem that is considered excessive and should be confirmed', 0);
INSERT INTO tbl_system_preferences VALUES (1, 'version', '0.9.3', 'This is the current version number for the system', 1);


--
-- Data for Name: tbl_thesaurus; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_thesaurus_mappings; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_times; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_user_preferences; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_userdomains; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_users; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_users VALUES (0, '', '', '* unassigned *', '', 1, 1, 0, 0);
INSERT INTO tbl_users VALUES (1, 'root', '63a9f0ea7bb98050796b649e85481845', 'Project Admin', '', 1, 1, 1, 0);


--
-- Data for Name: tbl_usersites; Type: TABLE DATA; Schema: public; Owner: helpdesk
--



--
-- Data for Name: tbl_usertypes; Type: TABLE DATA; Schema: public; Owner: helpdesk
--

INSERT INTO tbl_usertypes VALUES (1, 'Client', 0);
INSERT INTO tbl_usertypes VALUES (2, 'Site Contact', 1);
INSERT INTO tbl_usertypes VALUES (3, 'Support Agent', 2);
INSERT INTO tbl_usertypes VALUES (4, 'Administrator', 3);
INSERT INTO tbl_usertypes VALUES (5, 'Domain Administrator', 4);
INSERT INTO tbl_usertypes VALUES (6, 'Root', 999);


--
-- Name: tbl_default_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_default_preferences
    ADD CONSTRAINT tbl_default_preferences_pkey PRIMARY KEY (identifier);


ALTER INDEX public.tbl_default_preferences_pkey OWNER TO helpdesk;

--
-- Name: tbl_domain_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_domain_preferences
    ADD CONSTRAINT tbl_domain_preferences_pkey PRIMARY KEY (identifier, "domain");


ALTER INDEX public.tbl_domain_preferences_pkey OWNER TO helpdesk;

--
-- Name: tbl_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_domains
    ADD CONSTRAINT tbl_domains_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_domains_pkey OWNER TO helpdesk;

--
-- Name: tbl_emailconfirmation_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_emailconfirmation
    ADD CONSTRAINT tbl_emailconfirmation_pkey PRIMARY KEY (hash);


ALTER INDEX public.tbl_emailconfirmation_pkey OWNER TO helpdesk;

--
-- Name: tbl_issues_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_issues_pkey OWNER TO helpdesk;

--
-- Name: tbl_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_levels
    ADD CONSTRAINT tbl_levels_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_levels_pkey OWNER TO helpdesk;

--
-- Name: tbl_link_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_link_categories
    ADD CONSTRAINT tbl_link_categories_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_link_categories_pkey OWNER TO helpdesk;

--
-- Name: tbl_links_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_links
    ADD CONSTRAINT tbl_links_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_links_pkey OWNER TO helpdesk;

--
-- Name: tbl_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_logs
    ADD CONSTRAINT tbl_logs_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_logs_pkey OWNER TO helpdesk;

--
-- Name: tbl_preference_descriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_preference_descriptions
    ADD CONSTRAINT tbl_preference_descriptions_pkey PRIMARY KEY (identifier);


ALTER INDEX public.tbl_preference_descriptions_pkey OWNER TO helpdesk;

--
-- Name: tbl_priorities_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_priorities
    ADD CONSTRAINT tbl_priorities_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_priorities_pkey OWNER TO helpdesk;

--
-- Name: tbl_problemcategories_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_problemcategories
    ADD CONSTRAINT tbl_problemcategories_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_problemcategories_pkey OWNER TO helpdesk;

--
-- Name: tbl_problemdetails_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_problemdetails
    ADD CONSTRAINT tbl_problemdetails_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_problemdetails_pkey OWNER TO helpdesk;

--
-- Name: tbl_remarks_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_remarks
    ADD CONSTRAINT tbl_remarks_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_remarks_pkey OWNER TO helpdesk;

--
-- Name: tbl_sites_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_sites
    ADD CONSTRAINT tbl_sites_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_sites_pkey OWNER TO helpdesk;

--
-- Name: tbl_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_statuses
    ADD CONSTRAINT tbl_statuses_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_statuses_pkey OWNER TO helpdesk;

--
-- Name: tbl_system_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_system_preferences
    ADD CONSTRAINT tbl_system_preferences_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_system_preferences_pkey OWNER TO helpdesk;

--
-- Name: tbl_thesaurus_mappings_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_thesaurus_mappings
    ADD CONSTRAINT tbl_thesaurus_mappings_pkey PRIMARY KEY (term, issue);


ALTER INDEX public.tbl_thesaurus_mappings_pkey OWNER TO helpdesk;

--
-- Name: tbl_thesaurus_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_thesaurus
    ADD CONSTRAINT tbl_thesaurus_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_thesaurus_pkey OWNER TO helpdesk;

--
-- Name: tbl_times_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_times
    ADD CONSTRAINT tbl_times_pkey PRIMARY KEY (issue, userid);


ALTER INDEX public.tbl_times_pkey OWNER TO helpdesk;

--
-- Name: tbl_user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_user_preferences
    ADD CONSTRAINT tbl_user_preferences_pkey PRIMARY KEY (identifier, userid, "domain");


ALTER INDEX public.tbl_user_preferences_pkey OWNER TO helpdesk;

--
-- Name: tbl_userdomains_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_userdomains
    ADD CONSTRAINT tbl_userdomains_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_userdomains_pkey OWNER TO helpdesk;

--
-- Name: tbl_users_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_users
    ADD CONSTRAINT tbl_users_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_users_pkey OWNER TO helpdesk;

--
-- Name: tbl_usersites_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_usersites
    ADD CONSTRAINT tbl_usersites_pkey PRIMARY KEY (userid, site, usertype);


ALTER INDEX public.tbl_usersites_pkey OWNER TO helpdesk;

--
-- Name: tbl_usertypes_pkey; Type: CONSTRAINT; Schema: public; Owner: helpdesk; Tablespace: 
--

ALTER TABLE ONLY tbl_usertypes
    ADD CONSTRAINT tbl_usertypes_pkey PRIMARY KEY (id);


ALTER INDEX public.tbl_usertypes_pkey OWNER TO helpdesk;

--
-- Name: category_tbl_problemdetails_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX category_tbl_problemdetails_key ON tbl_problemdetails USING btree (category);


ALTER INDEX public.category_tbl_problemdetails_key OWNER TO helpdesk;

--
-- Name: domain_tbl_levels_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_levels_key ON tbl_levels USING btree ("domain");


ALTER INDEX public.domain_tbl_levels_key OWNER TO helpdesk;

--
-- Name: domain_tbl_logs_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_logs_key ON tbl_logs USING btree ("domain");


ALTER INDEX public.domain_tbl_logs_key OWNER TO helpdesk;

--
-- Name: domain_tbl_priorities_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_priorities_key ON tbl_priorities USING btree ("domain");


ALTER INDEX public.domain_tbl_priorities_key OWNER TO helpdesk;

--
-- Name: domain_tbl_problemcategories_ke; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_problemcategories_ke ON tbl_problemcategories USING btree ("domain");


ALTER INDEX public.domain_tbl_problemcategories_ke OWNER TO helpdesk;

--
-- Name: domain_tbl_problemdetails_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_problemdetails_key ON tbl_problemdetails USING btree ("domain");


ALTER INDEX public.domain_tbl_problemdetails_key OWNER TO helpdesk;

--
-- Name: domain_tbl_sites_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_sites_key ON tbl_sites USING btree ("domain");


ALTER INDEX public.domain_tbl_sites_key OWNER TO helpdesk;

--
-- Name: domain_tbl_statuses_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX domain_tbl_statuses_key ON tbl_statuses USING btree ("domain");


ALTER INDEX public.domain_tbl_statuses_key OWNER TO helpdesk;

--
-- Name: issue_tbl_remarks_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX issue_tbl_remarks_key ON tbl_remarks USING btree (issue);


ALTER INDEX public.issue_tbl_remarks_key OWNER TO helpdesk;

--
-- Name: reportedby_tbl_remarks_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX reportedby_tbl_remarks_key ON tbl_remarks USING btree (reportedby);


ALTER INDEX public.reportedby_tbl_remarks_key OWNER TO helpdesk;

--
-- Name: user_tbl_logs_key; Type: INDEX; Schema: public; Owner: helpdesk; Tablespace: 
--

CREATE INDEX user_tbl_logs_key ON tbl_logs USING btree (userid);


ALTER INDEX public.user_tbl_logs_key OWNER TO helpdesk;

--
-- Name: tbl_default_preferences_identifier_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_default_preferences
    ADD CONSTRAINT tbl_default_preferences_identifier_fkey FOREIGN KEY (identifier) REFERENCES tbl_preference_descriptions(identifier) ON DELETE CASCADE;


--
-- Name: tbl_domain_preferences_identifier_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_domain_preferences
    ADD CONSTRAINT tbl_domain_preferences_identifier_fkey FOREIGN KEY (identifier) REFERENCES tbl_preference_descriptions(identifier) ON DELETE CASCADE;


--
-- Name: tbl_domains_defaultpriority_fk; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_domains
    ADD CONSTRAINT tbl_domains_defaultpriority_fk FOREIGN KEY (defaultpriority) REFERENCES tbl_priorities(id) MATCH FULL ON DELETE SET DEFAULT;


--
-- Name: tbl_issues_assignedto_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_assignedto_fkey FOREIGN KEY (assignedto) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_category_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_category_fkey FOREIGN KEY (category) REFERENCES tbl_problemcategories(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_closedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_closedby_fkey FOREIGN KEY (closedby) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_createdby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_createdby_fkey FOREIGN KEY (createdby) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_detail_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_detail_fkey FOREIGN KEY (detail) REFERENCES tbl_problemdetails(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_level_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_level_fkey FOREIGN KEY ("level") REFERENCES tbl_levels(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_priority_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_priority_fkey FOREIGN KEY (priority) REFERENCES tbl_priorities(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_publishedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_publishedby_fkey FOREIGN KEY (publishedby) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_reportedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_reportedby_fkey FOREIGN KEY (reportedby) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_site_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_site_fkey FOREIGN KEY (site) REFERENCES tbl_sites(id) ON DELETE CASCADE;


--
-- Name: tbl_issues_status_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_issues
    ADD CONSTRAINT tbl_issues_status_fkey FOREIGN KEY (status) REFERENCES tbl_statuses(id) ON DELETE CASCADE;


--
-- Name: tbl_levels_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_levels
    ADD CONSTRAINT tbl_levels_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_links_category_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_links
    ADD CONSTRAINT tbl_links_category_fkey FOREIGN KEY (category) REFERENCES tbl_link_categories(id) ON DELETE CASCADE;


--
-- Name: tbl_logs_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_logs
    ADD CONSTRAINT tbl_logs_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_logs_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_logs
    ADD CONSTRAINT tbl_logs_user_fkey FOREIGN KEY (userid) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_priorities_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_priorities
    ADD CONSTRAINT tbl_priorities_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_problemcategories_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_problemcategories
    ADD CONSTRAINT tbl_problemcategories_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_problemdetails_category_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_problemdetails
    ADD CONSTRAINT tbl_problemdetails_category_fkey FOREIGN KEY (category) REFERENCES tbl_problemcategories(id) ON DELETE CASCADE;


--
-- Name: tbl_problemdetails_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_problemdetails
    ADD CONSTRAINT tbl_problemdetails_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_remarks_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_remarks
    ADD CONSTRAINT tbl_remarks_issue_fkey FOREIGN KEY (issue) REFERENCES tbl_issues(id) ON DELETE CASCADE;


--
-- Name: tbl_remarks_reportedby_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_remarks
    ADD CONSTRAINT tbl_remarks_reportedby_fkey FOREIGN KEY (reportedby) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_sites_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_sites
    ADD CONSTRAINT tbl_sites_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_statuses_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_statuses
    ADD CONSTRAINT tbl_statuses_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_thesaurus_mappings_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_thesaurus_mappings
    ADD CONSTRAINT tbl_thesaurus_mappings_issue_fkey FOREIGN KEY (issue) REFERENCES tbl_issues(id) ON DELETE CASCADE;


--
-- Name: tbl_thesaurus_mappings_term_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_thesaurus_mappings
    ADD CONSTRAINT tbl_thesaurus_mappings_term_fkey FOREIGN KEY (term) REFERENCES tbl_thesaurus(id) ON DELETE CASCADE;


--
-- Name: tbl_times_issue_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_times
    ADD CONSTRAINT tbl_times_issue_fkey FOREIGN KEY (issue) REFERENCES tbl_issues(id) ON DELETE CASCADE;


--
-- Name: tbl_times_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_times
    ADD CONSTRAINT tbl_times_user_fkey FOREIGN KEY (userid) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_user_preferences_identifier_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_user_preferences
    ADD CONSTRAINT tbl_user_preferences_identifier_fkey FOREIGN KEY (identifier) REFERENCES tbl_preference_descriptions(identifier) ON DELETE CASCADE;


--
-- Name: tbl_userdomains_domain_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_userdomains
    ADD CONSTRAINT tbl_userdomains_domain_fkey FOREIGN KEY ("domain") REFERENCES tbl_domains(id) ON DELETE CASCADE;


--
-- Name: tbl_userdomains_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_userdomains
    ADD CONSTRAINT tbl_userdomains_user_fkey FOREIGN KEY (userid) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_usersites_site_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_usersites
    ADD CONSTRAINT tbl_usersites_site_fkey FOREIGN KEY (site) REFERENCES tbl_sites(id) ON DELETE CASCADE;


--
-- Name: tbl_usersites_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_usersites
    ADD CONSTRAINT tbl_usersites_user_fkey FOREIGN KEY (userid) REFERENCES tbl_users(id) ON DELETE CASCADE;


--
-- Name: tbl_usersites_usertype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: helpdesk
--

ALTER TABLE ONLY tbl_usersites
    ADD CONSTRAINT tbl_usersites_usertype_fkey FOREIGN KEY (usertype) REFERENCES tbl_usertypes(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

