--
-- PostgreSQL database dump
--

SET search_path = public, pg_catalog;

--
-- TOC entry 2 (OID 17132)
-- Name: country; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE country (
    id serial NOT NULL,
    name character varying(40) NOT NULL
);


--
-- TOC entry 3 (OID 17137)
-- Name: client; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE client (
    id serial NOT NULL,
    firstname character varying(40) NOT NULL,
    lastname character varying(40) NOT NULL,
    address1 character varying(40) NOT NULL,
    address2 character varying(40),
    country integer NOT NULL,
    town character varying(50) NOT NULL,
    zipcode character(5) NOT NULL,
    state character varying(40),
    active boolean DEFAULT false NOT NULL,
    phone character varying(20),
    mobile character varying(20),
    reseller_id integer
);


--
-- TOC entry 4 (OID 17143)
-- Name: reseller; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE reseller (
    id serial NOT NULL,
    name character varying(40) NOT NULL
);


--
-- TOC entry 5 (OID 17148)
-- Name: email; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE email (
    id serial NOT NULL,
    email character varying(128) NOT NULL,
    client integer,
    verified boolean DEFAULT false NOT NULL
);


--
-- TOC entry 6 (OID 17154)
-- Name: sysuser; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE sysuser (
    id serial NOT NULL,
    name character varying(12) NOT NULL,
    "type" integer DEFAULT 0 NOT NULL,
    home character varying(128),
    shell boolean,
    "password" character varying(64),
    client integer NOT NULL,
    toupdate boolean DEFAULT false NOT NULL,
    md5pass character varying(32),
    sysuid integer
);


--
-- TOC entry 7 (OID 17161)
-- Name: domain; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE "domain" (
    id serial NOT NULL,
    domainname character varying(64) NOT NULL,
    client integer NOT NULL,
    status integer DEFAULT 0 NOT NULL
);


--
-- TOC entry 8 (OID 17167)
-- Name: zone; Type: TABLE; Schema: public; Owner: gnuviech
--

CREATE TABLE "zone" (
    id serial NOT NULL,
    "domain" integer NOT NULL,
    "type" character varying(5) NOT NULL,
    ttl integer NOT NULL,
    mxprio integer,
    resource character varying(256),
    toupdate boolean DEFAULT false NOT NULL
);


--
-- TOC entry 12 (OID 17171)
-- Name: reseller_name_idx; Type: INDEX; Schema: public; Owner: gnuviech
--

CREATE UNIQUE INDEX reseller_name_idx ON reseller USING btree (name);


--
-- TOC entry 9 (OID 17172)
-- Name: country_name_idx; Type: INDEX; Schema: public; Owner: gnuviech
--

CREATE UNIQUE INDEX country_name_idx ON country USING btree (name);


--
-- TOC entry 19 (OID 17173)
-- Name: sysuser_type_idx; Type: INDEX; Schema: public; Owner: gnuviech
--

CREATE INDEX sysuser_type_idx ON sysuser USING btree ("type");


--
-- TOC entry 18 (OID 17231)
-- Name: sysuser_sysuid_idx; Type: INDEX; Schema: public; Owner: gnuviech
--

CREATE UNIQUE INDEX sysuser_sysuid_idx ON sysuser USING btree (sysuid);


--
-- TOC entry 10 (OID 17174)
-- Name: country_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY country
    ADD CONSTRAINT country_pkey PRIMARY KEY (id);


--
-- TOC entry 11 (OID 17176)
-- Name: client_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY client
    ADD CONSTRAINT client_pkey PRIMARY KEY (id);


--
-- TOC entry 22 (OID 17178)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY client
    ADD CONSTRAINT "$1" FOREIGN KEY (country) REFERENCES country(id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 13 (OID 17182)
-- Name: reseller_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY reseller
    ADD CONSTRAINT reseller_pkey PRIMARY KEY (id);


--
-- TOC entry 23 (OID 17184)
-- Name: $2; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY client
    ADD CONSTRAINT "$2" FOREIGN KEY (reseller_id) REFERENCES reseller(id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 15 (OID 17188)
-- Name: email_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY email
    ADD CONSTRAINT email_pkey PRIMARY KEY (id);


--
-- TOC entry 14 (OID 17190)
-- Name: email_email_key; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY email
    ADD CONSTRAINT email_email_key UNIQUE (email);


--
-- TOC entry 24 (OID 17192)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY email
    ADD CONSTRAINT "$1" FOREIGN KEY (client) REFERENCES client(id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 17 (OID 17196)
-- Name: sysuser_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY sysuser
    ADD CONSTRAINT sysuser_pkey PRIMARY KEY (id);


--
-- TOC entry 16 (OID 17198)
-- Name: sysuser_name_key; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY sysuser
    ADD CONSTRAINT sysuser_name_key UNIQUE (name);


--
-- TOC entry 25 (OID 17200)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY sysuser
    ADD CONSTRAINT "$1" FOREIGN KEY (client) REFERENCES client(id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 20 (OID 17204)
-- Name: domain_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY "domain"
    ADD CONSTRAINT domain_pkey PRIMARY KEY (id);


--
-- TOC entry 26 (OID 17206)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY "domain"
    ADD CONSTRAINT "$1" FOREIGN KEY (client) REFERENCES client(id) ON UPDATE NO ACTION ON DELETE NO ACTION;


--
-- TOC entry 21 (OID 17210)
-- Name: zone_pkey; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY "zone"
    ADD CONSTRAINT zone_pkey PRIMARY KEY (id);


--
-- TOC entry 27 (OID 17212)
-- Name: $1; Type: CONSTRAINT; Schema: public; Owner: gnuviech
--

ALTER TABLE ONLY "zone"
    ADD CONSTRAINT "$1" FOREIGN KEY ("domain") REFERENCES "domain"(id) ON UPDATE NO ACTION ON DELETE NO ACTION;


