scripts/oracle/or_create.sql
58dc550c
 CREATE TABLE acc (
0aaa6f74
     id INT NOT NULL,
2d5eff87
     server_id INT NOT NULL DEFAULT '0',
0aaa6f74
     from_uid VARCHAR(64),
     to_uid VARCHAR(64),
     to_did VARCHAR(64),
     from_did VARCHAR(64),
     sip_from VARCHAR(255),
     sip_to VARCHAR(255),
e3f13759
     sip_status INT,
0aaa6f74
     sip_method VARCHAR(16),
     in_ruri VARCHAR(255),
     out_ruri VARCHAR(255),
     from_uri VARCHAR(255),
     to_uri VARCHAR(255),
     sip_callid VARCHAR(255),
     sip_cseq INT,
     digest_username VARCHAR(64),
     digest_realm VARCHAR(255),
     from_tag VARCHAR(128),
     to_tag VARCHAR(128),
     src_ip INT UNSIGNED,
     src_port SMALLINT UNSIGNED,
     request_timestamp DATETIME NOT NULL,
     response_timestamp DATETIME NOT NULL,
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     attrs VARCHAR(255),
2d5eff87
     UNIQUE KEY acc_id_key (server_id, id),
ef5eee79
     KEY acc_cid_key (sip_callid),
     KEY acc_from_uid (from_uid),
     KEY acc_to_uid (to_uid)
58dc550c
 );
 
 CREATE TABLE missed_calls (
0aaa6f74
     id INT NOT NULL,
2d5eff87
     server_id INT NOT NULL DEFAULT '0',
0aaa6f74
     from_uid VARCHAR(64),
     to_uid VARCHAR(64),
     to_did VARCHAR(64),
     from_did VARCHAR(64),
     sip_from VARCHAR(255),
     sip_to VARCHAR(255),
e3f13759
     sip_status INT,
0aaa6f74
     sip_method VARCHAR(16),
     in_ruri VARCHAR(255),
     out_ruri VARCHAR(255),
     from_uri VARCHAR(255),
     to_uri VARCHAR(255),
     sip_callid VARCHAR(255),
     sip_cseq INT,
     digest_username VARCHAR(64),
     digest_realm VARCHAR(255),
     from_tag VARCHAR(128),
     to_tag VARCHAR(128),
     src_ip INT UNSIGNED,
     src_port SMALLINT UNSIGNED,
     request_timestamp DATETIME NOT NULL,
     response_timestamp DATETIME NOT NULL,
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     attrs VARCHAR(255),
2d5eff87
     UNIQUE KEY mc_id_key (server_id, id),
cd4a536d
     KEY mc_cid_key (sip_callid),
     KEY mc_to_uid (to_uid)
58dc550c
 );
 
 CREATE TABLE credentials (
0aaa6f74
     auth_username VARCHAR(64) NOT NULL,
     did VARCHAR(64) NOT NULL DEFAULT '_default',
     realm VARCHAR(64) NOT NULL,
     password VARCHAR(28) NOT NULL DEFAULT '',
     flags INT NOT NULL DEFAULT '0',
     ha1 VARCHAR(32) NOT NULL,
     ha1b VARCHAR(32) NOT NULL DEFAULT '',
     uuid VARCHAR(64) NOT NULL,
     KEY cred_idx (auth_username, did),
cf61e681
     KEY uuid (uuid),
     KEY did_idx (did),
     KEY realm_idx (realm)
58dc550c
 );
 
 CREATE TABLE attr_types (
0aaa6f74
     name VARCHAR(32) NOT NULL,
     rich_type VARCHAR(32) NOT NULL DEFAULT 'string',
     raw_type INT NOT NULL DEFAULT '2',
     type_spec VARCHAR(255) DEFAULT NULL,
     description VARCHAR(255) DEFAULT NULL,
     default_flags INT NOT NULL DEFAULT '0',
     flags INT NOT NULL DEFAULT '0',
     priority INT NOT NULL DEFAULT '0',
8b4007ba
     attr_access INT NOT NULL DEFAULT '0',
0aaa6f74
     ordering INT NOT NULL DEFAULT '0',
1d2cb9e0
     grp VARCHAR(32) NOT NULL DEFAULT 'other',
0aaa6f74
     UNIQUE KEY upt_idx1 (name)
58dc550c
 );
 
 CREATE TABLE global_attrs (
0aaa6f74
     name VARCHAR(32) NOT NULL,
     type INT NOT NULL DEFAULT '0',
     value VARCHAR(255),
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY global_attrs_idx (name, value)
58dc550c
 );
 
 CREATE TABLE domain_attrs (
0aaa6f74
     did VARCHAR(64),
     name VARCHAR(32) NOT NULL,
     type INT NOT NULL DEFAULT '0',
     value VARCHAR(255),
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY domain_attr_idx (did, name, value),
     KEY domain_did (did, flags)
58dc550c
 );
 
 CREATE TABLE user_attrs (
0aaa6f74
     uuid VARCHAR(64) NOT NULL,
     name VARCHAR(32) NOT NULL,
     value VARCHAR(255),
     type INT NOT NULL DEFAULT '0',
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY userattrs_idx (uuid, name, value)
58dc550c
 );
 
