diff options
author | Erik Johnston <erik@matrix.org> | 2015-03-19 15:59:48 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-03-19 15:59:48 +0000 |
commit | d7a0496f3ec534076121632352f44733253e1e16 (patch) | |
tree | bc981c1de8f70c9b79b26c97a3cedc11567e5255 /synapse/storage/state.py | |
parent | Remove redundant key (diff) | |
download | synapse-d7a0496f3ec534076121632352f44733253e1e16.tar.xz |
Convert storage layer to be mysql compatible
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r-- | synapse/storage/state.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 456e4bd45d..888837cd1e 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -15,6 +15,8 @@ from ._base import SQLBaseStore +from synapse.util.stringutils import random_string + import logging logger = logging.getLogger(__name__) @@ -89,14 +91,15 @@ class StateStore(SQLBaseStore): state_group = context.state_group if not state_group: + group = _make_group_id(self._clock) state_group = self._simple_insert_txn( txn, table="state_groups", values={ + "id": group, "room_id": event.room_id, "event_id": event.event_id, }, - or_ignore=True, ) for state in state_events.values(): @@ -110,7 +113,6 @@ class StateStore(SQLBaseStore): "state_key": state.state_key, "event_id": state.event_id, }, - or_ignore=True, ) self._simple_insert_txn( @@ -122,3 +124,7 @@ class StateStore(SQLBaseStore): }, or_replace=True, ) + + +def _make_group_id(clock): + return str(int(clock.time_msec())) + random_string(5) |