--
-- SERWEB PostgreSQL database dump
--


--
-- TOC entry 7 (OID 31248)
-- Name: location; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE "location" (
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    contact character varying(255) DEFAULT ''::character varying NOT NULL,
    expires timestamp without time zone,
    q double precision,
    callid character varying(255),
    cseq bigint,
    last_modified timestamp without time zone,
    replicate bigint,
    state smallint,
    flags bigint DEFAULT 0 NOT NULL
);



--
-- TOC entry 9 (OID 34980)
-- Name: version; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE "version" (
    table_name character varying(64) NOT NULL,
    table_version bigint DEFAULT 0 NOT NULL
);



--
-- TOC entry 19 (OID 70091)
-- Name: acc; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE acc (
    sip_from character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_to character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_status character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_method character varying(16) DEFAULT ''::character varying NOT NULL,
    i_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    o_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    from_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    to_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_callid character varying(128) DEFAULT ''::character varying NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    fromtag character varying(128) DEFAULT ''::character varying NOT NULL,
    totag character varying(128) DEFAULT ''::character varying NOT NULL,
    "time" timestamp without time zone NOT NULL,
    "timestamp" timestamp without time zone NOT NULL
);


--
-- TOC entry 20 (OID 70106)
-- Name: active_sessions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE active_sessions (
    sid character varying(32) DEFAULT ''::character varying NOT NULL,
    name character varying(32) DEFAULT ''::character varying NOT NULL,
    val text,
    changed character varying(14) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 21 (OID 70116)
-- Name: aliases; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE aliases (
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    contact character varying(255) DEFAULT ''::character varying NOT NULL,
    expires timestamp without time zone,
    q double precision,
    callid character varying(255),
    cseq integer,
    last_modified timestamp without time zone NOT NULL,
    replicate integer,
    state smallint,
    flags integer DEFAULT 0 NOT NULL,
    user_agent character varying(50) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 22 (OID 70127)
-- Name: event; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE event (
    id serial NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    uri character varying(255) DEFAULT ''::character varying NOT NULL,
    description character varying(255) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 23 (OID 70136)
-- Name: grp; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE grp (
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    grp character varying(50) DEFAULT ''::character varying NOT NULL,
    last_modified timestamp without time zone NOT NULL
);


--
-- TOC entry 24 (OID 70143)
-- Name: missed_calls; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE missed_calls (
    sip_from character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_to character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_status character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_method character varying(16) DEFAULT ''::character varying NOT NULL,
    i_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    o_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    from_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    to_uri character varying(128) DEFAULT ''::character varying NOT NULL,
    sip_callid character varying(128) DEFAULT ''::character varying NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    fromtag character varying(128) DEFAULT ''::character varying NOT NULL,
    totag character varying(128) DEFAULT ''::character varying NOT NULL,
    "time" timestamp without time zone NOT NULL,
    "timestamp" timestamp without time zone NOT NULL
);


--
-- TOC entry 25 (OID 70158)
-- Name: pending; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE pending (
    phplib_id character varying(32) DEFAULT ''::character varying NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    "password" character varying(25) DEFAULT ''::character varying NOT NULL,
    first_name character varying(25) DEFAULT ''::character varying NOT NULL,
    last_name character varying(45) DEFAULT ''::character varying NOT NULL,
    phone character varying(15) DEFAULT ''::character varying NOT NULL,
    email_address character varying(50) DEFAULT ''::character varying NOT NULL,
    datetime_created timestamp without time zone NOT NULL,
    datetime_modified timestamp without time zone NOT NULL,
    confirmation character varying(64) DEFAULT ''::character varying NOT NULL,
    flag character(1) DEFAULT 'o'::bpchar NOT NULL,
    sendnotification character varying(50) DEFAULT ''::character varying NOT NULL,
    greeting character varying(50) DEFAULT ''::character varying NOT NULL,
    ha1 character varying(128) DEFAULT ''::character varying NOT NULL,
    ha1b character varying(128) DEFAULT ''::character varying NOT NULL,
    perms character varying(32),
    allow_find character(1) DEFAULT '0'::bpchar NOT NULL,
    timezone character varying(128),
    rpid character varying(128)
);


--
-- TOC entry 5 (OID 70191)
-- Name: id_phonebook_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


--
-- TOC entry 26 (OID 70193)
-- Name: phonebook; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE phonebook (
    id integer DEFAULT nextval('id_phonebook_seq'::text) NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    fname character varying(32) DEFAULT ''::character varying NOT NULL,
    lname character varying(32) DEFAULT ''::character varying NOT NULL,
    sip_uri character varying(128) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 27 (OID 70203)
-- Name: reserved; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE reserved (
    username character(64) DEFAULT ''::bpchar NOT NULL
);


--
-- TOC entry 28 (OID 70208)
-- Name: subscriber; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE subscriber (
    phplib_id character varying(32) DEFAULT ''::character varying NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    "password" character varying(25) DEFAULT ''::character varying NOT NULL,
    first_name character varying(25) DEFAULT ''::character varying NOT NULL,
    last_name character varying(45) DEFAULT ''::character varying NOT NULL,
    phone character varying(15) DEFAULT ''::character varying NOT NULL,
    email_address character varying(50) DEFAULT ''::character varying NOT NULL,
    datetime_created timestamp without time zone NOT NULL,
    datetime_modified timestamp without time zone NOT NULL,
    confirmation character varying(64) DEFAULT ''::character varying NOT NULL,
    flag character(1) DEFAULT 'o'::bpchar NOT NULL,
    sendnotification character varying(50) DEFAULT ''::character varying NOT NULL,
    greeting character varying(50) DEFAULT ''::character varying NOT NULL,
    ha1 character varying(128) DEFAULT ''::character varying NOT NULL,
    ha1b character varying(128) DEFAULT ''::character varying NOT NULL,
    perms character varying(32),
    allow_find character(1) DEFAULT '0'::bpchar NOT NULL,
    timezone character varying(128),
    rpid character varying(128)
);


--
-- TOC entry 29 (OID 70229)
-- Name: config; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE config (
    attribute character varying(32) NOT NULL,
    value character varying(128) NOT NULL,
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    modified timestamp without time zone
);


--
-- TOC entry 6 (OID 70243)
-- Name: mid_silo_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


--
-- TOC entry 30 (OID 70245)
-- Name: silo; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE silo (
    mid integer DEFAULT nextval('mid_silo_seq'::text) NOT NULL,
    src_addr character varying(255) DEFAULT ''::character varying NOT NULL,
    dst_addr character varying(255) DEFAULT ''::character varying NOT NULL,
    r_uri character varying(255) DEFAULT ''::character varying NOT NULL,
    inc_time integer DEFAULT 0 NOT NULL,
    exp_time integer DEFAULT 0 NOT NULL,
    ctype character varying(32) DEFAULT 'text/plain'::character varying NOT NULL,
    body bytea DEFAULT ''::bytea NOT NULL
);


--
-- TOC entry 31 (OID 70260)
-- Name: domain; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE "domain" (
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    last_modified timestamp without time zone NOT NULL
);


--
-- TOC entry 32 (OID 70265)
-- Name: uri; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE uri (
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    uri_user character varying(50) DEFAULT ''::character varying NOT NULL,
    last_modified timestamp without time zone NOT NULL
);


--
-- TOC entry 33 (OID 70272)
-- Name: server_monitoring; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE server_monitoring (
    "time" timestamp without time zone NOT NULL,
    id integer DEFAULT 0 NOT NULL,
    param character varying(32) DEFAULT ''::character varying NOT NULL,
    value integer DEFAULT 0 NOT NULL,
    "increment" integer DEFAULT 0 NOT NULL
);


--
-- TOC entry 34 (OID 70280)
-- Name: preferences; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE preferences (
    username character varying(64) DEFAULT ''::character varying NOT NULL,
    "domain" character varying(128) DEFAULT ''::character varying NOT NULL,
    attribute character varying(50) DEFAULT ''::character varying NOT NULL,
    value character varying(100) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 35 (OID 70288)
-- Name: server_monitoring_agg; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE server_monitoring_agg (
    param character varying(32) DEFAULT ''::character varying NOT NULL,
    s_value integer DEFAULT 0 NOT NULL,
    s_increment integer DEFAULT 0 NOT NULL,
    last_aggregated_increment integer DEFAULT 0 NOT NULL,
    av double precision DEFAULT 0::double precision NOT NULL,
    mv integer DEFAULT 0 NOT NULL,
    ad double precision DEFAULT 0::double precision NOT NULL,
    lv integer DEFAULT 0 NOT NULL,
    min_val integer DEFAULT 0 NOT NULL,
    max_val integer DEFAULT 0 NOT NULL,
    min_inc integer DEFAULT 0 NOT NULL,
    max_inc integer DEFAULT 0 NOT NULL,
    lastupdate timestamp without time zone NOT NULL
);



--
-- TOC entry 36 (OID 31254)
-- Name: location_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY "location"
    ADD CONSTRAINT location_pkey PRIMARY KEY (username, "domain", contact);



--
-- TOC entry 43 (OID 70114)
-- Name: active_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY active_sessions
    ADD CONSTRAINT active_sessions_pkey PRIMARY KEY (name, sid);


--
-- TOC entry 44 (OID 70123)
-- Name: aliases_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY aliases
    ADD CONSTRAINT aliases_pkey PRIMARY KEY (username, "domain", contact);


--
-- TOC entry 45 (OID 70134)
-- Name: event_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY event
    ADD CONSTRAINT event_pkey PRIMARY KEY (id);


--
-- TOC entry 46 (OID 70141)
-- Name: grp_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY grp
    ADD CONSTRAINT grp_pkey PRIMARY KEY (username, "domain", grp);


--
-- TOC entry 48 (OID 70175)
-- Name: pending_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY pending
    ADD CONSTRAINT pending_pkey PRIMARY KEY (username, "domain");


--
-- TOC entry 47 (OID 70177)
-- Name: pending_phplib_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY pending
    ADD CONSTRAINT pending_phplib_id_key UNIQUE (phplib_id);


--
-- TOC entry 49 (OID 70201)
-- Name: phonebook_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY phonebook
    ADD CONSTRAINT phonebook_pkey PRIMARY KEY (id);


--
-- TOC entry 50 (OID 70206)
-- Name: reserved_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY reserved
    ADD CONSTRAINT reserved_username_key UNIQUE (username);


--
-- TOC entry 52 (OID 70225)
-- Name: subscriber_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY subscriber
    ADD CONSTRAINT subscriber_pkey PRIMARY KEY (username, "domain");


--
-- TOC entry 51 (OID 70227)
-- Name: subscriber_phplib_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY subscriber
    ADD CONSTRAINT subscriber_phplib_id_key UNIQUE (phplib_id);


--
-- TOC entry 53 (OID 70258)
-- Name: silo_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY silo
    ADD CONSTRAINT silo_pkey PRIMARY KEY (mid);


--
-- TOC entry 54 (OID 70263)
-- Name: domain_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

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


--
-- TOC entry 55 (OID 70270)
-- Name: uri_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY uri
    ADD CONSTRAINT uri_pkey PRIMARY KEY (username, "domain", uri_user);


--
-- TOC entry 56 (OID 70278)
-- Name: server_monitoring_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY server_monitoring
    ADD CONSTRAINT server_monitoring_pkey PRIMARY KEY (id, param);


--
-- TOC entry 57 (OID 70286)
-- Name: preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY preferences
    ADD CONSTRAINT preferences_pkey PRIMARY KEY (username, "domain", attribute);


--
-- TOC entry 58 (OID 70302)
-- Name: server_monitoring_agg_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY server_monitoring_agg
    ADD CONSTRAINT server_monitoring_agg_pkey PRIMARY KEY (param);






