RoundCube Webmail
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

293 lines
7.9 KiB

  1. -- Roundcube Webmail initial database structure
  2. --
  3. -- Sequence "users_seq"
  4. -- Name: users_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  5. --
  6. CREATE SEQUENCE users_seq
  7. INCREMENT BY 1
  8. NO MAXVALUE
  9. NO MINVALUE
  10. CACHE 1;
  11. --
  12. -- Table "users"
  13. -- Name: users; Type: TABLE; Schema: public; Owner: postgres
  14. --
  15. CREATE TABLE users (
  16. user_id integer DEFAULT nextval('users_seq'::text) PRIMARY KEY,
  17. username varchar(128) DEFAULT '' NOT NULL,
  18. mail_host varchar(128) DEFAULT '' NOT NULL,
  19. created timestamp with time zone DEFAULT now() NOT NULL,
  20. last_login timestamp with time zone DEFAULT NULL,
  21. "language" varchar(5),
  22. preferences text DEFAULT ''::text NOT NULL,
  23. CONSTRAINT users_username_key UNIQUE (username, mail_host)
  24. );
  25. --
  26. -- Table "session"
  27. -- Name: session; Type: TABLE; Schema: public; Owner: postgres
  28. --
  29. CREATE TABLE "session" (
  30. sess_id varchar(128) DEFAULT '' PRIMARY KEY,
  31. created timestamp with time zone DEFAULT now() NOT NULL,
  32. changed timestamp with time zone DEFAULT now() NOT NULL,
  33. ip varchar(41) NOT NULL,
  34. vars text NOT NULL
  35. );
  36. CREATE INDEX session_changed_idx ON session (changed);
  37. --
  38. -- Sequence "identities_seq"
  39. -- Name: identities_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  40. --
  41. CREATE SEQUENCE identities_seq
  42. START WITH 1
  43. INCREMENT BY 1
  44. NO MAXVALUE
  45. NO MINVALUE
  46. CACHE 1;
  47. --
  48. -- Table "identities"
  49. -- Name: identities; Type: TABLE; Schema: public; Owner: postgres
  50. --
  51. CREATE TABLE identities (
  52. identity_id integer DEFAULT nextval('identities_seq'::text) PRIMARY KEY,
  53. user_id integer NOT NULL
  54. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  55. changed timestamp with time zone DEFAULT now() NOT NULL,
  56. del smallint DEFAULT 0 NOT NULL,
  57. standard smallint DEFAULT 0 NOT NULL,
  58. name varchar(128) NOT NULL,
  59. organization varchar(128),
  60. email varchar(128) NOT NULL,
  61. "reply-to" varchar(128),
  62. bcc varchar(128),
  63. signature text,
  64. html_signature integer DEFAULT 0 NOT NULL
  65. );
  66. CREATE INDEX identities_user_id_idx ON identities (user_id, del);
  67. CREATE INDEX identities_email_idx ON identities (email, del);
  68. --
  69. -- Sequence "contacts_seq"
  70. -- Name: contacts_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  71. --
  72. CREATE SEQUENCE contacts_seq
  73. START WITH 1
  74. INCREMENT BY 1
  75. NO MAXVALUE
  76. NO MINVALUE
  77. CACHE 1;
  78. --
  79. -- Table "contacts"
  80. -- Name: contacts; Type: TABLE; Schema: public; Owner: postgres
  81. --
  82. CREATE TABLE contacts (
  83. contact_id integer DEFAULT nextval('contacts_seq'::text) PRIMARY KEY,
  84. user_id integer NOT NULL
  85. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  86. changed timestamp with time zone DEFAULT now() NOT NULL,
  87. del smallint DEFAULT 0 NOT NULL,
  88. name varchar(128) DEFAULT '' NOT NULL,
  89. email text DEFAULT '' NOT NULL,
  90. firstname varchar(128) DEFAULT '' NOT NULL,
  91. surname varchar(128) DEFAULT '' NOT NULL,
  92. vcard text,
  93. words text
  94. );
  95. CREATE INDEX contacts_user_id_idx ON contacts (user_id, del);
  96. --
  97. -- Sequence "contactgroups_seq"
  98. -- Name: contactgroups_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  99. --
  100. CREATE SEQUENCE contactgroups_seq
  101. INCREMENT BY 1
  102. NO MAXVALUE
  103. NO MINVALUE
  104. CACHE 1;
  105. --
  106. -- Table "contactgroups"
  107. -- Name: contactgroups; Type: TABLE; Schema: public; Owner: postgres
  108. --
  109. CREATE TABLE contactgroups (
  110. contactgroup_id integer DEFAULT nextval('contactgroups_seq'::text) PRIMARY KEY,
  111. user_id integer NOT NULL
  112. REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  113. changed timestamp with time zone DEFAULT now() NOT NULL,
  114. del smallint NOT NULL DEFAULT 0,
  115. name varchar(128) NOT NULL DEFAULT ''
  116. );
  117. CREATE INDEX contactgroups_user_id_idx ON contactgroups (user_id, del);
  118. --
  119. -- Table "contactgroupmembers"
  120. -- Name: contactgroupmembers; Type: TABLE; Schema: public; Owner: postgres
  121. --
  122. CREATE TABLE contactgroupmembers (
  123. contactgroup_id integer NOT NULL
  124. REFERENCES contactgroups(contactgroup_id) ON DELETE CASCADE ON UPDATE CASCADE,
  125. contact_id integer NOT NULL
  126. REFERENCES contacts(contact_id) ON DELETE CASCADE ON UPDATE CASCADE,
  127. created timestamp with time zone DEFAULT now() NOT NULL,
  128. PRIMARY KEY (contactgroup_id, contact_id)
  129. );
  130. CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
  131. --
  132. -- Table "cache"
  133. -- Name: cache; Type: TABLE; Schema: public; Owner: postgres
  134. --
  135. CREATE TABLE "cache" (
  136. user_id integer NOT NULL
  137. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  138. cache_key varchar(128) DEFAULT '' NOT NULL,
  139. created timestamp with time zone DEFAULT now() NOT NULL,
  140. expires timestamp with time zone DEFAULT NULL,
  141. data text NOT NULL
  142. );
  143. CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key);
  144. CREATE INDEX cache_expires_idx ON "cache" (expires);
  145. --
  146. -- Table "cache_shared"
  147. -- Name: cache_shared; Type: TABLE; Schema: public; Owner: postgres
  148. --
  149. CREATE TABLE "cache_shared" (
  150. cache_key varchar(255) NOT NULL,
  151. created timestamp with time zone DEFAULT now() NOT NULL,
  152. expires timestamp with time zone DEFAULT NULL,
  153. data text NOT NULL
  154. );
  155. CREATE INDEX cache_shared_cache_key_idx ON "cache_shared" (cache_key);
  156. CREATE INDEX cache_shared_expires_idx ON "cache_shared" (expires);
  157. --
  158. -- Table "cache_index"
  159. -- Name: cache_index; Type: TABLE; Schema: public; Owner: postgres
  160. --
  161. CREATE TABLE cache_index (
  162. user_id integer NOT NULL
  163. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  164. mailbox varchar(255) NOT NULL,
  165. expires timestamp with time zone DEFAULT NULL,
  166. valid smallint NOT NULL DEFAULT 0,
  167. data text NOT NULL,
  168. PRIMARY KEY (user_id, mailbox)
  169. );
  170. CREATE INDEX cache_index_expires_idx ON cache_index (expires);
  171. --
  172. -- Table "cache_thread"
  173. -- Name: cache_thread; Type: TABLE; Schema: public; Owner: postgres
  174. --
  175. CREATE TABLE cache_thread (
  176. user_id integer NOT NULL
  177. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  178. mailbox varchar(255) NOT NULL,
  179. expires timestamp with time zone DEFAULT NULL,
  180. data text NOT NULL,
  181. PRIMARY KEY (user_id, mailbox)
  182. );
  183. CREATE INDEX cache_thread_expires_idx ON cache_thread (expires);
  184. --
  185. -- Table "cache_messages"
  186. -- Name: cache_messages; Type: TABLE; Schema: public; Owner: postgres
  187. --
  188. CREATE TABLE cache_messages (
  189. user_id integer NOT NULL
  190. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  191. mailbox varchar(255) NOT NULL,
  192. uid integer NOT NULL,
  193. expires timestamp with time zone DEFAULT NULL,
  194. data text NOT NULL,
  195. flags integer NOT NULL DEFAULT 0,
  196. PRIMARY KEY (user_id, mailbox, uid)
  197. );
  198. CREATE INDEX cache_messages_expires_idx ON cache_messages (expires);
  199. --
  200. -- Table "dictionary"
  201. -- Name: dictionary; Type: TABLE; Schema: public; Owner: postgres
  202. --
  203. CREATE TABLE dictionary (
  204. user_id integer DEFAULT NULL
  205. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  206. "language" varchar(5) NOT NULL,
  207. data text NOT NULL,
  208. CONSTRAINT dictionary_user_id_language_key UNIQUE (user_id, "language")
  209. );
  210. --
  211. -- Sequence "searches_seq"
  212. -- Name: searches_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  213. --
  214. CREATE SEQUENCE searches_seq
  215. INCREMENT BY 1
  216. NO MAXVALUE
  217. NO MINVALUE
  218. CACHE 1;
  219. --
  220. -- Table "searches"
  221. -- Name: searches; Type: TABLE; Schema: public; Owner: postgres
  222. --
  223. CREATE TABLE searches (
  224. search_id integer DEFAULT nextval('searches_seq'::text) PRIMARY KEY,
  225. user_id integer NOT NULL
  226. REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  227. "type" smallint DEFAULT 0 NOT NULL,
  228. name varchar(128) NOT NULL,
  229. data text NOT NULL,
  230. CONSTRAINT searches_user_id_key UNIQUE (user_id, "type", name)
  231. );
  232. --
  233. -- Table "system"
  234. -- Name: system; Type: TABLE; Schema: public; Owner: postgres
  235. --
  236. CREATE TABLE "system" (
  237. name varchar(64) NOT NULL PRIMARY KEY,
  238. value text
  239. );
  240. INSERT INTO system (name, value) VALUES ('roundcube-version', '2014042900');