tables.sql 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. CREATE TABLE IF NOT EXISTS organization (
  2. key uuid,
  3. external_accounting_id text,
  4. external_accounting_url text,
  5. owner_key uuid,
  6. domain varchar(2048),
  7. contact_email varchar(320),
  8. name varchar(256),
  9. description varchar(512),
  10. matrix_home_server text,
  11. matrix_live_support_room_url text,
  12. matrix_general_room_url text,
  13. created bigint,
  14. updated bigint
  15. );
  16. CREATE TABLE IF NOT EXISTS users (
  17. key uuid,
  18. organization_key uuid,
  19. email varchar(320),
  20. matrix_user_id varchar(512),
  21. matrix_home_server text,
  22. created bigint,
  23. updated bigint
  24. );
  25. CREATE TABLE IF NOT EXISTS files (
  26. key uuid,
  27. owner_key uuid,
  28. organization_key uuid,
  29. association_type smallint,
  30. association_key uuid,
  31. url varchar(2048),
  32. hash text,
  33. name varchar(256),
  34. description varchar(512),
  35. tags varchar(256),
  36. format varchar(32),
  37. size bigint,
  38. created bigint,
  39. updated bigint
  40. );
  41. CREATE TABLE IF NOT EXISTS notes (
  42. key uuid,
  43. owner_key uuid,
  44. organization_key uuid,
  45. association_type smallint,
  46. association_key uuid,
  47. url varchar(2048),
  48. hash text,
  49. title varchar(256),
  50. content varchar(512),
  51. created bigint,
  52. updated bigint
  53. );
  54. CREATE TABLE IF NOT EXISTS service_items (
  55. key uuid,
  56. owner_key uuid,
  57. organization_key uuid,
  58. external_accounting_id text,
  59. name varchar(256),
  60. description varchar(512),
  61. value bigint,
  62. currency varchar(16),
  63. service_item_type smallint,
  64. service_value_type smallint,
  65. expenses uuid [],
  66. created bigint,
  67. updated bigint
  68. );
  69. CREATE TABLE IF NOT EXISTS projects (
  70. key uuid,
  71. owner_key uuid,
  72. organization_key uuid,
  73. name varchar(256),
  74. description varchar(512),
  75. tags varchar(256),
  76. estimated_quarter_days int,
  77. start bigint,
  78. due bigint,
  79. created bigint,
  80. updated bigint
  81. );
  82. CREATE TABLE IF NOT EXISTS mile_stones (
  83. key uuid,
  84. owner_key uuid,
  85. organization_key uuid,
  86. project_key uuid,
  87. name varchar(256),
  88. description varchar(512),
  89. tags varchar(256),
  90. estimated_quarter_days int,
  91. start bigint,
  92. due bigint,
  93. created bigint,
  94. updated bigint
  95. );
  96. CREATE TABLE IF NOT EXISTS tasks (
  97. key uuid,
  98. owner_key uuid,
  99. organization_key uuid,
  100. project_key uuid,
  101. assignee_key uuid,
  102. name varchar(256),
  103. description varchar(512),
  104. tags varchar(256),
  105. status smallint,
  106. estimated_quarter_days int,
  107. start bigint,
  108. due bigint,
  109. created bigint,
  110. updated bigint
  111. );
  112. CREATE TABLE IF NOT EXISTS boards (
  113. key uuid,
  114. owner_key uuid,
  115. organization_key uuid,
  116. project_key uuid,
  117. name varchar(256),
  118. description varchar(512),
  119. columns text [],
  120. lanes text [],
  121. filter text,
  122. created bigint,
  123. updated bigint
  124. );
  125. CREATE TABLE IF NOT EXISTS entitys (
  126. key uuid,
  127. owner_key uuid,
  128. organization_key uuid,
  129. external_accounting_id text,
  130. name varchar(256),
  131. description varchar(512),
  132. matrix_room_url text,
  133. web_url text,
  134. avatar_url text,
  135. entity_type smallint,
  136. address_primary text,
  137. address_unit text,
  138. city text,
  139. state text,
  140. zip_code text,
  141. country text,
  142. created bigint,
  143. updated bigint
  144. );
  145. CREATE TABLE IF NOT EXISTS contacts (
  146. key uuid,
  147. entity_key uuid,
  148. organization_key uuid,
  149. external_accounting_id text,
  150. first_name varchar(128),
  151. middle_initial varchar(12),
  152. last_name varchar(128),
  153. description varchar(512),
  154. position varchar(512),
  155. email varchar(320),
  156. phone varchar(16),
  157. secondary_email varchar(320),
  158. secondary_phone varchar(16),
  159. matrix_user_id varchar(512),
  160. web_url text,
  161. avatar_url text,
  162. social_urls text [],
  163. address_primary text,
  164. address_unit text,
  165. city text,
  166. state text,
  167. zip_code text,
  168. country text,
  169. created bigint,
  170. updated bigint
  171. );
  172. CREATE TABLE IF NOT EXISTS rooms (
  173. key uuid,
  174. owner_key uuid,
  175. organization_key uuid,
  176. name varchar(256),
  177. description varchar(512),
  178. matrix_room_url text,
  179. matrix_room_id varchar(512),
  180. message_types smallint,
  181. alert_level smallint,
  182. created bigint,
  183. updated bigint
  184. );
  185. CREATE TABLE IF NOT EXISTS akaunting_options (
  186. key uuid,
  187. owner_key uuid,
  188. organization_key uuid,
  189. matrix_room_url text,
  190. user_name text,
  191. user_pass text,
  192. akaunting_domain text,
  193. akaunting_company_id text,
  194. organization_data boolean,
  195. employee_data boolean,
  196. client_data boolean,
  197. vendor_data boolean,
  198. item_data boolean,
  199. invoice_data boolean,
  200. allow_post boolean,
  201. last_sync bigint,
  202. created bigint,
  203. updated bigint
  204. );
  205. GRANT ALL ON ALL TABLES IN SCHEMA public TO projectmanager;
  206. -- delete from akaunting_options;
  207. -- delete from boards ;
  208. -- delete from contacts ;
  209. -- delete from entitys ;
  210. -- delete from files ;
  211. -- delete from mile_stones ;
  212. -- delete from notes ;
  213. -- delete from organization ;
  214. -- delete from projects ;
  215. -- delete from rooms ;
  216. -- delete from service_items ;
  217. -- delete from tasks ;
  218. -- delete from users;