or_create.sql 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. CREATE TABLE version (
  2. table_name string(32) NOT NULL,
  3. table_version int NOT NULL DEFAULT '0'
  4. );
  5. INSERT INTO version (table_name, table_version) VALUES ('acc', '3');
  6. INSERT INTO version (table_name, table_version) VALUES ('missed_calls', '3');
  7. INSERT INTO version (table_name, table_version) VALUES ('location', '8');
  8. INSERT INTO version (table_name, table_version) VALUES ('credentials', '6');
  9. INSERT INTO version (table_name, table_version) VALUES ('domain', '2');
  10. INSERT INTO version (table_name, table_version) VALUES ('attr_types', '1');
  11. INSERT INTO version (table_name, table_version) VALUES ('global_attrs', '1');
  12. INSERT INTO version (table_name, table_version) VALUES ('domain_attrs', '1');
  13. INSERT INTO version (table_name, table_version) VALUES ('user_attrs', '3');
  14. INSERT INTO version (table_name, table_version) VALUES ('phonebook', '1');
  15. INSERT INTO version (table_name, table_version) VALUES ('silo', '3');
  16. INSERT INTO version (table_name, table_version) VALUES ('uri', '2');
  17. INSERT INTO version (table_name, table_version) VALUES ('server_monitoring', '1');
  18. INSERT INTO version (table_name, table_version) VALUES ('trusted', '1');
  19. INSERT INTO version (table_name, table_version) VALUES ('server_monitoring_agg', '1');
  20. INSERT INTO version (table_name, table_version) VALUES ('speed_dial', '2');
  21. INSERT INTO version (table_name, table_version) VALUES ('sd_attrs', '1');
  22. INSERT INTO version (table_name, table_version) VALUES ('gw', '2');
  23. INSERT INTO version (table_name, table_version) VALUES ('gw_grp', '2');
  24. INSERT INTO version (table_name, table_version) VALUES ('lcr', '1');
  25. INSERT INTO version (table_name, table_version) VALUES ('presentity', '1');
  26. INSERT INTO version (table_name, table_version) VALUES ('presentity_contact', '1');
  27. INSERT INTO version (table_name, table_version) VALUES ('watcherinfo', '1');
  28. CREATE TABLE acc (
  29. id int NOT NULL,
  30. from_uid string(64),
  31. to_uid string(64),
  32. to_did string(64),
  33. from_did string(64),
  34. sip_from string(255),
  35. sip_to string(255),
  36. sip_status string(128),
  37. sip_method string(16),
  38. in_ruri string(255),
  39. out_ruri string(255),
  40. from_uri string(255),
  41. to_uri string(255),
  42. sip_callid string(255),
  43. sip_cseq int,
  44. digest_username string(64),
  45. digest_realm string(255),
  46. from_tag string(128),
  47. to_tag string(128),
  48. src_ip int,
  49. src_port short,
  50. request_timestamp datetime NOT NULL,
  51. response_timestamp datetime NOT NULL,
  52. flags int NOT NULL DEFAULT '0',
  53. attrs string(255),
  54. id_key UNIQUE (id, ),
  55. );
  56. CREATE TABLE missed_calls (
  57. id int NOT NULL,
  58. from_uid string(64),
  59. to_uid string(64),
  60. to_did string(64),
  61. from_did string(64),
  62. sip_from string(255),
  63. sip_to string(255),
  64. sip_status string(128),
  65. sip_method string(16),
  66. inbound_ruri string(255),
  67. outbound_ruri string(255),
  68. from_uri string(255),
  69. to_uri string(255),
  70. sip_callid string(255),
  71. sip_cseq int,
  72. digest_username string(64),
  73. digest_realm string(255),
  74. from_tag string(128),
  75. to_tag string(128),
  76. request_timestamp datetime NOT NULL,
  77. response_timestamp datetime NOT NULL,
  78. flags int NOT NULL DEFAULT '0',
  79. attrs string(255),
  80. id_key UNIQUE (id, ),
  81. );
  82. CREATE TABLE credentials (
  83. auth_username string(64) NOT NULL,
  84. realm string(64) NOT NULL,
  85. password string(28) NOT NULL DEFAULT '',
  86. flags int NOT NULL DEFAULT '0',
  87. ha1 string(32) NOT NULL,
  88. ha1b string(32) NOT NULL DEFAULT '',
  89. uid string(64) NOT NULL,
  90. UNIQUE (auth_username, realm, ),
  91. );
  92. CREATE TABLE attr_types (
  93. name string(32) NOT NULL,
  94. rich_type string(32) NOT NULL DEFAULT 'string',
  95. raw_type int NOT NULL DEFAULT '2',
  96. type_spec string(255) DEFAULT NULL
  97. );
  98. INSERT INTO attr_types (name, raw_type) VALUES ('uid', '2');
  99. INSERT INTO attr_types (name, raw_type) VALUES ('did', '2');
  100. INSERT INTO attr_types (name, raw_type) VALUES ('digest_realm', '2');
  101. INSERT INTO attr_types (name, raw_type) VALUES ('rpid', '2');
  102. INSERT INTO attr_types (name, raw_type) VALUES ('fr_timer', '0');
  103. INSERT INTO attr_types (name, raw_type) VALUES ('fr_inv_timer', '2');
  104. INSERT INTO attr_types (name, raw_type) VALUES ('flags', '0');
  105. CREATE TABLE global_attrs (
  106. name string(32) NOT NULL,
  107. type int NOT NULL DEFAULT '0',
  108. value string(64),
  109. flags int NOT NULL DEFAULT '0',
  110. global_attrs_idx UNIQUE (name, value, )
  111. );
  112. CREATE TABLE domain_attrs (
  113. did string(64),
  114. name string(32) NOT NULL,
  115. type int NOT NULL DEFAULT '0',
  116. value string(64),
  117. flags int NOT NULL DEFAULT '0',
  118. domain_attr_idx UNIQUE (did, name, value, ),
  119. );
  120. CREATE TABLE user_attrs (
  121. uid string(64) NOT NULL,
  122. name string(32) NOT NULL,
  123. value string(64),
  124. type int NOT NULL DEFAULT '0',
  125. flags int NOT NULL DEFAULT '0',
  126. userattrs_idx UNIQUE (uid, name, value, )
  127. );
  128. CREATE TABLE domain (
  129. did string(64) NOT NULL,
  130. domain string(128) NOT NULL,
  131. last_modified datetime NOT NULL,
  132. flags int NOT NULL DEFAULT '0',
  133. domain_idx UNIQUE (did, domain, )
  134. );
  135. CREATE TABLE location (
  136. uid string(64) NOT NULL,
  137. contact string(255) NOT NULL,
  138. received string(255),
  139. expires datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  140. q float NOT NULL DEFAULT '1.0',
  141. callid string(255),
  142. cseq int,
  143. flags int NOT NULL DEFAULT '0',
  144. user_agent string(64),
  145. instance string(255),
  146. location_key UNIQUE (uid, contact, ),
  147. );
  148. CREATE TABLE trusted (
  149. src_ip string(39) NOT NULL,
  150. proto string(4) NOT NULL,
  151. from_pattern string(64) NOT NULL,
  152. trusted_idx UNIQUE (src_ip, proto, from_pattern, )
  153. );
  154. CREATE TABLE server_monitoring (
  155. time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  156. id int NOT NULL DEFAULT '0',
  157. param string(32) NOT NULL DEFAULT '',
  158. value int NOT NULL DEFAULT '0',
  159. increment int NOT NULL DEFAULT '0'
  160. );
  161. CREATE TABLE server_monitoring_agg (
  162. param string(32) NOT NULL DEFAULT '',
  163. s_value int NOT NULL DEFAULT '0',
  164. s_increment int NOT NULL DEFAULT '0',
  165. last_aggregated_increment int NOT NULL DEFAULT '0',
  166. av double NOT NULL DEFAULT '0',
  167. mv int NOT NULL DEFAULT '0',
  168. ad double NOT NULL DEFAULT '0',
  169. lv int NOT NULL DEFAULT '0',
  170. min_val int NOT NULL DEFAULT '0',
  171. max_val int NOT NULL DEFAULT '0',
  172. min_inc int NOT NULL DEFAULT '0',
  173. max_inc int NOT NULL DEFAULT '0',
  174. lastupdate datetime NOT NULL DEFAULT '1970-01-01 00:00:00'
  175. );
  176. CREATE TABLE phonebook (
  177. id int NOT NULL,
  178. uid string(64) NOT NULL,
  179. fname string(32),
  180. lname string(32),
  181. sip_uri string(255) NOT NULL,
  182. pb_idx UNIQUE (id, ),
  183. );
  184. CREATE TABLE gw (
  185. gw_name string(128) NOT NULL,
  186. ip_addr int NOT NULL,
  187. port short,
  188. uri_scheme char,
  189. transport short,
  190. grp_id int NOT NULL,
  191. gw_idx1 UNIQUE (gw_name, ),
  192. );
  193. CREATE TABLE gw_grp (
  194. grp_id int NOT NULL,
  195. grp_name string(64) NOT NULL,
  196. gwgrp_idx UNIQUE (grp_id, )
  197. );
  198. CREATE TABLE lcr (
  199. prefix string(16) NOT NULL,
  200. from_uri string(255) NOT NULL DEFAULT '%',
  201. grp_id int,
  202. priority int
  203. );
  204. CREATE TABLE silo (
  205. mid int NOT NULL,
  206. src_addr string(255) NOT NULL,
  207. dst_addr string(255) NOT NULL,
  208. r_uri string(255) NOT NULL,
  209. uid string(64) NOT NULL,
  210. inc_time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  211. exp_time datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  212. ctype string(128) NOT NULL DEFAULT 'text/plain',
  213. body binary NOT NULL DEFAULT '',
  214. silo_idx1 UNIQUE (mid, )
  215. );
  216. CREATE TABLE uri (
  217. uid string(64) NOT NULL,
  218. did string(64) NOT NULL,
  219. username string(64) NOT NULL,
  220. flags int NOT NULL DEFAULT '0',
  221. uri_idx1 UNIQUE (username, did, flags, ),
  222. uri_uid UNIQUE (uid, flags, )
  223. );
  224. CREATE TABLE speed_dial (
  225. id int NOT NULL,
  226. uid string(64) NOT NULL,
  227. dial_username string(64) NOT NULL,
  228. dial_did string(64) NOT NULL,
  229. new_uri string(255) NOT NULL,
  230. speeddial_idx1 UNIQUE (uid, dial_did, dial_username, ),
  231. speeddial_id UNIQUE (id, ),
  232. );
  233. CREATE TABLE sd_attrs (
  234. id string(64) NOT NULL,
  235. name string(32) NOT NULL,
  236. value string(64),
  237. type int NOT NULL DEFAULT '0',
  238. flags int NOT NULL DEFAULT '0',
  239. userattrs_idx UNIQUE (id, name, value, )
  240. );
  241. CREATE TABLE presentity (
  242. presid int(10) NOT NULL,
  243. uri string(255) NOT NULL,
  244. pdomain string(128) NOT NULL,
  245. presentity_key UNIQUE (presid, ),
  246. );
  247. CREATE TABLE presentity_contact (
  248. contactid int(10) NOT NULL,
  249. presid int(10) NOT NULL,
  250. basic string(32) NOT NULL DEFAULT 'offline',
  251. status string(32) NOT NULL,
  252. location string(128) NOT NULL,
  253. expires datetime NOT NULL DEFAULT '2020-05-28 21:32:15',
  254. placeid int(10),
  255. priority float NOT NULL DEFAULT '0.5',
  256. contact string(255),
  257. tupleid string(64) NOT NULL,
  258. prescaps int(10) NOT NULL,
  259. pc_idx1 UNIQUE (contactid, ),
  260. );
  261. CREATE TABLE watcherinfo (
  262. r_uri string(255) NOT NULL,
  263. w_uri string(255) NOT NULL,
  264. display_name string(128) NOT NULL,
  265. s_id string(64) NOT NULL,
  266. package string(32) NOT NULL DEFAULT 'presence',
  267. status string(32) NOT NULL DEFAULT 'pending',
  268. event string(32) NOT NULL,
  269. expires int NOT NULL,
  270. accepts int NOT NULL,
  271. presid int(10) NOT NULL,
  272. server_contact string(255) NOT NULL,
  273. dialog binary NOT NULL,
  274. doc_index int NOT NULL,
  275. wi_idx1 UNIQUE (s_id, ),
  276. );