f223fdcf
 CREATE TABLE uri_attrs (
0aaa6f74
     username VARCHAR(64) NOT NULL,
     did VARCHAR(64) NOT NULL,
     name VARCHAR(32) NOT NULL,
     value VARCHAR(255),
     type INT NOT NULL DEFAULT '0',
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     scheme VARCHAR(8) NOT NULL DEFAULT 'sip',
     UNIQUE KEY uriattrs_idx (username, did, name, value, scheme)
f223fdcf
 );
 
58dc550c
 CREATE TABLE domain (
0aaa6f74
     did VARCHAR(64) NOT NULL,
     domain VARCHAR(128) NOT NULL,
     flags INT UNSIGNED NOT NULL DEFAULT '0',
cf61e681
     UNIQUE KEY domain_idx (domain),
     KEY did_idx (did)
58dc550c
 );
 
fd7dba07
 CREATE TABLE domain_settings (
0aaa6f74
     did VARCHAR(64) NOT NULL,
     filename VARCHAR(255) NOT NULL,
     version INT UNSIGNED NOT NULL,
     timestamp INT UNSIGNED,
     content BLOB,
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY ds_id (did, filename, version),
     KEY ds_df (did, filename)
fd7dba07
 );
 
58dc550c
 CREATE TABLE location (
0aaa6f74
     uuid VARCHAR(64) NOT NULL,
     aor VARCHAR(255) NOT NULL,
     contact VARCHAR(255) NOT NULL,
2d5eff87
     server_id INT NOT NULL DEFAULT '0',
0aaa6f74
     received VARCHAR(255),
     expires DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
     q FLOAT NOT NULL DEFAULT '1.0',
     callid VARCHAR(255),
     cseq INT UNSIGNED,
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     user_agent VARCHAR(64),
     instance VARCHAR(255),
     UNIQUE KEY location_key (uuid, contact),
6909b18b
     KEY location_contact (contact),
     KEY location_expires (expires)
58dc550c
 );
 
11ade778
 CREATE TABLE contact_attrs (
0aaa6f74
     uuid VARCHAR(64) NOT NULL,
     contact VARCHAR(255) NOT NULL,
     name VARCHAR(32) NOT NULL,
     value VARCHAR(255),
     type INT NOT NULL DEFAULT '0',
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY contactattrs_idx (uuid, contact, name)
11ade778
 );
 
58dc550c
 CREATE TABLE trusted (
0aaa6f74
     src_ip VARCHAR(39) NOT NULL,
     proto VARCHAR(4) NOT NULL,
     from_pattern VARCHAR(64) NOT NULL,
     UNIQUE KEY trusted_idx (src_ip, proto, from_pattern)
58dc550c
 );
 
f0167465
 CREATE TABLE ipmatch (
0aaa6f74
     ip VARCHAR(50) NOT NULL DEFAULT '',
     avp_val VARCHAR(30) DEFAULT NULL,
     mark INT(10) UNSIGNED NOT NULL DEFAULT '1',
     flags INT(10) UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY ipmatch_idx (ip, mark)
f0167465
 );
 
58dc550c
 CREATE TABLE phonebook (
0aaa6f74
     id INT UNSIGNED NOT NULL,
     uuid VARCHAR(64) NOT NULL,
     fname VARCHAR(32),
     lname VARCHAR(32),
     sip_uri VARCHAR(255) NOT NULL,
     UNIQUE KEY pb_idx (id),
     KEY pb_uid (uuid)
58dc550c
 );
 
 CREATE TABLE gw (
0aaa6f74
     gw_name VARCHAR(128) NOT NULL,
     ip_addr INT UNSIGNED NOT NULL,
     port SMALLINT UNSIGNED,
     uri_scheme TINYINT UNSIGNED,
     transport SMALLINT UNSIGNED,
629a255e
     prefix VARCHAR(16) NOT NULL,
0aaa6f74
     grp_id INT NOT NULL,
     UNIQUE KEY gw_idx1 (gw_name),
     KEY gw_idx2 (grp_id)
58dc550c
 );
 
 CREATE TABLE gw_grp (
0aaa6f74
     grp_id INT NOT NULL,
     grp_name VARCHAR(64) NOT NULL,
     UNIQUE KEY gwgrp_idx (grp_id)
58dc550c
 );
 
 CREATE TABLE lcr (
0aaa6f74
     prefix VARCHAR(16) NOT NULL,
     from_uri VARCHAR(255) NOT NULL DEFAULT '%',
     grp_id INT,
     priority INT,
     KEY lcr_idx1 (prefix),
     KEY lcr_idx2 (from_uri),
     KEY lcr_idx3 (grp_id)
58dc550c
 );
 
