CREATE TABLE sip_trace (
    id SERIAL PRIMARY KEY NOT NULL,
    time_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
    time_us INTEGER DEFAULT 0 NOT NULL,
    callid VARCHAR(255) DEFAULT '' NOT NULL,
    traced_user VARCHAR(255) DEFAULT '' NOT NULL,
    msg TEXT NOT NULL,
    method VARCHAR(50) DEFAULT '' NOT NULL,
    status VARCHAR(255) DEFAULT '' NOT NULL,
    fromip VARCHAR(64) DEFAULT '' NOT NULL,
    toip VARCHAR(64) DEFAULT '' NOT NULL,
    fromtag VARCHAR(128) DEFAULT '' NOT NULL,
    totag VARCHAR(128) DEFAULT '' NOT NULL,
    direction VARCHAR(4) DEFAULT '' NOT NULL
);

CREATE INDEX sip_trace_traced_user_idx ON sip_trace (traced_user);
CREATE INDEX sip_trace_date_idx ON sip_trace (time_stamp);
CREATE INDEX sip_trace_fromip_idx ON sip_trace (fromip);
CREATE INDEX sip_trace_callid_idx ON sip_trace (callid);

INSERT INTO version (table_name, table_version) values ('sip_trace','4');

