full.sql.postgres 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. -- Dumped from database version 11.1
  5. -- Dumped by pg_dump version 11.1
  6. --
  7. -- Name: access_tokens; Type: TABLE; Schema: public; Owner: -
  8. --
  9. CREATE TABLE access_tokens (
  10. id bigint NOT NULL,
  11. user_id text NOT NULL,
  12. device_id text,
  13. token text NOT NULL,
  14. last_used bigint
  15. );
  16. --
  17. -- Name: account_data; Type: TABLE; Schema: public; Owner: -
  18. --
  19. CREATE TABLE account_data (
  20. user_id text NOT NULL,
  21. account_data_type text NOT NULL,
  22. stream_id bigint NOT NULL,
  23. content text NOT NULL
  24. );
  25. --
  26. -- Name: account_data_max_stream_id; Type: TABLE; Schema: public; Owner: -
  27. --
  28. CREATE TABLE account_data_max_stream_id (
  29. lock character(1) DEFAULT 'X'::bpchar NOT NULL,
  30. stream_id bigint NOT NULL,
  31. CONSTRAINT private_user_data_max_stream_id_lock_check CHECK ((lock = 'X'::bpchar))
  32. );
  33. --
  34. -- Name: application_services; Type: TABLE; Schema: public; Owner: -
  35. --
  36. CREATE TABLE application_services (
  37. id bigint NOT NULL,
  38. url text,
  39. token text,
  40. hs_token text,
  41. sender text
  42. );
  43. --
  44. -- Name: application_services_regex; Type: TABLE; Schema: public; Owner: -
  45. --
  46. CREATE TABLE application_services_regex (
  47. id bigint NOT NULL,
  48. as_id bigint NOT NULL,
  49. namespace integer,
  50. regex text
  51. );
  52. --
  53. -- Name: application_services_state; Type: TABLE; Schema: public; Owner: -
  54. --
  55. CREATE TABLE application_services_state (
  56. as_id text NOT NULL,
  57. state character varying(5),
  58. last_txn integer
  59. );
  60. --
  61. -- Name: application_services_txns; Type: TABLE; Schema: public; Owner: -
  62. --
  63. CREATE TABLE application_services_txns (
  64. as_id text NOT NULL,
  65. txn_id integer NOT NULL,
  66. event_ids text NOT NULL
  67. );
  68. --
  69. -- Name: appservice_room_list; Type: TABLE; Schema: public; Owner: -
  70. --
  71. CREATE TABLE appservice_room_list (
  72. appservice_id text NOT NULL,
  73. network_id text NOT NULL,
  74. room_id text NOT NULL
  75. );
  76. --
  77. -- Name: appservice_stream_position; Type: TABLE; Schema: public; Owner: -
  78. --
  79. CREATE TABLE appservice_stream_position (
  80. lock character(1) DEFAULT 'X'::bpchar NOT NULL,
  81. stream_ordering bigint,
  82. CONSTRAINT appservice_stream_position_lock_check CHECK ((lock = 'X'::bpchar))
  83. );
  84. --
  85. -- Name: background_updates; Type: TABLE; Schema: public; Owner: -
  86. --
  87. CREATE TABLE background_updates (
  88. update_name text NOT NULL,
  89. progress_json text NOT NULL,
  90. depends_on text
  91. );
  92. --
  93. -- Name: blocked_rooms; Type: TABLE; Schema: public; Owner: -
  94. --
  95. CREATE TABLE blocked_rooms (
  96. room_id text NOT NULL,
  97. user_id text NOT NULL
  98. );
  99. --
  100. -- Name: cache_invalidation_stream; Type: TABLE; Schema: public; Owner: -
  101. --
  102. CREATE TABLE cache_invalidation_stream (
  103. stream_id bigint,
  104. cache_func text,
  105. keys text[],
  106. invalidation_ts bigint
  107. );
  108. --
  109. -- Name: current_state_delta_stream; Type: TABLE; Schema: public; Owner: -
  110. --
  111. CREATE TABLE current_state_delta_stream (
  112. stream_id bigint NOT NULL,
  113. room_id text NOT NULL,
  114. type text NOT NULL,
  115. state_key text NOT NULL,
  116. event_id text,
  117. prev_event_id text
  118. );
  119. --
  120. -- Name: current_state_events; Type: TABLE; Schema: public; Owner: -
  121. --
  122. CREATE TABLE current_state_events (
  123. event_id text NOT NULL,
  124. room_id text NOT NULL,
  125. type text NOT NULL,
  126. state_key text NOT NULL
  127. );
  128. --
  129. -- Name: current_state_resets; Type: TABLE; Schema: public; Owner: -
  130. --
  131. CREATE TABLE current_state_resets (
  132. event_stream_ordering bigint NOT NULL
  133. );
  134. --
  135. -- Name: deleted_pushers; Type: TABLE; Schema: public; Owner: -
  136. --
  137. CREATE TABLE deleted_pushers (
  138. stream_id bigint NOT NULL,
  139. app_id text NOT NULL,
  140. pushkey text NOT NULL,
  141. user_id text NOT NULL
  142. );
  143. --
  144. -- Name: destinations; Type: TABLE; Schema: public; Owner: -
  145. --
  146. CREATE TABLE destinations (
  147. destination text NOT NULL,
  148. retry_last_ts bigint,
  149. retry_interval integer
  150. );
  151. --
  152. -- Name: device_federation_inbox; Type: TABLE; Schema: public; Owner: -
  153. --
  154. CREATE TABLE device_federation_inbox (
  155. origin text NOT NULL,
  156. message_id text NOT NULL,
  157. received_ts bigint NOT NULL
  158. );
  159. --
  160. -- Name: device_federation_outbox; Type: TABLE; Schema: public; Owner: -
  161. --
  162. CREATE TABLE device_federation_outbox (
  163. destination text NOT NULL,
  164. stream_id bigint NOT NULL,
  165. queued_ts bigint NOT NULL,
  166. messages_json text NOT NULL
  167. );
  168. --
  169. -- Name: device_inbox; Type: TABLE; Schema: public; Owner: -
  170. --
  171. CREATE TABLE device_inbox (
  172. user_id text NOT NULL,
  173. device_id text NOT NULL,
  174. stream_id bigint NOT NULL,
  175. message_json text NOT NULL
  176. );
  177. --
  178. -- Name: device_lists_outbound_last_success; Type: TABLE; Schema: public; Owner: -
  179. --
  180. CREATE TABLE device_lists_outbound_last_success (
  181. destination text NOT NULL,
  182. user_id text NOT NULL,
  183. stream_id bigint NOT NULL
  184. );
  185. --
  186. -- Name: device_lists_outbound_pokes; Type: TABLE; Schema: public; Owner: -
  187. --
  188. CREATE TABLE device_lists_outbound_pokes (
  189. destination text NOT NULL,
  190. stream_id bigint NOT NULL,
  191. user_id text NOT NULL,
  192. device_id text NOT NULL,
  193. sent boolean NOT NULL,
  194. ts bigint NOT NULL
  195. );
  196. --
  197. -- Name: device_lists_remote_cache; Type: TABLE; Schema: public; Owner: -
  198. --
  199. CREATE TABLE device_lists_remote_cache (
  200. user_id text NOT NULL,
  201. device_id text NOT NULL,
  202. content text NOT NULL
  203. );
  204. --
  205. -- Name: device_lists_remote_extremeties; Type: TABLE; Schema: public; Owner: -
  206. --
  207. CREATE TABLE device_lists_remote_extremeties (
  208. user_id text NOT NULL,
  209. stream_id text NOT NULL
  210. );
  211. --
  212. -- Name: device_lists_stream; Type: TABLE; Schema: public; Owner: -
  213. --
  214. CREATE TABLE device_lists_stream (
  215. stream_id bigint NOT NULL,
  216. user_id text NOT NULL,
  217. device_id text NOT NULL
  218. );
  219. --
  220. -- Name: device_max_stream_id; Type: TABLE; Schema: public; Owner: -
  221. --
  222. CREATE TABLE device_max_stream_id (
  223. stream_id bigint NOT NULL
  224. );
  225. --
  226. -- Name: devices; Type: TABLE; Schema: public; Owner: -
  227. --
  228. CREATE TABLE devices (
  229. user_id text NOT NULL,
  230. device_id text NOT NULL,
  231. display_name text
  232. );
  233. --
  234. -- Name: e2e_device_keys_json; Type: TABLE; Schema: public; Owner: -
  235. --
  236. CREATE TABLE e2e_device_keys_json (
  237. user_id text NOT NULL,
  238. device_id text NOT NULL,
  239. ts_added_ms bigint NOT NULL,
  240. key_json text NOT NULL
  241. );
  242. --
  243. -- Name: e2e_one_time_keys_json; Type: TABLE; Schema: public; Owner: -
  244. --
  245. CREATE TABLE e2e_one_time_keys_json (
  246. user_id text NOT NULL,
  247. device_id text NOT NULL,
  248. algorithm text NOT NULL,
  249. key_id text NOT NULL,
  250. ts_added_ms bigint NOT NULL,
  251. key_json text NOT NULL
  252. );
  253. --
  254. -- Name: e2e_room_keys; Type: TABLE; Schema: public; Owner: -
  255. --
  256. CREATE TABLE e2e_room_keys (
  257. user_id text NOT NULL,
  258. room_id text NOT NULL,
  259. session_id text NOT NULL,
  260. version bigint NOT NULL,
  261. first_message_index integer,
  262. forwarded_count integer,
  263. is_verified boolean,
  264. session_data text NOT NULL
  265. );
  266. --
  267. -- Name: e2e_room_keys_versions; Type: TABLE; Schema: public; Owner: -
  268. --
  269. CREATE TABLE e2e_room_keys_versions (
  270. user_id text NOT NULL,
  271. version bigint NOT NULL,
  272. algorithm text NOT NULL,
  273. auth_data text NOT NULL,
  274. deleted smallint DEFAULT 0 NOT NULL
  275. );
  276. --
  277. -- Name: erased_users; Type: TABLE; Schema: public; Owner: -
  278. --
  279. CREATE TABLE erased_users (
  280. user_id text NOT NULL
  281. );
  282. --
  283. -- Name: event_auth; Type: TABLE; Schema: public; Owner: -
  284. --
  285. CREATE TABLE event_auth (
  286. event_id text NOT NULL,
  287. auth_id text NOT NULL,
  288. room_id text NOT NULL
  289. );
  290. --
  291. -- Name: event_backward_extremities; Type: TABLE; Schema: public; Owner: -
  292. --
  293. CREATE TABLE event_backward_extremities (
  294. event_id text NOT NULL,
  295. room_id text NOT NULL
  296. );
  297. --
  298. -- Name: event_content_hashes; Type: TABLE; Schema: public; Owner: -
  299. --
  300. CREATE TABLE event_content_hashes (
  301. event_id text,
  302. algorithm text,
  303. hash bytea
  304. );
  305. --
  306. -- Name: event_destinations; Type: TABLE; Schema: public; Owner: -
  307. --
  308. CREATE TABLE event_destinations (
  309. event_id text NOT NULL,
  310. destination text NOT NULL,
  311. delivered_ts bigint DEFAULT 0
  312. );
  313. --
  314. -- Name: event_edge_hashes; Type: TABLE; Schema: public; Owner: -
  315. --
  316. CREATE TABLE event_edge_hashes (
  317. event_id text,
  318. prev_event_id text,
  319. algorithm text,
  320. hash bytea
  321. );
  322. --
  323. -- Name: event_edges; Type: TABLE; Schema: public; Owner: -
  324. --
  325. CREATE TABLE event_edges (
  326. event_id text NOT NULL,
  327. prev_event_id text NOT NULL,
  328. room_id text NOT NULL,
  329. is_state boolean NOT NULL
  330. );
  331. --
  332. -- Name: event_forward_extremities; Type: TABLE; Schema: public; Owner: -
  333. --
  334. CREATE TABLE event_forward_extremities (
  335. event_id text NOT NULL,
  336. room_id text NOT NULL
  337. );
  338. --
  339. -- Name: event_json; Type: TABLE; Schema: public; Owner: -
  340. --
  341. CREATE TABLE event_json (
  342. event_id text NOT NULL,
  343. room_id text NOT NULL,
  344. internal_metadata text NOT NULL,
  345. json text NOT NULL
  346. );
  347. --
  348. -- Name: event_push_actions; Type: TABLE; Schema: public; Owner: -
  349. --
  350. CREATE TABLE event_push_actions (
  351. room_id text NOT NULL,
  352. event_id text NOT NULL,
  353. user_id text NOT NULL,
  354. profile_tag character varying(32),
  355. actions text NOT NULL,
  356. topological_ordering bigint,
  357. stream_ordering bigint,
  358. notif smallint,
  359. highlight smallint
  360. );
  361. --
  362. -- Name: event_push_actions_staging; Type: TABLE; Schema: public; Owner: -
  363. --
  364. CREATE TABLE event_push_actions_staging (
  365. event_id text NOT NULL,
  366. user_id text NOT NULL,
  367. actions text NOT NULL,
  368. notif smallint NOT NULL,
  369. highlight smallint NOT NULL
  370. );
  371. --
  372. -- Name: event_push_summary; Type: TABLE; Schema: public; Owner: -
  373. --
  374. CREATE TABLE event_push_summary (
  375. user_id text NOT NULL,
  376. room_id text NOT NULL,
  377. notif_count bigint NOT NULL,
  378. stream_ordering bigint NOT NULL
  379. );
  380. --
  381. -- Name: event_push_summary_stream_ordering; Type: TABLE; Schema: public; Owner: -
  382. --
  383. CREATE TABLE event_push_summary_stream_ordering (
  384. lock character(1) DEFAULT 'X'::bpchar NOT NULL,
  385. stream_ordering bigint NOT NULL,
  386. CONSTRAINT event_push_summary_stream_ordering_lock_check CHECK ((lock = 'X'::bpchar))
  387. );
  388. --
  389. -- Name: event_reference_hashes; Type: TABLE; Schema: public; Owner: -
  390. --
  391. CREATE TABLE event_reference_hashes (
  392. event_id text,
  393. algorithm text,
  394. hash bytea
  395. );
  396. --
  397. -- Name: event_reports; Type: TABLE; Schema: public; Owner: -
  398. --
  399. CREATE TABLE event_reports (
  400. id bigint NOT NULL,
  401. received_ts bigint NOT NULL,
  402. room_id text NOT NULL,
  403. event_id text NOT NULL,
  404. user_id text NOT NULL,
  405. reason text,
  406. content text
  407. );
  408. --
  409. -- Name: event_search; Type: TABLE; Schema: public; Owner: -
  410. --
  411. CREATE TABLE event_search (
  412. event_id text,
  413. room_id text,
  414. sender text,
  415. key text,
  416. vector tsvector,
  417. origin_server_ts bigint,
  418. stream_ordering bigint
  419. );
  420. --
  421. -- Name: event_signatures; Type: TABLE; Schema: public; Owner: -
  422. --
  423. CREATE TABLE event_signatures (
  424. event_id text,
  425. signature_name text,
  426. key_id text,
  427. signature bytea
  428. );
  429. --
  430. -- Name: event_to_state_groups; Type: TABLE; Schema: public; Owner: -
  431. --
  432. CREATE TABLE event_to_state_groups (
  433. event_id text NOT NULL,
  434. state_group bigint NOT NULL
  435. );
  436. --
  437. -- Name: events; Type: TABLE; Schema: public; Owner: -
  438. --
  439. CREATE TABLE events (
  440. stream_ordering integer NOT NULL,
  441. topological_ordering bigint NOT NULL,
  442. event_id text NOT NULL,
  443. type text NOT NULL,
  444. room_id text NOT NULL,
  445. content text,
  446. unrecognized_keys text,
  447. processed boolean NOT NULL,
  448. outlier boolean NOT NULL,
  449. depth bigint DEFAULT 0 NOT NULL,
  450. origin_server_ts bigint,
  451. received_ts bigint,
  452. sender text,
  453. contains_url boolean
  454. );
  455. --
  456. -- Name: ex_outlier_stream; Type: TABLE; Schema: public; Owner: -
  457. --
  458. CREATE TABLE ex_outlier_stream (
  459. event_stream_ordering bigint NOT NULL,
  460. event_id text NOT NULL,
  461. state_group bigint NOT NULL
  462. );
  463. --
  464. -- Name: federation_stream_position; Type: TABLE; Schema: public; Owner: -
  465. --
  466. CREATE TABLE federation_stream_position (
  467. type text NOT NULL,
  468. stream_id integer NOT NULL
  469. );
  470. --
  471. -- Name: feedback; Type: TABLE; Schema: public; Owner: -
  472. --
  473. CREATE TABLE feedback (
  474. event_id text NOT NULL,
  475. feedback_type text,
  476. target_event_id text,
  477. sender text,
  478. room_id text
  479. );
  480. --
  481. -- Name: group_attestations_remote; Type: TABLE; Schema: public; Owner: -
  482. --
  483. CREATE TABLE group_attestations_remote (
  484. group_id text NOT NULL,
  485. user_id text NOT NULL,
  486. valid_until_ms bigint NOT NULL,
  487. attestation_json text NOT NULL
  488. );
  489. --
  490. -- Name: group_attestations_renewals; Type: TABLE; Schema: public; Owner: -
  491. --
  492. CREATE TABLE group_attestations_renewals (
  493. group_id text NOT NULL,
  494. user_id text NOT NULL,
  495. valid_until_ms bigint NOT NULL
  496. );
  497. --
  498. -- Name: group_invites; Type: TABLE; Schema: public; Owner: -
  499. --
  500. CREATE TABLE group_invites (
  501. group_id text NOT NULL,
  502. user_id text NOT NULL
  503. );
  504. --
  505. -- Name: group_roles; Type: TABLE; Schema: public; Owner: -
  506. --
  507. CREATE TABLE group_roles (
  508. group_id text NOT NULL,
  509. role_id text NOT NULL,
  510. profile text NOT NULL,
  511. is_public boolean NOT NULL
  512. );
  513. --
  514. -- Name: group_room_categories; Type: TABLE; Schema: public; Owner: -
  515. --
  516. CREATE TABLE group_room_categories (
  517. group_id text NOT NULL,
  518. category_id text NOT NULL,
  519. profile text NOT NULL,
  520. is_public boolean NOT NULL
  521. );
  522. --
  523. -- Name: group_rooms; Type: TABLE; Schema: public; Owner: -
  524. --
  525. CREATE TABLE group_rooms (
  526. group_id text NOT NULL,
  527. room_id text NOT NULL,
  528. is_public boolean NOT NULL
  529. );
  530. --
  531. -- Name: group_summary_roles; Type: TABLE; Schema: public; Owner: -
  532. --
  533. CREATE TABLE group_summary_roles (
  534. group_id text NOT NULL,
  535. role_id text NOT NULL,
  536. role_order bigint NOT NULL,
  537. CONSTRAINT group_summary_roles_role_order_check CHECK ((role_order > 0))
  538. );
  539. --
  540. -- Name: group_summary_room_categories; Type: TABLE; Schema: public; Owner: -
  541. --
  542. CREATE TABLE group_summary_room_categories (
  543. group_id text NOT NULL,
  544. category_id text NOT NULL,
  545. cat_order bigint NOT NULL,
  546. CONSTRAINT group_summary_room_categories_cat_order_check CHECK ((cat_order > 0))
  547. );
  548. --
  549. -- Name: group_summary_rooms; Type: TABLE; Schema: public; Owner: -
  550. --
  551. CREATE TABLE group_summary_rooms (
  552. group_id text NOT NULL,
  553. room_id text NOT NULL,
  554. category_id text NOT NULL,
  555. room_order bigint NOT NULL,
  556. is_public boolean NOT NULL,
  557. CONSTRAINT group_summary_rooms_room_order_check CHECK ((room_order > 0))
  558. );
  559. --
  560. -- Name: group_summary_users; Type: TABLE; Schema: public; Owner: -
  561. --
  562. CREATE TABLE group_summary_users (
  563. group_id text NOT NULL,
  564. user_id text NOT NULL,
  565. role_id text NOT NULL,
  566. user_order bigint NOT NULL,
  567. is_public boolean NOT NULL
  568. );
  569. --
  570. -- Name: group_users; Type: TABLE; Schema: public; Owner: -
  571. --
  572. CREATE TABLE group_users (
  573. group_id text NOT NULL,
  574. user_id text NOT NULL,
  575. is_admin boolean NOT NULL,
  576. is_public boolean NOT NULL
  577. );
  578. --
  579. -- Name: groups; Type: TABLE; Schema: public; Owner: -
  580. --
  581. CREATE TABLE groups (
  582. group_id text NOT NULL,
  583. name text,
  584. avatar_url text,
  585. short_description text,
  586. long_description text,
  587. is_public boolean NOT NULL,
  588. join_policy text DEFAULT 'invite'::text NOT NULL
  589. );
  590. --
  591. -- Name: guest_access; Type: TABLE; Schema: public; Owner: -
  592. --
  593. CREATE TABLE guest_access (
  594. event_id text NOT NULL,
  595. room_id text NOT NULL,
  596. guest_access text NOT NULL
  597. );
  598. --
  599. -- Name: history_visibility; Type: TABLE; Schema: public; Owner: -
  600. --
  601. CREATE TABLE history_visibility (
  602. event_id text NOT NULL,
  603. room_id text NOT NULL,
  604. history_visibility text NOT NULL
  605. );
  606. --
  607. -- Name: local_group_membership; Type: TABLE; Schema: public; Owner: -
  608. --
  609. CREATE TABLE local_group_membership (
  610. group_id text NOT NULL,
  611. user_id text NOT NULL,
  612. is_admin boolean NOT NULL,
  613. membership text NOT NULL,
  614. is_publicised boolean NOT NULL,
  615. content text NOT NULL
  616. );
  617. --
  618. -- Name: local_group_updates; Type: TABLE; Schema: public; Owner: -
  619. --
  620. CREATE TABLE local_group_updates (
  621. stream_id bigint NOT NULL,
  622. group_id text NOT NULL,
  623. user_id text NOT NULL,
  624. type text NOT NULL,
  625. content text NOT NULL
  626. );
  627. --
  628. -- Name: local_invites; Type: TABLE; Schema: public; Owner: -
  629. --
  630. CREATE TABLE local_invites (
  631. stream_id bigint NOT NULL,
  632. inviter text NOT NULL,
  633. invitee text NOT NULL,
  634. event_id text NOT NULL,
  635. room_id text NOT NULL,
  636. locally_rejected text,
  637. replaced_by text
  638. );
  639. --
  640. -- Name: local_media_repository; Type: TABLE; Schema: public; Owner: -
  641. --
  642. CREATE TABLE local_media_repository (
  643. media_id text,
  644. media_type text,
  645. media_length integer,
  646. created_ts bigint,
  647. upload_name text,
  648. user_id text,
  649. quarantined_by text,
  650. url_cache text,
  651. last_access_ts bigint
  652. );
  653. --
  654. -- Name: local_media_repository_thumbnails; Type: TABLE; Schema: public; Owner: -
  655. --
  656. CREATE TABLE local_media_repository_thumbnails (
  657. media_id text,
  658. thumbnail_width integer,
  659. thumbnail_height integer,
  660. thumbnail_type text,
  661. thumbnail_method text,
  662. thumbnail_length integer
  663. );
  664. --
  665. -- Name: local_media_repository_url_cache; Type: TABLE; Schema: public; Owner: -
  666. --
  667. CREATE TABLE local_media_repository_url_cache (
  668. url text,
  669. response_code integer,
  670. etag text,
  671. expires_ts bigint,
  672. og text,
  673. media_id text,
  674. download_ts bigint
  675. );
  676. --
  677. -- Name: monthly_active_users; Type: TABLE; Schema: public; Owner: -
  678. --
  679. CREATE TABLE monthly_active_users (
  680. user_id text NOT NULL,
  681. "timestamp" bigint NOT NULL
  682. );
  683. --
  684. -- Name: open_id_tokens; Type: TABLE; Schema: public; Owner: -
  685. --
  686. CREATE TABLE open_id_tokens (
  687. token text NOT NULL,
  688. ts_valid_until_ms bigint NOT NULL,
  689. user_id text NOT NULL
  690. );
  691. --
  692. -- Name: presence; Type: TABLE; Schema: public; Owner: -
  693. --
  694. CREATE TABLE presence (
  695. user_id text NOT NULL,
  696. state character varying(20),
  697. status_msg text,
  698. mtime bigint
  699. );
  700. --
  701. -- Name: presence_allow_inbound; Type: TABLE; Schema: public; Owner: -
  702. --
  703. CREATE TABLE presence_allow_inbound (
  704. observed_user_id text NOT NULL,
  705. observer_user_id text NOT NULL
  706. );
  707. --
  708. -- Name: presence_list; Type: TABLE; Schema: public; Owner: -
  709. --
  710. CREATE TABLE presence_list (
  711. user_id text NOT NULL,
  712. observed_user_id text NOT NULL,
  713. accepted boolean NOT NULL
  714. );
  715. --
  716. -- Name: presence_stream; Type: TABLE; Schema: public; Owner: -
  717. --
  718. CREATE TABLE presence_stream (
  719. stream_id bigint,
  720. user_id text,
  721. state text,
  722. last_active_ts bigint,
  723. last_federation_update_ts bigint,
  724. last_user_sync_ts bigint,
  725. status_msg text,
  726. currently_active boolean
  727. );
  728. --
  729. -- Name: profiles; Type: TABLE; Schema: public; Owner: -
  730. --
  731. CREATE TABLE profiles (
  732. user_id text NOT NULL,
  733. displayname text,
  734. avatar_url text
  735. );
  736. --
  737. -- Name: public_room_list_stream; Type: TABLE; Schema: public; Owner: -
  738. --
  739. CREATE TABLE public_room_list_stream (
  740. stream_id bigint NOT NULL,
  741. room_id text NOT NULL,
  742. visibility boolean NOT NULL,
  743. appservice_id text,
  744. network_id text
  745. );
  746. --
  747. -- Name: push_rules; Type: TABLE; Schema: public; Owner: -
  748. --
  749. CREATE TABLE push_rules (
  750. id bigint NOT NULL,
  751. user_name text NOT NULL,
  752. rule_id text NOT NULL,
  753. priority_class smallint NOT NULL,
  754. priority integer DEFAULT 0 NOT NULL,
  755. conditions text NOT NULL,
  756. actions text NOT NULL
  757. );
  758. --
  759. -- Name: push_rules_enable; Type: TABLE; Schema: public; Owner: -
  760. --
  761. CREATE TABLE push_rules_enable (
  762. id bigint NOT NULL,
  763. user_name text NOT NULL,
  764. rule_id text NOT NULL,
  765. enabled smallint
  766. );
  767. --
  768. -- Name: push_rules_stream; Type: TABLE; Schema: public; Owner: -
  769. --
  770. CREATE TABLE push_rules_stream (
  771. stream_id bigint NOT NULL,
  772. event_stream_ordering bigint NOT NULL,
  773. user_id text NOT NULL,
  774. rule_id text NOT NULL,
  775. op text NOT NULL,
  776. priority_class smallint,
  777. priority integer,
  778. conditions text,
  779. actions text
  780. );
  781. --
  782. -- Name: pusher_throttle; Type: TABLE; Schema: public; Owner: -
  783. --
  784. CREATE TABLE pusher_throttle (
  785. pusher bigint NOT NULL,
  786. room_id text NOT NULL,
  787. last_sent_ts bigint,
  788. throttle_ms bigint
  789. );
  790. --
  791. -- Name: pushers; Type: TABLE; Schema: public; Owner: -
  792. --
  793. CREATE TABLE pushers (
  794. id bigint NOT NULL,
  795. user_name text NOT NULL,
  796. access_token bigint,
  797. profile_tag text NOT NULL,
  798. kind text NOT NULL,
  799. app_id text NOT NULL,
  800. app_display_name text NOT NULL,
  801. device_display_name text NOT NULL,
  802. pushkey text NOT NULL,
  803. ts bigint NOT NULL,
  804. lang text,
  805. data text,
  806. last_stream_ordering integer,
  807. last_success bigint,
  808. failing_since bigint
  809. );
  810. --
  811. -- Name: ratelimit_override; Type: TABLE; Schema: public; Owner: -
  812. --
  813. CREATE TABLE ratelimit_override (
  814. user_id text NOT NULL,
  815. messages_per_second bigint,
  816. burst_count bigint
  817. );
  818. --
  819. -- Name: receipts_graph; Type: TABLE; Schema: public; Owner: -
  820. --
  821. CREATE TABLE receipts_graph (
  822. room_id text NOT NULL,
  823. receipt_type text NOT NULL,
  824. user_id text NOT NULL,
  825. event_ids text NOT NULL,
  826. data text NOT NULL
  827. );
  828. --
  829. -- Name: receipts_linearized; Type: TABLE; Schema: public; Owner: -
  830. --
  831. CREATE TABLE receipts_linearized (
  832. stream_id bigint NOT NULL,
  833. room_id text NOT NULL,
  834. receipt_type text NOT NULL,
  835. user_id text NOT NULL,
  836. event_id text NOT NULL,
  837. data text NOT NULL
  838. );
  839. --
  840. -- Name: received_transactions; Type: TABLE; Schema: public; Owner: -
  841. --
  842. CREATE TABLE received_transactions (
  843. transaction_id text,
  844. origin text,
  845. ts bigint,
  846. response_code integer,
  847. response_json bytea,
  848. has_been_referenced smallint DEFAULT 0
  849. );
  850. --
  851. -- Name: redactions; Type: TABLE; Schema: public; Owner: -
  852. --
  853. CREATE TABLE redactions (
  854. event_id text NOT NULL,
  855. redacts text NOT NULL
  856. );
  857. --
  858. -- Name: rejections; Type: TABLE; Schema: public; Owner: -
  859. --
  860. CREATE TABLE rejections (
  861. event_id text NOT NULL,
  862. reason text NOT NULL,
  863. last_check text NOT NULL
  864. );
  865. --
  866. -- Name: remote_media_cache; Type: TABLE; Schema: public; Owner: -
  867. --
  868. CREATE TABLE remote_media_cache (
  869. media_origin text,
  870. media_id text,
  871. media_type text,
  872. created_ts bigint,
  873. upload_name text,
  874. media_length integer,
  875. filesystem_id text,
  876. last_access_ts bigint,
  877. quarantined_by text
  878. );
  879. --
  880. -- Name: remote_media_cache_thumbnails; Type: TABLE; Schema: public; Owner: -
  881. --
  882. CREATE TABLE remote_media_cache_thumbnails (
  883. media_origin text,
  884. media_id text,
  885. thumbnail_width integer,
  886. thumbnail_height integer,
  887. thumbnail_method text,
  888. thumbnail_type text,
  889. thumbnail_length integer,
  890. filesystem_id text
  891. );
  892. --
  893. -- Name: remote_profile_cache; Type: TABLE; Schema: public; Owner: -
  894. --
  895. CREATE TABLE remote_profile_cache (
  896. user_id text NOT NULL,
  897. displayname text,
  898. avatar_url text,
  899. last_check bigint NOT NULL
  900. );
  901. --
  902. -- Name: room_account_data; Type: TABLE; Schema: public; Owner: -
  903. --
  904. CREATE TABLE room_account_data (
  905. user_id text NOT NULL,
  906. room_id text NOT NULL,
  907. account_data_type text NOT NULL,
  908. stream_id bigint NOT NULL,
  909. content text NOT NULL
  910. );
  911. --
  912. -- Name: room_alias_servers; Type: TABLE; Schema: public; Owner: -
  913. --
  914. CREATE TABLE room_alias_servers (
  915. room_alias text NOT NULL,
  916. server text NOT NULL
  917. );
  918. --
  919. -- Name: room_aliases; Type: TABLE; Schema: public; Owner: -
  920. --
  921. CREATE TABLE room_aliases (
  922. room_alias text NOT NULL,
  923. room_id text NOT NULL,
  924. creator text
  925. );
  926. --
  927. -- Name: room_depth; Type: TABLE; Schema: public; Owner: -
  928. --
  929. CREATE TABLE room_depth (
  930. room_id text NOT NULL,
  931. min_depth integer NOT NULL
  932. );
  933. --
  934. -- Name: room_hosts; Type: TABLE; Schema: public; Owner: -
  935. --
  936. CREATE TABLE room_hosts (
  937. room_id text NOT NULL,
  938. host text NOT NULL
  939. );
  940. --
  941. -- Name: room_memberships; Type: TABLE; Schema: public; Owner: -
  942. --
  943. CREATE TABLE room_memberships (
  944. event_id text NOT NULL,
  945. user_id text NOT NULL,
  946. sender text NOT NULL,
  947. room_id text NOT NULL,
  948. membership text NOT NULL,
  949. forgotten integer DEFAULT 0,
  950. display_name text,
  951. avatar_url text
  952. );
  953. --
  954. -- Name: room_names; Type: TABLE; Schema: public; Owner: -
  955. --
  956. CREATE TABLE room_names (
  957. event_id text NOT NULL,
  958. room_id text NOT NULL,
  959. name text NOT NULL
  960. );
  961. --
  962. -- Name: room_tags; Type: TABLE; Schema: public; Owner: -
  963. --
  964. CREATE TABLE room_tags (
  965. user_id text NOT NULL,
  966. room_id text NOT NULL,
  967. tag text NOT NULL,
  968. content text NOT NULL
  969. );
  970. --
  971. -- Name: room_tags_revisions; Type: TABLE; Schema: public; Owner: -
  972. --
  973. CREATE TABLE room_tags_revisions (
  974. user_id text NOT NULL,
  975. room_id text NOT NULL,
  976. stream_id bigint NOT NULL
  977. );
  978. --
  979. -- Name: rooms; Type: TABLE; Schema: public; Owner: -
  980. --
  981. CREATE TABLE rooms (
  982. room_id text NOT NULL,
  983. is_public boolean,
  984. creator text
  985. );
  986. --
  987. -- Name: server_keys_json; Type: TABLE; Schema: public; Owner: -
  988. --
  989. CREATE TABLE server_keys_json (
  990. server_name text NOT NULL,
  991. key_id text NOT NULL,
  992. from_server text NOT NULL,
  993. ts_added_ms bigint NOT NULL,
  994. ts_valid_until_ms bigint NOT NULL,
  995. key_json bytea NOT NULL
  996. );
  997. --
  998. -- Name: server_signature_keys; Type: TABLE; Schema: public; Owner: -
  999. --
  1000. CREATE TABLE server_signature_keys (
  1001. server_name text,
  1002. key_id text,
  1003. from_server text,
  1004. ts_added_ms bigint,
  1005. verify_key bytea
  1006. );
  1007. --
  1008. -- Name: server_tls_certificates; Type: TABLE; Schema: public; Owner: -
  1009. --
  1010. CREATE TABLE server_tls_certificates (
  1011. server_name text,
  1012. fingerprint text,
  1013. from_server text,
  1014. ts_added_ms bigint,
  1015. tls_certificate bytea
  1016. );
  1017. --
  1018. -- Name: state_events; Type: TABLE; Schema: public; Owner: -
  1019. --
  1020. CREATE TABLE state_events (
  1021. event_id text NOT NULL,
  1022. room_id text NOT NULL,
  1023. type text NOT NULL,
  1024. state_key text NOT NULL,
  1025. prev_state text
  1026. );
  1027. --
  1028. -- Name: state_forward_extremities; Type: TABLE; Schema: public; Owner: -
  1029. --
  1030. CREATE TABLE state_forward_extremities (
  1031. event_id text NOT NULL,
  1032. room_id text NOT NULL,
  1033. type text NOT NULL,
  1034. state_key text NOT NULL
  1035. );
  1036. --
  1037. -- Name: state_group_edges; Type: TABLE; Schema: public; Owner: -
  1038. --
  1039. CREATE TABLE state_group_edges (
  1040. state_group bigint NOT NULL,
  1041. prev_state_group bigint NOT NULL
  1042. );
  1043. --
  1044. -- Name: state_group_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  1045. --
  1046. CREATE SEQUENCE state_group_id_seq
  1047. START WITH 1
  1048. INCREMENT BY 1
  1049. NO MINVALUE
  1050. NO MAXVALUE
  1051. CACHE 1;
  1052. --
  1053. -- Name: state_groups; Type: TABLE; Schema: public; Owner: -
  1054. --
  1055. CREATE TABLE state_groups (
  1056. id bigint NOT NULL,
  1057. room_id text NOT NULL,
  1058. event_id text NOT NULL
  1059. );
  1060. --
  1061. -- Name: state_groups_state; Type: TABLE; Schema: public; Owner: -
  1062. --
  1063. CREATE TABLE state_groups_state (
  1064. state_group bigint NOT NULL,
  1065. room_id text NOT NULL,
  1066. type text NOT NULL,
  1067. state_key text NOT NULL,
  1068. event_id text NOT NULL
  1069. );
  1070. --
  1071. -- Name: stats_reporting; Type: TABLE; Schema: public; Owner: -
  1072. --
  1073. CREATE TABLE stats_reporting (
  1074. reported_stream_token integer,
  1075. reported_time bigint
  1076. );
  1077. --
  1078. -- Name: stream_ordering_to_exterm; Type: TABLE; Schema: public; Owner: -
  1079. --
  1080. CREATE TABLE stream_ordering_to_exterm (
  1081. stream_ordering bigint NOT NULL,
  1082. room_id text NOT NULL,
  1083. event_id text NOT NULL
  1084. );
  1085. --
  1086. -- Name: threepid_guest_access_tokens; Type: TABLE; Schema: public; Owner: -
  1087. --
  1088. CREATE TABLE threepid_guest_access_tokens (
  1089. medium text,
  1090. address text,
  1091. guest_access_token text,
  1092. first_inviter text
  1093. );
  1094. --
  1095. -- Name: topics; Type: TABLE; Schema: public; Owner: -
  1096. --
  1097. CREATE TABLE topics (
  1098. event_id text NOT NULL,
  1099. room_id text NOT NULL,
  1100. topic text NOT NULL
  1101. );
  1102. --
  1103. -- Name: transaction_id_to_pdu; Type: TABLE; Schema: public; Owner: -
  1104. --
  1105. CREATE TABLE transaction_id_to_pdu (
  1106. transaction_id integer,
  1107. destination text,
  1108. pdu_id text,
  1109. pdu_origin text
  1110. );
  1111. --
  1112. -- Name: user_daily_visits; Type: TABLE; Schema: public; Owner: -
  1113. --
  1114. CREATE TABLE user_daily_visits (
  1115. user_id text NOT NULL,
  1116. device_id text,
  1117. "timestamp" bigint NOT NULL
  1118. );
  1119. --
  1120. -- Name: user_directory; Type: TABLE; Schema: public; Owner: -
  1121. --
  1122. CREATE TABLE user_directory (
  1123. user_id text NOT NULL,
  1124. room_id text,
  1125. display_name text,
  1126. avatar_url text
  1127. );
  1128. --
  1129. -- Name: user_directory_search; Type: TABLE; Schema: public; Owner: -
  1130. --
  1131. CREATE TABLE user_directory_search (
  1132. user_id text NOT NULL,
  1133. vector tsvector
  1134. );
  1135. --
  1136. -- Name: user_directory_stream_pos; Type: TABLE; Schema: public; Owner: -
  1137. --
  1138. CREATE TABLE user_directory_stream_pos (
  1139. lock character(1) DEFAULT 'X'::bpchar NOT NULL,
  1140. stream_id bigint,
  1141. CONSTRAINT user_directory_stream_pos_lock_check CHECK ((lock = 'X'::bpchar))
  1142. );
  1143. --
  1144. -- Name: user_filters; Type: TABLE; Schema: public; Owner: -
  1145. --
  1146. CREATE TABLE user_filters (
  1147. user_id text,
  1148. filter_id bigint,
  1149. filter_json bytea
  1150. );
  1151. --
  1152. -- Name: user_ips; Type: TABLE; Schema: public; Owner: -
  1153. --
  1154. CREATE TABLE user_ips (
  1155. user_id text NOT NULL,
  1156. access_token text NOT NULL,
  1157. device_id text,
  1158. ip text NOT NULL,
  1159. user_agent text NOT NULL,
  1160. last_seen bigint NOT NULL
  1161. );
  1162. --
  1163. -- Name: user_threepids; Type: TABLE; Schema: public; Owner: -
  1164. --
  1165. CREATE TABLE user_threepids (
  1166. user_id text NOT NULL,
  1167. medium text NOT NULL,
  1168. address text NOT NULL,
  1169. validated_at bigint NOT NULL,
  1170. added_at bigint NOT NULL
  1171. );
  1172. --
  1173. -- Name: users; Type: TABLE; Schema: public; Owner: -
  1174. --
  1175. CREATE TABLE users (
  1176. name text,
  1177. password_hash text,
  1178. creation_ts bigint,
  1179. admin smallint DEFAULT 0 NOT NULL,
  1180. upgrade_ts bigint,
  1181. is_guest smallint DEFAULT 0 NOT NULL,
  1182. appservice_id text,
  1183. consent_version text,
  1184. consent_server_notice_sent text,
  1185. user_type text
  1186. );
  1187. --
  1188. -- Name: users_in_public_rooms; Type: TABLE; Schema: public; Owner: -
  1189. --
  1190. CREATE TABLE users_in_public_rooms (
  1191. user_id text NOT NULL,
  1192. room_id text NOT NULL
  1193. );
  1194. --
  1195. -- Name: users_pending_deactivation; Type: TABLE; Schema: public; Owner: -
  1196. --
  1197. CREATE TABLE users_pending_deactivation (
  1198. user_id text NOT NULL
  1199. );
  1200. --
  1201. -- Name: users_who_share_rooms; Type: TABLE; Schema: public; Owner: -
  1202. --
  1203. CREATE TABLE users_who_share_rooms (
  1204. user_id text NOT NULL,
  1205. other_user_id text NOT NULL,
  1206. room_id text NOT NULL,
  1207. share_private boolean NOT NULL
  1208. );
  1209. --
  1210. -- Name: access_tokens access_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1211. --
  1212. ALTER TABLE ONLY access_tokens
  1213. ADD CONSTRAINT access_tokens_pkey PRIMARY KEY (id);
  1214. --
  1215. -- Name: access_tokens access_tokens_token_key; Type: CONSTRAINT; Schema: public; Owner: -
  1216. --
  1217. ALTER TABLE ONLY access_tokens
  1218. ADD CONSTRAINT access_tokens_token_key UNIQUE (token);
  1219. --
  1220. -- Name: account_data account_data_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1221. --
  1222. ALTER TABLE ONLY account_data
  1223. ADD CONSTRAINT account_data_uniqueness UNIQUE (user_id, account_data_type);
  1224. --
  1225. -- Name: application_services application_services_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1226. --
  1227. ALTER TABLE ONLY application_services
  1228. ADD CONSTRAINT application_services_pkey PRIMARY KEY (id);
  1229. --
  1230. -- Name: application_services_regex application_services_regex_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1231. --
  1232. ALTER TABLE ONLY application_services_regex
  1233. ADD CONSTRAINT application_services_regex_pkey PRIMARY KEY (id);
  1234. --
  1235. -- Name: application_services_state application_services_state_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1236. --
  1237. ALTER TABLE ONLY application_services_state
  1238. ADD CONSTRAINT application_services_state_pkey PRIMARY KEY (as_id);
  1239. --
  1240. -- Name: application_services application_services_token_key; Type: CONSTRAINT; Schema: public; Owner: -
  1241. --
  1242. ALTER TABLE ONLY application_services
  1243. ADD CONSTRAINT application_services_token_key UNIQUE (token);
  1244. --
  1245. -- Name: application_services_txns application_services_txns_as_id_txn_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1246. --
  1247. ALTER TABLE ONLY application_services_txns
  1248. ADD CONSTRAINT application_services_txns_as_id_txn_id_key UNIQUE (as_id, txn_id);
  1249. --
  1250. -- Name: appservice_stream_position appservice_stream_position_lock_key; Type: CONSTRAINT; Schema: public; Owner: -
  1251. --
  1252. ALTER TABLE ONLY appservice_stream_position
  1253. ADD CONSTRAINT appservice_stream_position_lock_key UNIQUE (lock);
  1254. --
  1255. -- Name: background_updates background_updates_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1256. --
  1257. ALTER TABLE ONLY background_updates
  1258. ADD CONSTRAINT background_updates_uniqueness UNIQUE (update_name);
  1259. --
  1260. -- Name: current_state_events current_state_events_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1261. --
  1262. ALTER TABLE ONLY current_state_events
  1263. ADD CONSTRAINT current_state_events_event_id_key UNIQUE (event_id);
  1264. --
  1265. -- Name: current_state_events current_state_events_room_id_type_state_key_key; Type: CONSTRAINT; Schema: public; Owner: -
  1266. --
  1267. ALTER TABLE ONLY current_state_events
  1268. ADD CONSTRAINT current_state_events_room_id_type_state_key_key UNIQUE (room_id, type, state_key);
  1269. --
  1270. -- Name: current_state_resets current_state_resets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1271. --
  1272. ALTER TABLE ONLY current_state_resets
  1273. ADD CONSTRAINT current_state_resets_pkey PRIMARY KEY (event_stream_ordering);
  1274. --
  1275. -- Name: destinations destinations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1276. --
  1277. ALTER TABLE ONLY destinations
  1278. ADD CONSTRAINT destinations_pkey PRIMARY KEY (destination);
  1279. --
  1280. -- Name: devices device_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1281. --
  1282. ALTER TABLE ONLY devices
  1283. ADD CONSTRAINT device_uniqueness UNIQUE (user_id, device_id);
  1284. --
  1285. -- Name: e2e_device_keys_json e2e_device_keys_json_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1286. --
  1287. ALTER TABLE ONLY e2e_device_keys_json
  1288. ADD CONSTRAINT e2e_device_keys_json_uniqueness UNIQUE (user_id, device_id);
  1289. --
  1290. -- Name: e2e_one_time_keys_json e2e_one_time_keys_json_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1291. --
  1292. ALTER TABLE ONLY e2e_one_time_keys_json
  1293. ADD CONSTRAINT e2e_one_time_keys_json_uniqueness UNIQUE (user_id, device_id, algorithm, key_id);
  1294. --
  1295. -- Name: event_backward_extremities event_backward_extremities_event_id_room_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1296. --
  1297. ALTER TABLE ONLY event_backward_extremities
  1298. ADD CONSTRAINT event_backward_extremities_event_id_room_id_key UNIQUE (event_id, room_id);
  1299. --
  1300. -- Name: event_content_hashes event_content_hashes_event_id_algorithm_key; Type: CONSTRAINT; Schema: public; Owner: -
  1301. --
  1302. ALTER TABLE ONLY event_content_hashes
  1303. ADD CONSTRAINT event_content_hashes_event_id_algorithm_key UNIQUE (event_id, algorithm);
  1304. --
  1305. -- Name: event_destinations event_destinations_event_id_destination_key; Type: CONSTRAINT; Schema: public; Owner: -
  1306. --
  1307. ALTER TABLE ONLY event_destinations
  1308. ADD CONSTRAINT event_destinations_event_id_destination_key UNIQUE (event_id, destination);
  1309. --
  1310. -- Name: event_edge_hashes event_edge_hashes_event_id_prev_event_id_algorithm_key; Type: CONSTRAINT; Schema: public; Owner: -
  1311. --
  1312. ALTER TABLE ONLY event_edge_hashes
  1313. ADD CONSTRAINT event_edge_hashes_event_id_prev_event_id_algorithm_key UNIQUE (event_id, prev_event_id, algorithm);
  1314. --
  1315. -- Name: event_edges event_edges_event_id_prev_event_id_room_id_is_state_key; Type: CONSTRAINT; Schema: public; Owner: -
  1316. --
  1317. ALTER TABLE ONLY event_edges
  1318. ADD CONSTRAINT event_edges_event_id_prev_event_id_room_id_is_state_key UNIQUE (event_id, prev_event_id, room_id, is_state);
  1319. --
  1320. -- Name: event_forward_extremities event_forward_extremities_event_id_room_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1321. --
  1322. ALTER TABLE ONLY event_forward_extremities
  1323. ADD CONSTRAINT event_forward_extremities_event_id_room_id_key UNIQUE (event_id, room_id);
  1324. --
  1325. -- Name: event_push_actions event_id_user_id_profile_tag_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1326. --
  1327. ALTER TABLE ONLY event_push_actions
  1328. ADD CONSTRAINT event_id_user_id_profile_tag_uniqueness UNIQUE (room_id, event_id, user_id, profile_tag);
  1329. --
  1330. -- Name: event_json event_json_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1331. --
  1332. ALTER TABLE ONLY event_json
  1333. ADD CONSTRAINT event_json_event_id_key UNIQUE (event_id);
  1334. --
  1335. -- Name: event_push_summary_stream_ordering event_push_summary_stream_ordering_lock_key; Type: CONSTRAINT; Schema: public; Owner: -
  1336. --
  1337. ALTER TABLE ONLY event_push_summary_stream_ordering
  1338. ADD CONSTRAINT event_push_summary_stream_ordering_lock_key UNIQUE (lock);
  1339. --
  1340. -- Name: event_reference_hashes event_reference_hashes_event_id_algorithm_key; Type: CONSTRAINT; Schema: public; Owner: -
  1341. --
  1342. ALTER TABLE ONLY event_reference_hashes
  1343. ADD CONSTRAINT event_reference_hashes_event_id_algorithm_key UNIQUE (event_id, algorithm);
  1344. --
  1345. -- Name: event_reports event_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1346. --
  1347. ALTER TABLE ONLY event_reports
  1348. ADD CONSTRAINT event_reports_pkey PRIMARY KEY (id);
  1349. --
  1350. -- Name: event_signatures event_signatures_event_id_signature_name_key_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1351. --
  1352. ALTER TABLE ONLY event_signatures
  1353. ADD CONSTRAINT event_signatures_event_id_signature_name_key_id_key UNIQUE (event_id, signature_name, key_id);
  1354. --
  1355. -- Name: event_to_state_groups event_to_state_groups_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1356. --
  1357. ALTER TABLE ONLY event_to_state_groups
  1358. ADD CONSTRAINT event_to_state_groups_event_id_key UNIQUE (event_id);
  1359. --
  1360. -- Name: events events_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1361. --
  1362. ALTER TABLE ONLY events
  1363. ADD CONSTRAINT events_event_id_key UNIQUE (event_id);
  1364. --
  1365. -- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1366. --
  1367. ALTER TABLE ONLY events
  1368. ADD CONSTRAINT events_pkey PRIMARY KEY (stream_ordering);
  1369. --
  1370. -- Name: ex_outlier_stream ex_outlier_stream_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1371. --
  1372. ALTER TABLE ONLY ex_outlier_stream
  1373. ADD CONSTRAINT ex_outlier_stream_pkey PRIMARY KEY (event_stream_ordering);
  1374. --
  1375. -- Name: feedback feedback_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1376. --
  1377. ALTER TABLE ONLY feedback
  1378. ADD CONSTRAINT feedback_event_id_key UNIQUE (event_id);
  1379. --
  1380. -- Name: group_roles group_roles_group_id_role_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1381. --
  1382. ALTER TABLE ONLY group_roles
  1383. ADD CONSTRAINT group_roles_group_id_role_id_key UNIQUE (group_id, role_id);
  1384. --
  1385. -- Name: group_room_categories group_room_categories_group_id_category_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1386. --
  1387. ALTER TABLE ONLY group_room_categories
  1388. ADD CONSTRAINT group_room_categories_group_id_category_id_key UNIQUE (group_id, category_id);
  1389. --
  1390. -- Name: group_summary_roles group_summary_roles_group_id_role_id_role_order_key; Type: CONSTRAINT; Schema: public; Owner: -
  1391. --
  1392. ALTER TABLE ONLY group_summary_roles
  1393. ADD CONSTRAINT group_summary_roles_group_id_role_id_role_order_key UNIQUE (group_id, role_id, role_order);
  1394. --
  1395. -- Name: group_summary_room_categories group_summary_room_categories_group_id_category_id_cat_orde_key; Type: CONSTRAINT; Schema: public; Owner: -
  1396. --
  1397. ALTER TABLE ONLY group_summary_room_categories
  1398. ADD CONSTRAINT group_summary_room_categories_group_id_category_id_cat_orde_key UNIQUE (group_id, category_id, cat_order);
  1399. --
  1400. -- Name: group_summary_rooms group_summary_rooms_group_id_category_id_room_id_room_order_key; Type: CONSTRAINT; Schema: public; Owner: -
  1401. --
  1402. ALTER TABLE ONLY group_summary_rooms
  1403. ADD CONSTRAINT group_summary_rooms_group_id_category_id_room_id_room_order_key UNIQUE (group_id, category_id, room_id, room_order);
  1404. --
  1405. -- Name: guest_access guest_access_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1406. --
  1407. ALTER TABLE ONLY guest_access
  1408. ADD CONSTRAINT guest_access_event_id_key UNIQUE (event_id);
  1409. --
  1410. -- Name: history_visibility history_visibility_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1411. --
  1412. ALTER TABLE ONLY history_visibility
  1413. ADD CONSTRAINT history_visibility_event_id_key UNIQUE (event_id);
  1414. --
  1415. -- Name: local_media_repository local_media_repository_media_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1416. --
  1417. ALTER TABLE ONLY local_media_repository
  1418. ADD CONSTRAINT local_media_repository_media_id_key UNIQUE (media_id);
  1419. --
  1420. -- Name: local_media_repository_thumbnails local_media_repository_thumbn_media_id_thumbnail_width_thum_key; Type: CONSTRAINT; Schema: public; Owner: -
  1421. --
  1422. ALTER TABLE ONLY local_media_repository_thumbnails
  1423. ADD CONSTRAINT local_media_repository_thumbn_media_id_thumbnail_width_thum_key UNIQUE (media_id, thumbnail_width, thumbnail_height, thumbnail_type);
  1424. --
  1425. -- Name: user_threepids medium_address; Type: CONSTRAINT; Schema: public; Owner: -
  1426. --
  1427. ALTER TABLE ONLY user_threepids
  1428. ADD CONSTRAINT medium_address UNIQUE (medium, address);
  1429. --
  1430. -- Name: open_id_tokens open_id_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1431. --
  1432. ALTER TABLE ONLY open_id_tokens
  1433. ADD CONSTRAINT open_id_tokens_pkey PRIMARY KEY (token);
  1434. --
  1435. -- Name: presence_allow_inbound presence_allow_inbound_observed_user_id_observer_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1436. --
  1437. ALTER TABLE ONLY presence_allow_inbound
  1438. ADD CONSTRAINT presence_allow_inbound_observed_user_id_observer_user_id_key UNIQUE (observed_user_id, observer_user_id);
  1439. --
  1440. -- Name: presence_list presence_list_user_id_observed_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1441. --
  1442. ALTER TABLE ONLY presence_list
  1443. ADD CONSTRAINT presence_list_user_id_observed_user_id_key UNIQUE (user_id, observed_user_id);
  1444. --
  1445. -- Name: presence presence_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1446. --
  1447. ALTER TABLE ONLY presence
  1448. ADD CONSTRAINT presence_user_id_key UNIQUE (user_id);
  1449. --
  1450. -- Name: account_data_max_stream_id private_user_data_max_stream_id_lock_key; Type: CONSTRAINT; Schema: public; Owner: -
  1451. --
  1452. ALTER TABLE ONLY account_data_max_stream_id
  1453. ADD CONSTRAINT private_user_data_max_stream_id_lock_key UNIQUE (lock);
  1454. --
  1455. -- Name: profiles profiles_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1456. --
  1457. ALTER TABLE ONLY profiles
  1458. ADD CONSTRAINT profiles_user_id_key UNIQUE (user_id);
  1459. --
  1460. -- Name: push_rules_enable push_rules_enable_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1461. --
  1462. ALTER TABLE ONLY push_rules_enable
  1463. ADD CONSTRAINT push_rules_enable_pkey PRIMARY KEY (id);
  1464. --
  1465. -- Name: push_rules_enable push_rules_enable_user_name_rule_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1466. --
  1467. ALTER TABLE ONLY push_rules_enable
  1468. ADD CONSTRAINT push_rules_enable_user_name_rule_id_key UNIQUE (user_name, rule_id);
  1469. --
  1470. -- Name: push_rules push_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1471. --
  1472. ALTER TABLE ONLY push_rules
  1473. ADD CONSTRAINT push_rules_pkey PRIMARY KEY (id);
  1474. --
  1475. -- Name: push_rules push_rules_user_name_rule_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1476. --
  1477. ALTER TABLE ONLY push_rules
  1478. ADD CONSTRAINT push_rules_user_name_rule_id_key UNIQUE (user_name, rule_id);
  1479. --
  1480. -- Name: pusher_throttle pusher_throttle_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1481. --
  1482. ALTER TABLE ONLY pusher_throttle
  1483. ADD CONSTRAINT pusher_throttle_pkey PRIMARY KEY (pusher, room_id);
  1484. --
  1485. -- Name: pushers pushers2_app_id_pushkey_user_name_key; Type: CONSTRAINT; Schema: public; Owner: -
  1486. --
  1487. ALTER TABLE ONLY pushers
  1488. ADD CONSTRAINT pushers2_app_id_pushkey_user_name_key UNIQUE (app_id, pushkey, user_name);
  1489. --
  1490. -- Name: pushers pushers2_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1491. --
  1492. ALTER TABLE ONLY pushers
  1493. ADD CONSTRAINT pushers2_pkey PRIMARY KEY (id);
  1494. --
  1495. -- Name: receipts_graph receipts_graph_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1496. --
  1497. ALTER TABLE ONLY receipts_graph
  1498. ADD CONSTRAINT receipts_graph_uniqueness UNIQUE (room_id, receipt_type, user_id);
  1499. --
  1500. -- Name: receipts_linearized receipts_linearized_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1501. --
  1502. ALTER TABLE ONLY receipts_linearized
  1503. ADD CONSTRAINT receipts_linearized_uniqueness UNIQUE (room_id, receipt_type, user_id);
  1504. --
  1505. -- Name: received_transactions received_transactions_transaction_id_origin_key; Type: CONSTRAINT; Schema: public; Owner: -
  1506. --
  1507. ALTER TABLE ONLY received_transactions
  1508. ADD CONSTRAINT received_transactions_transaction_id_origin_key UNIQUE (transaction_id, origin);
  1509. --
  1510. -- Name: redactions redactions_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1511. --
  1512. ALTER TABLE ONLY redactions
  1513. ADD CONSTRAINT redactions_event_id_key UNIQUE (event_id);
  1514. --
  1515. -- Name: rejections rejections_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1516. --
  1517. ALTER TABLE ONLY rejections
  1518. ADD CONSTRAINT rejections_event_id_key UNIQUE (event_id);
  1519. --
  1520. -- Name: remote_media_cache remote_media_cache_media_origin_media_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1521. --
  1522. ALTER TABLE ONLY remote_media_cache
  1523. ADD CONSTRAINT remote_media_cache_media_origin_media_id_key UNIQUE (media_origin, media_id);
  1524. --
  1525. -- Name: remote_media_cache_thumbnails remote_media_cache_thumbnails_media_origin_media_id_thumbna_key; Type: CONSTRAINT; Schema: public; Owner: -
  1526. --
  1527. ALTER TABLE ONLY remote_media_cache_thumbnails
  1528. ADD CONSTRAINT remote_media_cache_thumbnails_media_origin_media_id_thumbna_key UNIQUE (media_origin, media_id, thumbnail_width, thumbnail_height, thumbnail_type);
  1529. --
  1530. -- Name: room_account_data room_account_data_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1531. --
  1532. ALTER TABLE ONLY room_account_data
  1533. ADD CONSTRAINT room_account_data_uniqueness UNIQUE (user_id, room_id, account_data_type);
  1534. --
  1535. -- Name: room_aliases room_aliases_room_alias_key; Type: CONSTRAINT; Schema: public; Owner: -
  1536. --
  1537. ALTER TABLE ONLY room_aliases
  1538. ADD CONSTRAINT room_aliases_room_alias_key UNIQUE (room_alias);
  1539. --
  1540. -- Name: room_depth room_depth_room_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1541. --
  1542. ALTER TABLE ONLY room_depth
  1543. ADD CONSTRAINT room_depth_room_id_key UNIQUE (room_id);
  1544. --
  1545. -- Name: room_hosts room_hosts_room_id_host_key; Type: CONSTRAINT; Schema: public; Owner: -
  1546. --
  1547. ALTER TABLE ONLY room_hosts
  1548. ADD CONSTRAINT room_hosts_room_id_host_key UNIQUE (room_id, host);
  1549. --
  1550. -- Name: room_memberships room_memberships_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1551. --
  1552. ALTER TABLE ONLY room_memberships
  1553. ADD CONSTRAINT room_memberships_event_id_key UNIQUE (event_id);
  1554. --
  1555. -- Name: room_names room_names_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1556. --
  1557. ALTER TABLE ONLY room_names
  1558. ADD CONSTRAINT room_names_event_id_key UNIQUE (event_id);
  1559. --
  1560. -- Name: room_tags_revisions room_tag_revisions_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1561. --
  1562. ALTER TABLE ONLY room_tags_revisions
  1563. ADD CONSTRAINT room_tag_revisions_uniqueness UNIQUE (user_id, room_id);
  1564. --
  1565. -- Name: room_tags room_tag_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1566. --
  1567. ALTER TABLE ONLY room_tags
  1568. ADD CONSTRAINT room_tag_uniqueness UNIQUE (user_id, room_id, tag);
  1569. --
  1570. -- Name: rooms rooms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1571. --
  1572. ALTER TABLE ONLY rooms
  1573. ADD CONSTRAINT rooms_pkey PRIMARY KEY (room_id);
  1574. --
  1575. -- Name: server_keys_json server_keys_json_uniqueness; Type: CONSTRAINT; Schema: public; Owner: -
  1576. --
  1577. ALTER TABLE ONLY server_keys_json
  1578. ADD CONSTRAINT server_keys_json_uniqueness UNIQUE (server_name, key_id, from_server);
  1579. --
  1580. -- Name: server_signature_keys server_signature_keys_server_name_key_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1581. --
  1582. ALTER TABLE ONLY server_signature_keys
  1583. ADD CONSTRAINT server_signature_keys_server_name_key_id_key UNIQUE (server_name, key_id);
  1584. --
  1585. -- Name: server_tls_certificates server_tls_certificates_server_name_fingerprint_key; Type: CONSTRAINT; Schema: public; Owner: -
  1586. --
  1587. ALTER TABLE ONLY server_tls_certificates
  1588. ADD CONSTRAINT server_tls_certificates_server_name_fingerprint_key UNIQUE (server_name, fingerprint);
  1589. --
  1590. -- Name: state_events state_events_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1591. --
  1592. ALTER TABLE ONLY state_events
  1593. ADD CONSTRAINT state_events_event_id_key UNIQUE (event_id);
  1594. --
  1595. -- Name: state_forward_extremities state_forward_extremities_event_id_room_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1596. --
  1597. ALTER TABLE ONLY state_forward_extremities
  1598. ADD CONSTRAINT state_forward_extremities_event_id_room_id_key UNIQUE (event_id, room_id);
  1599. --
  1600. -- Name: state_groups state_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
  1601. --
  1602. ALTER TABLE ONLY state_groups
  1603. ADD CONSTRAINT state_groups_pkey PRIMARY KEY (id);
  1604. --
  1605. -- Name: topics topics_event_id_key; Type: CONSTRAINT; Schema: public; Owner: -
  1606. --
  1607. ALTER TABLE ONLY topics
  1608. ADD CONSTRAINT topics_event_id_key UNIQUE (event_id);
  1609. --
  1610. -- Name: transaction_id_to_pdu transaction_id_to_pdu_transaction_id_destination_key; Type: CONSTRAINT; Schema: public; Owner: -
  1611. --
  1612. ALTER TABLE ONLY transaction_id_to_pdu
  1613. ADD CONSTRAINT transaction_id_to_pdu_transaction_id_destination_key UNIQUE (transaction_id, destination);
  1614. --
  1615. -- Name: user_directory_stream_pos user_directory_stream_pos_lock_key; Type: CONSTRAINT; Schema: public; Owner: -
  1616. --
  1617. ALTER TABLE ONLY user_directory_stream_pos
  1618. ADD CONSTRAINT user_directory_stream_pos_lock_key UNIQUE (lock);
  1619. --
  1620. -- Name: users users_name_key; Type: CONSTRAINT; Schema: public; Owner: -
  1621. --
  1622. ALTER TABLE ONLY users
  1623. ADD CONSTRAINT users_name_key UNIQUE (name);
  1624. --
  1625. -- Name: access_tokens_device_id; Type: INDEX; Schema: public; Owner: -
  1626. --
  1627. CREATE INDEX access_tokens_device_id ON access_tokens USING btree (user_id, device_id);
  1628. --
  1629. -- Name: account_data_stream_id; Type: INDEX; Schema: public; Owner: -
  1630. --
  1631. CREATE INDEX account_data_stream_id ON account_data USING btree (user_id, stream_id);
  1632. --
  1633. -- Name: application_services_txns_id; Type: INDEX; Schema: public; Owner: -
  1634. --
  1635. CREATE INDEX application_services_txns_id ON application_services_txns USING btree (as_id);
  1636. --
  1637. -- Name: appservice_room_list_idx; Type: INDEX; Schema: public; Owner: -
  1638. --
  1639. CREATE UNIQUE INDEX appservice_room_list_idx ON appservice_room_list USING btree (appservice_id, network_id, room_id);
  1640. --
  1641. -- Name: blocked_rooms_idx; Type: INDEX; Schema: public; Owner: -
  1642. --
  1643. CREATE UNIQUE INDEX blocked_rooms_idx ON blocked_rooms USING btree (room_id);
  1644. --
  1645. -- Name: cache_invalidation_stream_id; Type: INDEX; Schema: public; Owner: -
  1646. --
  1647. CREATE INDEX cache_invalidation_stream_id ON cache_invalidation_stream USING btree (stream_id);
  1648. --
  1649. -- Name: current_state_delta_stream_idx; Type: INDEX; Schema: public; Owner: -
  1650. --
  1651. CREATE INDEX current_state_delta_stream_idx ON current_state_delta_stream USING btree (stream_id);
  1652. --
  1653. -- Name: current_state_events_member_index; Type: INDEX; Schema: public; Owner: -
  1654. --
  1655. CREATE INDEX current_state_events_member_index ON current_state_events USING btree (state_key) WHERE (type = 'm.room.member'::text);
  1656. --
  1657. -- Name: deleted_pushers_stream_id; Type: INDEX; Schema: public; Owner: -
  1658. --
  1659. CREATE INDEX deleted_pushers_stream_id ON deleted_pushers USING btree (stream_id);
  1660. --
  1661. -- Name: device_federation_inbox_sender_id; Type: INDEX; Schema: public; Owner: -
  1662. --
  1663. CREATE INDEX device_federation_inbox_sender_id ON device_federation_inbox USING btree (origin, message_id);
  1664. --
  1665. -- Name: device_federation_outbox_destination_id; Type: INDEX; Schema: public; Owner: -
  1666. --
  1667. CREATE INDEX device_federation_outbox_destination_id ON device_federation_outbox USING btree (destination, stream_id);
  1668. --
  1669. -- Name: device_federation_outbox_id; Type: INDEX; Schema: public; Owner: -
  1670. --
  1671. CREATE INDEX device_federation_outbox_id ON device_federation_outbox USING btree (stream_id);
  1672. --
  1673. -- Name: device_inbox_stream_id_user_id; Type: INDEX; Schema: public; Owner: -
  1674. --
  1675. CREATE INDEX device_inbox_stream_id_user_id ON device_inbox USING btree (stream_id, user_id);
  1676. --
  1677. -- Name: device_inbox_user_stream_id; Type: INDEX; Schema: public; Owner: -
  1678. --
  1679. CREATE INDEX device_inbox_user_stream_id ON device_inbox USING btree (user_id, device_id, stream_id);
  1680. --
  1681. -- Name: device_lists_outbound_last_success_idx; Type: INDEX; Schema: public; Owner: -
  1682. --
  1683. CREATE INDEX device_lists_outbound_last_success_idx ON device_lists_outbound_last_success USING btree (destination, user_id, stream_id);
  1684. --
  1685. -- Name: device_lists_outbound_pokes_id; Type: INDEX; Schema: public; Owner: -
  1686. --
  1687. CREATE INDEX device_lists_outbound_pokes_id ON device_lists_outbound_pokes USING btree (destination, stream_id);
  1688. --
  1689. -- Name: device_lists_outbound_pokes_stream; Type: INDEX; Schema: public; Owner: -
  1690. --
  1691. CREATE INDEX device_lists_outbound_pokes_stream ON device_lists_outbound_pokes USING btree (stream_id);
  1692. --
  1693. -- Name: device_lists_outbound_pokes_user; Type: INDEX; Schema: public; Owner: -
  1694. --
  1695. CREATE INDEX device_lists_outbound_pokes_user ON device_lists_outbound_pokes USING btree (destination, user_id);
  1696. --
  1697. -- Name: device_lists_remote_cache_unique_id; Type: INDEX; Schema: public; Owner: -
  1698. --
  1699. CREATE UNIQUE INDEX device_lists_remote_cache_unique_id ON device_lists_remote_cache USING btree (user_id, device_id);
  1700. --
  1701. -- Name: device_lists_remote_extremeties_unique_idx; Type: INDEX; Schema: public; Owner: -
  1702. --
  1703. CREATE UNIQUE INDEX device_lists_remote_extremeties_unique_idx ON device_lists_remote_extremeties USING btree (user_id);
  1704. --
  1705. -- Name: device_lists_stream_id; Type: INDEX; Schema: public; Owner: -
  1706. --
  1707. CREATE INDEX device_lists_stream_id ON device_lists_stream USING btree (stream_id, user_id);
  1708. --
  1709. -- Name: device_lists_stream_user_id; Type: INDEX; Schema: public; Owner: -
  1710. --
  1711. CREATE INDEX device_lists_stream_user_id ON device_lists_stream USING btree (user_id, device_id);
  1712. --
  1713. -- Name: e2e_room_keys_idx; Type: INDEX; Schema: public; Owner: -
  1714. --
  1715. CREATE UNIQUE INDEX e2e_room_keys_idx ON e2e_room_keys USING btree (user_id, room_id, session_id);
  1716. --
  1717. -- Name: e2e_room_keys_versions_idx; Type: INDEX; Schema: public; Owner: -
  1718. --
  1719. CREATE UNIQUE INDEX e2e_room_keys_versions_idx ON e2e_room_keys_versions USING btree (user_id, version);
  1720. --
  1721. -- Name: erased_users_user; Type: INDEX; Schema: public; Owner: -
  1722. --
  1723. CREATE UNIQUE INDEX erased_users_user ON erased_users USING btree (user_id);
  1724. --
  1725. -- Name: ev_b_extrem_id; Type: INDEX; Schema: public; Owner: -
  1726. --
  1727. CREATE INDEX ev_b_extrem_id ON event_backward_extremities USING btree (event_id);
  1728. --
  1729. -- Name: ev_b_extrem_room; Type: INDEX; Schema: public; Owner: -
  1730. --
  1731. CREATE INDEX ev_b_extrem_room ON event_backward_extremities USING btree (room_id);
  1732. --
  1733. -- Name: ev_edges_id; Type: INDEX; Schema: public; Owner: -
  1734. --
  1735. CREATE INDEX ev_edges_id ON event_edges USING btree (event_id);
  1736. --
  1737. -- Name: ev_edges_prev_id; Type: INDEX; Schema: public; Owner: -
  1738. --
  1739. CREATE INDEX ev_edges_prev_id ON event_edges USING btree (prev_event_id);
  1740. --
  1741. -- Name: ev_extrem_id; Type: INDEX; Schema: public; Owner: -
  1742. --
  1743. CREATE INDEX ev_extrem_id ON event_forward_extremities USING btree (event_id);
  1744. --
  1745. -- Name: ev_extrem_room; Type: INDEX; Schema: public; Owner: -
  1746. --
  1747. CREATE INDEX ev_extrem_room ON event_forward_extremities USING btree (room_id);
  1748. --
  1749. -- Name: evauth_edges_id; Type: INDEX; Schema: public; Owner: -
  1750. --
  1751. CREATE INDEX evauth_edges_id ON event_auth USING btree (event_id);
  1752. --
  1753. -- Name: event_contains_url_index; Type: INDEX; Schema: public; Owner: -
  1754. --
  1755. CREATE INDEX event_contains_url_index ON events USING btree (room_id, topological_ordering, stream_ordering) WHERE ((contains_url = true) AND (outlier = false));
  1756. --
  1757. -- Name: event_json_room_id; Type: INDEX; Schema: public; Owner: -
  1758. --
  1759. CREATE INDEX event_json_room_id ON event_json USING btree (room_id);
  1760. --
  1761. -- Name: event_push_actions_highlights_index; Type: INDEX; Schema: public; Owner: -
  1762. --
  1763. CREATE INDEX event_push_actions_highlights_index ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering) WHERE (highlight = 1);
  1764. --
  1765. -- Name: event_push_actions_rm_tokens; Type: INDEX; Schema: public; Owner: -
  1766. --
  1767. CREATE INDEX event_push_actions_rm_tokens ON event_push_actions USING btree (user_id, room_id, topological_ordering, stream_ordering);
  1768. --
  1769. -- Name: event_push_actions_room_id_user_id; Type: INDEX; Schema: public; Owner: -
  1770. --
  1771. CREATE INDEX event_push_actions_room_id_user_id ON event_push_actions USING btree (room_id, user_id);
  1772. --
  1773. -- Name: event_push_actions_staging_id; Type: INDEX; Schema: public; Owner: -
  1774. --
  1775. CREATE INDEX event_push_actions_staging_id ON event_push_actions_staging USING btree (event_id);
  1776. --
  1777. -- Name: event_push_actions_stream_ordering; Type: INDEX; Schema: public; Owner: -
  1778. --
  1779. CREATE INDEX event_push_actions_stream_ordering ON event_push_actions USING btree (stream_ordering, user_id);
  1780. --
  1781. -- Name: event_push_actions_u_highlight; Type: INDEX; Schema: public; Owner: -
  1782. --
  1783. CREATE INDEX event_push_actions_u_highlight ON event_push_actions USING btree (user_id, stream_ordering);
  1784. --
  1785. -- Name: event_push_summary_user_rm; Type: INDEX; Schema: public; Owner: -
  1786. --
  1787. CREATE INDEX event_push_summary_user_rm ON event_push_summary USING btree (user_id, room_id);
  1788. --
  1789. -- Name: event_reference_hashes_id; Type: INDEX; Schema: public; Owner: -
  1790. --
  1791. CREATE INDEX event_reference_hashes_id ON event_reference_hashes USING btree (event_id);
  1792. --
  1793. -- Name: event_search_ev_ridx; Type: INDEX; Schema: public; Owner: -
  1794. --
  1795. CREATE INDEX event_search_ev_ridx ON event_search USING btree (room_id);
  1796. --
  1797. -- Name: event_search_event_id_idx; Type: INDEX; Schema: public; Owner: -
  1798. --
  1799. CREATE UNIQUE INDEX event_search_event_id_idx ON event_search USING btree (event_id);
  1800. --
  1801. -- Name: event_search_fts_idx; Type: INDEX; Schema: public; Owner: -
  1802. --
  1803. CREATE INDEX event_search_fts_idx ON event_search USING gin (vector);
  1804. --
  1805. -- Name: event_to_state_groups_sg_index; Type: INDEX; Schema: public; Owner: -
  1806. --
  1807. CREATE INDEX event_to_state_groups_sg_index ON event_to_state_groups USING btree (state_group);
  1808. --
  1809. -- Name: events_order_room; Type: INDEX; Schema: public; Owner: -
  1810. --
  1811. CREATE INDEX events_order_room ON events USING btree (room_id, topological_ordering, stream_ordering);
  1812. --
  1813. -- Name: events_room_stream; Type: INDEX; Schema: public; Owner: -
  1814. --
  1815. CREATE INDEX events_room_stream ON events USING btree (room_id, stream_ordering);
  1816. --
  1817. -- Name: events_ts; Type: INDEX; Schema: public; Owner: -
  1818. --
  1819. CREATE INDEX events_ts ON events USING btree (origin_server_ts, stream_ordering);
  1820. --
  1821. -- Name: group_attestations_remote_g_idx; Type: INDEX; Schema: public; Owner: -
  1822. --
  1823. CREATE INDEX group_attestations_remote_g_idx ON group_attestations_remote USING btree (group_id, user_id);
  1824. --
  1825. -- Name: group_attestations_remote_u_idx; Type: INDEX; Schema: public; Owner: -
  1826. --
  1827. CREATE INDEX group_attestations_remote_u_idx ON group_attestations_remote USING btree (user_id);
  1828. --
  1829. -- Name: group_attestations_remote_v_idx; Type: INDEX; Schema: public; Owner: -
  1830. --
  1831. CREATE INDEX group_attestations_remote_v_idx ON group_attestations_remote USING btree (valid_until_ms);
  1832. --
  1833. -- Name: group_attestations_renewals_g_idx; Type: INDEX; Schema: public; Owner: -
  1834. --
  1835. CREATE INDEX group_attestations_renewals_g_idx ON group_attestations_renewals USING btree (group_id, user_id);
  1836. --
  1837. -- Name: group_attestations_renewals_u_idx; Type: INDEX; Schema: public; Owner: -
  1838. --
  1839. CREATE INDEX group_attestations_renewals_u_idx ON group_attestations_renewals USING btree (user_id);
  1840. --
  1841. -- Name: group_attestations_renewals_v_idx; Type: INDEX; Schema: public; Owner: -
  1842. --
  1843. CREATE INDEX group_attestations_renewals_v_idx ON group_attestations_renewals USING btree (valid_until_ms);
  1844. --
  1845. -- Name: group_invites_g_idx; Type: INDEX; Schema: public; Owner: -
  1846. --
  1847. CREATE UNIQUE INDEX group_invites_g_idx ON group_invites USING btree (group_id, user_id);
  1848. --
  1849. -- Name: group_invites_u_idx; Type: INDEX; Schema: public; Owner: -
  1850. --
  1851. CREATE INDEX group_invites_u_idx ON group_invites USING btree (user_id);
  1852. --
  1853. -- Name: group_rooms_g_idx; Type: INDEX; Schema: public; Owner: -
  1854. --
  1855. CREATE UNIQUE INDEX group_rooms_g_idx ON group_rooms USING btree (group_id, room_id);
  1856. --
  1857. -- Name: group_rooms_r_idx; Type: INDEX; Schema: public; Owner: -
  1858. --
  1859. CREATE INDEX group_rooms_r_idx ON group_rooms USING btree (room_id);
  1860. --
  1861. -- Name: group_summary_rooms_g_idx; Type: INDEX; Schema: public; Owner: -
  1862. --
  1863. CREATE UNIQUE INDEX group_summary_rooms_g_idx ON group_summary_rooms USING btree (group_id, room_id, category_id);
  1864. --
  1865. -- Name: group_summary_users_g_idx; Type: INDEX; Schema: public; Owner: -
  1866. --
  1867. CREATE INDEX group_summary_users_g_idx ON group_summary_users USING btree (group_id);
  1868. --
  1869. -- Name: group_users_g_idx; Type: INDEX; Schema: public; Owner: -
  1870. --
  1871. CREATE UNIQUE INDEX group_users_g_idx ON group_users USING btree (group_id, user_id);
  1872. --
  1873. -- Name: group_users_u_idx; Type: INDEX; Schema: public; Owner: -
  1874. --
  1875. CREATE INDEX group_users_u_idx ON group_users USING btree (user_id);
  1876. --
  1877. -- Name: groups_idx; Type: INDEX; Schema: public; Owner: -
  1878. --
  1879. CREATE UNIQUE INDEX groups_idx ON groups USING btree (group_id);
  1880. --
  1881. -- Name: local_group_membership_g_idx; Type: INDEX; Schema: public; Owner: -
  1882. --
  1883. CREATE INDEX local_group_membership_g_idx ON local_group_membership USING btree (group_id);
  1884. --
  1885. -- Name: local_group_membership_u_idx; Type: INDEX; Schema: public; Owner: -
  1886. --
  1887. CREATE INDEX local_group_membership_u_idx ON local_group_membership USING btree (user_id, group_id);
  1888. --
  1889. -- Name: local_invites_for_user_idx; Type: INDEX; Schema: public; Owner: -
  1890. --
  1891. CREATE INDEX local_invites_for_user_idx ON local_invites USING btree (invitee, locally_rejected, replaced_by, room_id);
  1892. --
  1893. -- Name: local_invites_id; Type: INDEX; Schema: public; Owner: -
  1894. --
  1895. CREATE INDEX local_invites_id ON local_invites USING btree (stream_id);
  1896. --
  1897. -- Name: local_media_repository_thumbnails_media_id; Type: INDEX; Schema: public; Owner: -
  1898. --
  1899. CREATE INDEX local_media_repository_thumbnails_media_id ON local_media_repository_thumbnails USING btree (media_id);
  1900. --
  1901. -- Name: local_media_repository_url_cache_by_url_download_ts; Type: INDEX; Schema: public; Owner: -
  1902. --
  1903. CREATE INDEX local_media_repository_url_cache_by_url_download_ts ON local_media_repository_url_cache USING btree (url, download_ts);
  1904. --
  1905. -- Name: local_media_repository_url_cache_expires_idx; Type: INDEX; Schema: public; Owner: -
  1906. --
  1907. CREATE INDEX local_media_repository_url_cache_expires_idx ON local_media_repository_url_cache USING btree (expires_ts);
  1908. --
  1909. -- Name: local_media_repository_url_cache_media_idx; Type: INDEX; Schema: public; Owner: -
  1910. --
  1911. CREATE INDEX local_media_repository_url_cache_media_idx ON local_media_repository_url_cache USING btree (media_id);
  1912. --
  1913. -- Name: local_media_repository_url_idx; Type: INDEX; Schema: public; Owner: -
  1914. --
  1915. CREATE INDEX local_media_repository_url_idx ON local_media_repository USING btree (created_ts) WHERE (url_cache IS NOT NULL);
  1916. --
  1917. -- Name: monthly_active_users_time_stamp; Type: INDEX; Schema: public; Owner: -
  1918. --
  1919. CREATE INDEX monthly_active_users_time_stamp ON monthly_active_users USING btree ("timestamp");
  1920. --
  1921. -- Name: monthly_active_users_users; Type: INDEX; Schema: public; Owner: -
  1922. --
  1923. CREATE UNIQUE INDEX monthly_active_users_users ON monthly_active_users USING btree (user_id);
  1924. --
  1925. -- Name: open_id_tokens_ts_valid_until_ms; Type: INDEX; Schema: public; Owner: -
  1926. --
  1927. CREATE INDEX open_id_tokens_ts_valid_until_ms ON open_id_tokens USING btree (ts_valid_until_ms);
  1928. --
  1929. -- Name: presence_list_user_id; Type: INDEX; Schema: public; Owner: -
  1930. --
  1931. CREATE INDEX presence_list_user_id ON presence_list USING btree (user_id);
  1932. --
  1933. -- Name: presence_stream_id; Type: INDEX; Schema: public; Owner: -
  1934. --
  1935. CREATE INDEX presence_stream_id ON presence_stream USING btree (stream_id, user_id);
  1936. --
  1937. -- Name: presence_stream_user_id; Type: INDEX; Schema: public; Owner: -
  1938. --
  1939. CREATE INDEX presence_stream_user_id ON presence_stream USING btree (user_id);
  1940. --
  1941. -- Name: public_room_index; Type: INDEX; Schema: public; Owner: -
  1942. --
  1943. CREATE INDEX public_room_index ON rooms USING btree (is_public);
  1944. --
  1945. -- Name: public_room_list_stream_idx; Type: INDEX; Schema: public; Owner: -
  1946. --
  1947. CREATE INDEX public_room_list_stream_idx ON public_room_list_stream USING btree (stream_id);
  1948. --
  1949. -- Name: public_room_list_stream_rm_idx; Type: INDEX; Schema: public; Owner: -
  1950. --
  1951. CREATE INDEX public_room_list_stream_rm_idx ON public_room_list_stream USING btree (room_id, stream_id);
  1952. --
  1953. -- Name: push_rules_enable_user_name; Type: INDEX; Schema: public; Owner: -
  1954. --
  1955. CREATE INDEX push_rules_enable_user_name ON push_rules_enable USING btree (user_name);
  1956. --
  1957. -- Name: push_rules_stream_id; Type: INDEX; Schema: public; Owner: -
  1958. --
  1959. CREATE INDEX push_rules_stream_id ON push_rules_stream USING btree (stream_id);
  1960. --
  1961. -- Name: push_rules_stream_user_stream_id; Type: INDEX; Schema: public; Owner: -
  1962. --
  1963. CREATE INDEX push_rules_stream_user_stream_id ON push_rules_stream USING btree (user_id, stream_id);
  1964. --
  1965. -- Name: push_rules_user_name; Type: INDEX; Schema: public; Owner: -
  1966. --
  1967. CREATE INDEX push_rules_user_name ON push_rules USING btree (user_name);
  1968. --
  1969. -- Name: ratelimit_override_idx; Type: INDEX; Schema: public; Owner: -
  1970. --
  1971. CREATE UNIQUE INDEX ratelimit_override_idx ON ratelimit_override USING btree (user_id);
  1972. --
  1973. -- Name: receipts_linearized_id; Type: INDEX; Schema: public; Owner: -
  1974. --
  1975. CREATE INDEX receipts_linearized_id ON receipts_linearized USING btree (stream_id);
  1976. --
  1977. -- Name: receipts_linearized_room_stream; Type: INDEX; Schema: public; Owner: -
  1978. --
  1979. CREATE INDEX receipts_linearized_room_stream ON receipts_linearized USING btree (room_id, stream_id);
  1980. --
  1981. -- Name: receipts_linearized_user; Type: INDEX; Schema: public; Owner: -
  1982. --
  1983. CREATE INDEX receipts_linearized_user ON receipts_linearized USING btree (user_id);
  1984. --
  1985. -- Name: received_transactions_ts; Type: INDEX; Schema: public; Owner: -
  1986. --
  1987. CREATE INDEX received_transactions_ts ON received_transactions USING btree (ts);
  1988. --
  1989. -- Name: redactions_redacts; Type: INDEX; Schema: public; Owner: -
  1990. --
  1991. CREATE INDEX redactions_redacts ON redactions USING btree (redacts);
  1992. --
  1993. -- Name: remote_profile_cache_time; Type: INDEX; Schema: public; Owner: -
  1994. --
  1995. CREATE INDEX remote_profile_cache_time ON remote_profile_cache USING btree (last_check);
  1996. --
  1997. -- Name: remote_profile_cache_user_id; Type: INDEX; Schema: public; Owner: -
  1998. --
  1999. CREATE UNIQUE INDEX remote_profile_cache_user_id ON remote_profile_cache USING btree (user_id);
  2000. --
  2001. -- Name: room_account_data_stream_id; Type: INDEX; Schema: public; Owner: -
  2002. --
  2003. CREATE INDEX room_account_data_stream_id ON room_account_data USING btree (user_id, stream_id);
  2004. --
  2005. -- Name: room_alias_servers_alias; Type: INDEX; Schema: public; Owner: -
  2006. --
  2007. CREATE INDEX room_alias_servers_alias ON room_alias_servers USING btree (room_alias);
  2008. --
  2009. -- Name: room_aliases_id; Type: INDEX; Schema: public; Owner: -
  2010. --
  2011. CREATE INDEX room_aliases_id ON room_aliases USING btree (room_id);
  2012. --
  2013. -- Name: room_depth_room; Type: INDEX; Schema: public; Owner: -
  2014. --
  2015. CREATE INDEX room_depth_room ON room_depth USING btree (room_id);
  2016. --
  2017. -- Name: room_memberships_room_id; Type: INDEX; Schema: public; Owner: -
  2018. --
  2019. CREATE INDEX room_memberships_room_id ON room_memberships USING btree (room_id);
  2020. --
  2021. -- Name: room_memberships_user_id; Type: INDEX; Schema: public; Owner: -
  2022. --
  2023. CREATE INDEX room_memberships_user_id ON room_memberships USING btree (user_id);
  2024. --
  2025. -- Name: room_names_room_id; Type: INDEX; Schema: public; Owner: -
  2026. --
  2027. CREATE INDEX room_names_room_id ON room_names USING btree (room_id);
  2028. --
  2029. -- Name: st_extrem_keys; Type: INDEX; Schema: public; Owner: -
  2030. --
  2031. CREATE INDEX st_extrem_keys ON state_forward_extremities USING btree (room_id, type, state_key);
  2032. --
  2033. -- Name: state_group_edges_idx; Type: INDEX; Schema: public; Owner: -
  2034. --
  2035. CREATE INDEX state_group_edges_idx ON state_group_edges USING btree (state_group);
  2036. --
  2037. -- Name: state_group_edges_prev_idx; Type: INDEX; Schema: public; Owner: -
  2038. --
  2039. CREATE INDEX state_group_edges_prev_idx ON state_group_edges USING btree (prev_state_group);
  2040. --
  2041. -- Name: state_groups_state_type_idx; Type: INDEX; Schema: public; Owner: -
  2042. --
  2043. CREATE INDEX state_groups_state_type_idx ON state_groups_state USING btree (state_group, type, state_key);
  2044. --
  2045. -- Name: stream_ordering_to_exterm_idx; Type: INDEX; Schema: public; Owner: -
  2046. --
  2047. CREATE INDEX stream_ordering_to_exterm_idx ON stream_ordering_to_exterm USING btree (stream_ordering);
  2048. --
  2049. -- Name: stream_ordering_to_exterm_rm_idx; Type: INDEX; Schema: public; Owner: -
  2050. --
  2051. CREATE INDEX stream_ordering_to_exterm_rm_idx ON stream_ordering_to_exterm USING btree (room_id, stream_ordering);
  2052. --
  2053. -- Name: threepid_guest_access_tokens_index; Type: INDEX; Schema: public; Owner: -
  2054. --
  2055. CREATE UNIQUE INDEX threepid_guest_access_tokens_index ON threepid_guest_access_tokens USING btree (medium, address);
  2056. --
  2057. -- Name: topics_room_id; Type: INDEX; Schema: public; Owner: -
  2058. --
  2059. CREATE INDEX topics_room_id ON topics USING btree (room_id);
  2060. --
  2061. -- Name: transaction_id_to_pdu_dest; Type: INDEX; Schema: public; Owner: -
  2062. --
  2063. CREATE INDEX transaction_id_to_pdu_dest ON transaction_id_to_pdu USING btree (destination);
  2064. --
  2065. -- Name: user_daily_visits_ts_idx; Type: INDEX; Schema: public; Owner: -
  2066. --
  2067. CREATE INDEX user_daily_visits_ts_idx ON user_daily_visits USING btree ("timestamp");
  2068. --
  2069. -- Name: user_daily_visits_uts_idx; Type: INDEX; Schema: public; Owner: -
  2070. --
  2071. CREATE INDEX user_daily_visits_uts_idx ON user_daily_visits USING btree (user_id, "timestamp");
  2072. --
  2073. -- Name: user_directory_room_idx; Type: INDEX; Schema: public; Owner: -
  2074. --
  2075. CREATE INDEX user_directory_room_idx ON user_directory USING btree (room_id);
  2076. --
  2077. -- Name: user_directory_search_fts_idx; Type: INDEX; Schema: public; Owner: -
  2078. --
  2079. CREATE INDEX user_directory_search_fts_idx ON user_directory_search USING gin (vector);
  2080. --
  2081. -- Name: user_directory_search_user_idx; Type: INDEX; Schema: public; Owner: -
  2082. --
  2083. CREATE UNIQUE INDEX user_directory_search_user_idx ON user_directory_search USING btree (user_id);
  2084. --
  2085. -- Name: user_directory_user_idx; Type: INDEX; Schema: public; Owner: -
  2086. --
  2087. CREATE UNIQUE INDEX user_directory_user_idx ON user_directory USING btree (user_id);
  2088. --
  2089. -- Name: user_filters_by_user_id_filter_id; Type: INDEX; Schema: public; Owner: -
  2090. --
  2091. CREATE INDEX user_filters_by_user_id_filter_id ON user_filters USING btree (user_id, filter_id);
  2092. --
  2093. -- Name: user_ips_device_id; Type: INDEX; Schema: public; Owner: -
  2094. --
  2095. CREATE INDEX user_ips_device_id ON user_ips USING btree (user_id, device_id, last_seen);
  2096. --
  2097. -- Name: user_ips_device_unique_id; Type: INDEX; Schema: public; Owner: -
  2098. --
  2099. CREATE UNIQUE INDEX user_ips_device_unique_id ON user_ips USING btree (user_id, access_token, ip, user_agent, device_id);
  2100. --
  2101. -- Name: user_ips_last_seen; Type: INDEX; Schema: public; Owner: -
  2102. --
  2103. CREATE INDEX user_ips_last_seen ON user_ips USING btree (user_id, last_seen);
  2104. --
  2105. -- Name: user_ips_last_seen_only; Type: INDEX; Schema: public; Owner: -
  2106. --
  2107. CREATE INDEX user_ips_last_seen_only ON user_ips USING btree (last_seen);
  2108. --
  2109. -- Name: user_ips_user_ip; Type: INDEX; Schema: public; Owner: -
  2110. --
  2111. CREATE INDEX user_ips_user_ip ON user_ips USING btree (user_id, access_token, ip);
  2112. --
  2113. -- Name: user_threepids_medium_address; Type: INDEX; Schema: public; Owner: -
  2114. --
  2115. CREATE INDEX user_threepids_medium_address ON user_threepids USING btree (medium, address);
  2116. --
  2117. -- Name: user_threepids_user_id; Type: INDEX; Schema: public; Owner: -
  2118. --
  2119. CREATE INDEX user_threepids_user_id ON user_threepids USING btree (user_id);
  2120. --
  2121. -- Name: users_creation_ts; Type: INDEX; Schema: public; Owner: -
  2122. --
  2123. CREATE INDEX users_creation_ts ON users USING btree (creation_ts);
  2124. --
  2125. -- Name: users_in_public_rooms_room_idx; Type: INDEX; Schema: public; Owner: -
  2126. --
  2127. CREATE INDEX users_in_public_rooms_room_idx ON users_in_public_rooms USING btree (room_id);
  2128. --
  2129. -- Name: users_in_public_rooms_user_idx; Type: INDEX; Schema: public; Owner: -
  2130. --
  2131. CREATE UNIQUE INDEX users_in_public_rooms_user_idx ON users_in_public_rooms USING btree (user_id);
  2132. --
  2133. -- Name: users_who_share_rooms_o_idx; Type: INDEX; Schema: public; Owner: -
  2134. --
  2135. CREATE INDEX users_who_share_rooms_o_idx ON users_who_share_rooms USING btree (other_user_id);
  2136. --
  2137. -- Name: users_who_share_rooms_r_idx; Type: INDEX; Schema: public; Owner: -
  2138. --
  2139. CREATE INDEX users_who_share_rooms_r_idx ON users_who_share_rooms USING btree (room_id);
  2140. --
  2141. -- Name: users_who_share_rooms_u_idx; Type: INDEX; Schema: public; Owner: -
  2142. --
  2143. CREATE UNIQUE INDEX users_who_share_rooms_u_idx ON users_who_share_rooms USING btree (user_id, other_user_id);
  2144. --
  2145. -- Name: application_services_regex application_services_regex_as_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  2146. --
  2147. ALTER TABLE ONLY application_services_regex
  2148. ADD CONSTRAINT application_services_regex_as_id_fkey FOREIGN KEY (as_id) REFERENCES application_services(id);
  2149. --
  2150. -- PostgreSQL database dump complete
  2151. --