Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

oracle.initial.sql 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. -- Roundcube Webmail initial database structure
  2. -- This was tested with Oracle 11g
  3. CREATE TABLE "users" (
  4. "user_id" integer PRIMARY KEY,
  5. "username" varchar(128) NOT NULL,
  6. "mail_host" varchar(128) NOT NULL,
  7. "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  8. "last_login" timestamp with time zone DEFAULT NULL,
  9. "failed_login" timestamp with time zone DEFAULT NULL,
  10. "failed_login_counter" integer DEFAULT NULL,
  11. "language" varchar(5),
  12. "preferences" long DEFAULT NULL,
  13. CONSTRAINT "users_username_key" UNIQUE ("username", "mail_host")
  14. );
  15. CREATE SEQUENCE "users_seq"
  16. START WITH 1 INCREMENT BY 1 NOMAXVALUE;
  17. CREATE TRIGGER "users_seq_trig"
  18. BEFORE INSERT ON "users" FOR EACH ROW
  19. BEGIN
  20. :NEW."user_id" := "users_seq".nextval;
  21. END;
  22. /
  23. CREATE TABLE "session" (
  24. "sess_id" varchar(128) NOT NULL PRIMARY KEY,
  25. "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  26. "changed" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  27. "ip" varchar(41) NOT NULL,
  28. "vars" long NOT NULL
  29. );
  30. CREATE INDEX "session_changed_idx" ON "session" ("changed");
  31. CREATE TABLE "identities" (
  32. "identity_id" integer PRIMARY KEY,
  33. "user_id" integer NOT NULL
  34. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  35. "changed" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  36. "del" smallint DEFAULT 0 NOT NULL,
  37. "standard" smallint DEFAULT 0 NOT NULL,
  38. "name" varchar(128) NOT NULL,
  39. "organization" varchar(128),
  40. "email" varchar(128) NOT NULL,
  41. "reply-to" varchar(128),
  42. "bcc" varchar(128),
  43. "signature" long,
  44. "html_signature" integer DEFAULT 0 NOT NULL
  45. );
  46. CREATE INDEX "identities_user_id_idx" ON "identities" ("user_id", "del");
  47. CREATE INDEX "identities_email_idx" ON "identities" ("email", "del");
  48. CREATE SEQUENCE "identities_seq"
  49. START WITH 1 INCREMENT BY 1 NOMAXVALUE;
  50. CREATE TRIGGER "identities_seq_trig"
  51. BEFORE INSERT ON "identities" FOR EACH ROW
  52. BEGIN
  53. :NEW."identity_id" := "identities_seq".nextval;
  54. END;
  55. /
  56. CREATE TABLE "contacts" (
  57. "contact_id" integer PRIMARY KEY,
  58. "user_id" integer NOT NULL
  59. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  60. "changed" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  61. "del" smallint DEFAULT 0 NOT NULL,
  62. "name" varchar(128) DEFAULT NULL,
  63. "email" varchar(4000) DEFAULT NULL,
  64. "firstname" varchar(128) DEFAULT NULL,
  65. "surname" varchar(128) DEFAULT NULL,
  66. "vcard" long,
  67. "words" varchar(4000)
  68. );
  69. CREATE INDEX "contacts_user_id_idx" ON "contacts" ("user_id", "del");
  70. CREATE SEQUENCE "contacts_seq"
  71. START WITH 1 INCREMENT BY 1 NOMAXVALUE;
  72. CREATE TRIGGER "contacts_seq_trig"
  73. BEFORE INSERT ON "contacts" FOR EACH ROW
  74. BEGIN
  75. :NEW."contact_id" := "contacts_seq".nextval;
  76. END;
  77. /
  78. CREATE TABLE "contactgroups" (
  79. "contactgroup_id" integer PRIMARY KEY,
  80. "user_id" integer NOT NULL
  81. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  82. "changed" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  83. "del" smallint DEFAULT 0 NOT NULL,
  84. "name" varchar(128) NOT NULL
  85. );
  86. CREATE INDEX "contactgroups_user_id_idx" ON "contactgroups" ("user_id", "del");
  87. CREATE SEQUENCE "contactgroups_seq"
  88. START WITH 1 INCREMENT BY 1 NOMAXVALUE;
  89. CREATE TRIGGER "contactgroups_seq_trig"
  90. BEFORE INSERT ON "contactgroups" FOR EACH ROW
  91. BEGIN
  92. :NEW."contactgroup_id" := "contactgroups_seq".nextval;
  93. END;
  94. /
  95. CREATE TABLE "contactgroupmembers" (
  96. "contactgroup_id" integer NOT NULL
  97. REFERENCES "contactgroups" ("contactgroup_id") ON DELETE CASCADE,
  98. "contact_id" integer NOT NULL
  99. REFERENCES "contacts" ("contact_id") ON DELETE CASCADE,
  100. "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  101. PRIMARY KEY ("contactgroup_id", "contact_id")
  102. );
  103. CREATE INDEX "contactgroupmembers_idx" ON "contactgroupmembers" ("contact_id");
  104. CREATE TABLE "cache" (
  105. "user_id" integer NOT NULL
  106. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  107. "cache_key" varchar(128) NOT NULL,
  108. "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  109. "expires" timestamp with time zone DEFAULT NULL,
  110. "data" long NOT NULL
  111. );
  112. CREATE INDEX "cache_user_id_idx" ON "cache" ("user_id", "cache_key");
  113. CREATE INDEX "cache_expires_idx" ON "cache" ("expires");
  114. CREATE TABLE "cache_shared" (
  115. "cache_key" varchar(255) NOT NULL,
  116. "created" timestamp with time zone DEFAULT current_timestamp NOT NULL,
  117. "expires" timestamp with time zone DEFAULT NULL,
  118. "data" long NOT NULL
  119. );
  120. CREATE INDEX "cache_shared_cache_key_idx" ON "cache_shared" ("cache_key");
  121. CREATE INDEX "cache_shared_expires_idx" ON "cache_shared" ("expires");
  122. CREATE TABLE "cache_index" (
  123. "user_id" integer NOT NULL
  124. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  125. "mailbox" varchar(255) NOT NULL,
  126. "expires" timestamp with time zone DEFAULT NULL,
  127. "valid" smallint DEFAULT 0 NOT NULL,
  128. "data" long NOT NULL,
  129. PRIMARY KEY ("user_id", "mailbox")
  130. );
  131. CREATE INDEX "cache_index_expires_idx" ON "cache_index" ("expires");
  132. CREATE TABLE "cache_thread" (
  133. "user_id" integer NOT NULL
  134. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  135. "mailbox" varchar(255) NOT NULL,
  136. "expires" timestamp with time zone DEFAULT NULL,
  137. "data" long NOT NULL,
  138. PRIMARY KEY ("user_id", "mailbox")
  139. );
  140. CREATE INDEX "cache_thread_expires_idx" ON "cache_thread" ("expires");
  141. CREATE TABLE "cache_messages" (
  142. "user_id" integer NOT NULL
  143. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  144. "mailbox" varchar(255) NOT NULL,
  145. "uid" integer NOT NULL,
  146. "expires" timestamp with time zone DEFAULT NULL,
  147. "data" long NOT NULL,
  148. "flags" integer DEFAULT 0 NOT NULL,
  149. PRIMARY KEY ("user_id", "mailbox", "uid")
  150. );
  151. CREATE INDEX "cache_messages_expires_idx" ON "cache_messages" ("expires");
  152. CREATE TABLE "dictionary" (
  153. "user_id" integer DEFAULT NULL
  154. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  155. "language" varchar(5) NOT NULL,
  156. "data" long DEFAULT NULL,
  157. CONSTRAINT "dictionary_user_id_lang_key" UNIQUE ("user_id", "language")
  158. );
  159. CREATE TABLE "searches" (
  160. "search_id" integer PRIMARY KEY,
  161. "user_id" integer NOT NULL
  162. REFERENCES "users" ("user_id") ON DELETE CASCADE,
  163. "type" smallint DEFAULT 0 NOT NULL,
  164. "name" varchar(128) NOT NULL,
  165. "data" long NOT NULL,
  166. CONSTRAINT "searches_user_id_key" UNIQUE ("user_id", "type", "name")
  167. );
  168. CREATE SEQUENCE "searches_seq"
  169. START WITH 1 INCREMENT BY 1 NOMAXVALUE;
  170. CREATE TRIGGER "searches_seq_trig"
  171. BEFORE INSERT ON "searches" FOR EACH ROW
  172. BEGIN
  173. :NEW."search_id" := "searches_seq".nextval;
  174. END;
  175. /
  176. CREATE TABLE "system" (
  177. "name" varchar(64) NOT NULL PRIMARY KEY,
  178. "value" long
  179. );
  180. INSERT INTO "system" ("name", "value") VALUES ('roundcube-version', '2015111100');