41-historysync-store.sql 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. -- v41: Store history syncs for later backfills
  2. CREATE TABLE history_sync_conversation (
  3. user_mxid TEXT,
  4. conversation_id TEXT,
  5. portal_jid TEXT,
  6. portal_receiver TEXT,
  7. last_message_timestamp TIMESTAMP,
  8. archived BOOLEAN,
  9. pinned INTEGER,
  10. mute_end_time TIMESTAMP,
  11. disappearing_mode INTEGER,
  12. end_of_history_transfer_type INTEGER,
  13. ephemeral_expiration INTEGER,
  14. marked_as_unread BOOLEAN,
  15. unread_count INTEGER,
  16. PRIMARY KEY (user_mxid, conversation_id),
  17. FOREIGN KEY (user_mxid) REFERENCES "user" (mxid) ON DELETE CASCADE ON UPDATE CASCADE,
  18. FOREIGN KEY (portal_jid, portal_receiver) REFERENCES portal (jid, receiver) ON DELETE CASCADE ON UPDATE CASCADE
  19. );
  20. CREATE TABLE history_sync_message (
  21. user_mxid TEXT,
  22. conversation_id TEXT,
  23. message_id TEXT,
  24. timestamp TIMESTAMP,
  25. data BYTEA,
  26. PRIMARY KEY (user_mxid, conversation_id, message_id),
  27. FOREIGN KEY (user_mxid) REFERENCES "user" (mxid) ON DELETE CASCADE ON UPDATE CASCADE,
  28. FOREIGN KEY (user_mxid, conversation_id) REFERENCES history_sync_conversation (user_mxid, conversation_id) ON DELETE CASCADE
  29. );