a6ba579e
 CREATE TABLE grp (
0aaa6f74
     uuid VARCHAR(64) NOT NULL DEFAULT '',
     grp VARCHAR(64) NOT NULL DEFAULT '',
     last_modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
     KEY grp_idx (uuid, grp)
a6ba579e
 );
 
58dc550c
 CREATE TABLE silo (
0aaa6f74
     mid INT NOT NULL,
     from_hdr VARCHAR(255) NOT NULL,
     to_hdr VARCHAR(255) NOT NULL,
     ruri VARCHAR(255) NOT NULL,
     uuid VARCHAR(64) NOT NULL,
     inc_time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
     exp_time DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',
     ctype VARCHAR(128) NOT NULL DEFAULT 'text/plain',
     body BLOB NOT NULL DEFAULT '',
     UNIQUE KEY silo_idx1 (mid)
58dc550c
 );
 
 CREATE TABLE uri (
0aaa6f74
     uuid VARCHAR(64) NOT NULL,
     did VARCHAR(64) NOT NULL,
     username VARCHAR(64) NOT NULL,
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     scheme VARCHAR(8) NOT NULL DEFAULT 'sip',
     KEY uri_idx1 (username, did, scheme),
     KEY uri_uid (uuid)
58dc550c
 );
 
 CREATE TABLE speed_dial (
0aaa6f74
     id INT NOT NULL,
     uuid VARCHAR(64) NOT NULL,
     dial_username VARCHAR(64) NOT NULL,
     dial_did VARCHAR(64) NOT NULL,
     new_uri VARCHAR(255) NOT NULL,
     UNIQUE KEY speeddial_idx1 (uuid, dial_did, dial_username),
     UNIQUE KEY speeddial_id (id),
     KEY speeddial_uid (uuid)
58dc550c
 );
 
 CREATE TABLE sd_attrs (
0aaa6f74
     id VARCHAR(64) NOT NULL,
     name VARCHAR(32) NOT NULL,
     value VARCHAR(255),
     type INT NOT NULL DEFAULT '0',
     flags INT UNSIGNED NOT NULL DEFAULT '0',
     UNIQUE KEY sd_idx (id, name, value)
58dc550c
 );
 
 CREATE TABLE presentity (
0aaa6f74
     pres_id VARCHAR(64) NOT NULL,
     uri VARCHAR(255) NOT NULL,
     uuid VARCHAR(64) NOT NULL,
     pdomain VARCHAR(128) NOT NULL,
     xcap_params BLOB NOT NULL,
     UNIQUE KEY presentity_key (pres_id)
58dc550c
 );
 
5d20a960
 CREATE TABLE presentity_notes (
0aaa6f74
     dbid VARCHAR(64) NOT NULL,
     pres_id VARCHAR(64) NOT NULL,
     etag VARCHAR(64) NOT NULL,
     note VARCHAR(128) NOT NULL,
     lang VARCHAR(64) NOT NULL,
     expires DATETIME NOT NULL DEFAULT '2005-12-07 08:13:15',
     UNIQUE KEY pnotes_idx1 (dbid)
5d20a960
 );
 
11ade778
 CREATE TABLE presentity_extensions (
0aaa6f74
     dbid VARCHAR(64) NOT NULL,
     pres_id VARCHAR(64) NOT NULL,
     etag VARCHAR(64) NOT NULL,
     element BLOB NOT NULL,
     expires DATETIME NOT NULL DEFAULT '2005-12-07 08:13:15',
     UNIQUE KEY presextensions_idx1 (dbid)
de0394c4
 );
 
