--
-- (c) GPL 2007 Robert Sander <gurubert@gurubert.de> 
--

CREATE TABLE relaytofrom (
    id bigserial NOT NULL,
    relay_ip inet,
    mail_from character varying(255),
    rcpt_to character varying(255),
    block_expires timestamp with time zone DEFAULT '-infinity'::timestamp with time zone NOT NULL,
    record_expires timestamp with time zone DEFAULT 'infinity'::timestamp with time zone NOT NULL,
    blocked_count bigint DEFAULT 0::bigint NOT NULL,
    passed_count bigint DEFAULT 0::bigint NOT NULL,
    aborted_count bigint DEFAULT 0::bigint NOT NULL,
    origin_type character(1) DEFAULT 'M'::bpchar NOT NULL,
    create_time timestamp with time zone DEFAULT now() NOT NULL,
    last_update timestamp with time zone DEFAULT now() NOT NULL
);

CREATE INDEX block_expires_index ON relaytofrom USING btree (block_expires);

CREATE INDEX mail_from_index ON relaytofrom USING btree (mail_from);

CREATE INDEX origin_type_index ON relaytofrom USING btree (origin_type);

CREATE INDEX rcpt_to_index ON relaytofrom USING btree (rcpt_to);

CREATE INDEX record_expires_index ON relaytofrom USING btree (record_expires);

CREATE INDEX relay_ip_index ON relaytofrom USING btree (relay_ip);

ALTER TABLE ONLY relaytofrom
    ADD CONSTRAINT relaytofrom_pkey PRIMARY KEY (id);