58dc550c
 CREATE TABLE presentity_contact (
0aaa6f74
     pres_id VARCHAR(64) NOT NULL,
     basic INT(3) NOT NULL,
     expires DATETIME NOT NULL DEFAULT '2004-05-28 21:32:15',
     priority FLOAT NOT NULL DEFAULT '0.5',
     contact VARCHAR(255),
     tupleid VARCHAR(64) NOT NULL,
     etag VARCHAR(64) NOT NULL,
     published_id VARCHAR(64) NOT NULL,
     UNIQUE KEY presid_index (pres_id, tupleid)
58dc550c
 );
 
 CREATE TABLE watcherinfo (
0aaa6f74
     w_uri VARCHAR(255) NOT NULL,
     display_name VARCHAR(128) NOT NULL,
     s_id VARCHAR(64) NOT NULL,
     package VARCHAR(32) NOT NULL DEFAULT 'presence',
     status VARCHAR(32) NOT NULL DEFAULT 'pending',
     event VARCHAR(32) NOT NULL,
     expires DATETIME NOT NULL DEFAULT '2005-12-07 08:13:15',
     accepts INT NOT NULL,
     pres_id VARCHAR(64) NOT NULL,
     server_contact VARCHAR(255) NOT NULL,
     dialog BLOB NOT NULL,
     doc_index INT NOT NULL,
     UNIQUE KEY wi_idx1 (s_id)
58dc550c
 );
 
2cbeb3df
 CREATE TABLE tuple_notes (
0aaa6f74
     pres_id VARCHAR(64) NOT NULL,
     tupleid VARCHAR(64) NOT NULL,
     note VARCHAR(128) NOT NULL,
     lang VARCHAR(64) NOT NULL
2cbeb3df
 );
 
11ade778
 CREATE TABLE tuple_extensions (
0aaa6f74
     pres_id VARCHAR(64) NOT NULL,
     tupleid VARCHAR(64) NOT NULL,
     element BLOB NOT NULL,
     status_extension INT(1) NOT NULL
11ade778
 );
 
36f29438
 CREATE TABLE offline_winfo (
0aaa6f74
     uuid VARCHAR(64) NOT NULL,
     watcher VARCHAR(255) NOT NULL,
     events VARCHAR(64) NOT NULL,
     domain VARCHAR(128),
     status VARCHAR(32),
     created_on DATETIME NOT NULL DEFAULT '2006-01-31 13:13:13',
     expires_on DATETIME NOT NULL DEFAULT '2006-01-31 13:13:13',
     dbid INT(10) UNSIGNED NOT NULL,
a6b2e52d
     UNIQUE KEY offline_winfo_key (dbid)
36f29438
 );
 
77b36d49
 CREATE TABLE rls_subscription (
0aaa6f74
     id VARCHAR(48) NOT NULL,
     doc_version INT NOT NULL,
     dialog BLOB NOT NULL,
     expires DATETIME NOT NULL DEFAULT '2005-12-02 09:00:13',
     status INT NOT NULL,
     contact VARCHAR(255) NOT NULL,
     uri VARCHAR(255) NOT NULL,
     package VARCHAR(128) NOT NULL,
     w_uri VARCHAR(255) NOT NULL,
     xcap_params BLOB NOT NULL,
     UNIQUE KEY rls_subscription_key (id)
77b36d49
 );
 
 CREATE TABLE rls_vs (
0aaa6f74
     id VARCHAR(48) NOT NULL,
     rls_id VARCHAR(48) NOT NULL,
     uri VARCHAR(255) NOT NULL,
     UNIQUE KEY rls_vs_key (id)
77b36d49
 );
 
 CREATE TABLE rls_vs_names (
0aaa6f74
     id VARCHAR(48) NOT NULL,
     name VARCHAR(64),
     lang VARCHAR(64)
77b36d49
 );
 
1867e3f2
 CREATE TABLE i18n (
0aaa6f74
     code INT NOT NULL,
     reason_re VARCHAR(255) DEFAULT NULL,
     lang VARCHAR(32) NOT NULL,
     new_reason VARCHAR(255),
     KEY i18n_idx (code),
     UNIQUE KEY i18n_uniq_idx (code, lang)
4188caf1
 );
1867e3f2
 
ce6f458e
 CREATE TABLE pdt (
0aaa6f74
     prefix VARCHAR(32) NOT NULL,
     domain VARCHAR(255) NOT NULL,
     UNIQUE KEY pdt_idx (prefix)
ce6f458e
 );
 
390d5381
 CREATE TABLE cpl (
0aaa6f74
     uuid VARCHAR(64) NOT NULL,
     cpl_xml BLOB,
     cpl_bin BLOB,
     UNIQUE KEY cpl_key (uuid)
390d5381
 );
 
14bf4fda
 CREATE TABLE customers (
0aaa6f74
     cid INT UNSIGNED NOT NULL,
     name VARCHAR(128) NOT NULL,
     address VARCHAR(255),
     phone VARCHAR(64),
     email VARCHAR(255),
     UNIQUE KEY cu_idx (cid)
14bf4fda
 );
 
f0167465