diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-10-17 17:31:48 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-10-17 17:31:48 +0100 |
commit | 82c582076782f180c9f69a523953c3a36b57b3ac (patch) | |
tree | 00a79bdfe56a139cbe427ecc28bad852bdc3663d /synapse | |
parent | SPEC-7: Rename 'ts' to 'origin_server_ts' (diff) | |
download | synapse-82c582076782f180c9f69a523953c3a36b57b3ac.tar.xz |
keep 'origin_server_ts' as 'ts' in the database to avoid needlessly updating schema
Diffstat (limited to '')
-rw-r--r-- | synapse/federation/units.py | 1 | ||||
-rw-r--r-- | synapse/storage/__init__.py | 2 | ||||
-rw-r--r-- | synapse/storage/_base.py | 3 | ||||
-rw-r--r-- | synapse/storage/pdu.py | 2 | ||||
-rw-r--r-- | synapse/storage/schema/pdu.sql | 2 | ||||
-rw-r--r-- | synapse/storage/schema/transactions.sql | 4 | ||||
-rw-r--r-- | synapse/storage/transactions.py | 13 |
7 files changed, 16 insertions, 11 deletions
diff --git a/synapse/federation/units.py b/synapse/federation/units.py index dccac2aca7..b2fb964180 100644 --- a/synapse/federation/units.py +++ b/synapse/federation/units.py @@ -118,6 +118,7 @@ class Pdu(JsonEncodedObject): """ if pdu_tuple: d = copy.copy(pdu_tuple.pdu_entry._asdict()) + d["origin_server_ts"] = d.pop("ts") d["content"] = json.loads(d["content_json"]) del d["content_json"] diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index 6dadeb8cce..c8e0efb18f 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -155,6 +155,8 @@ class DataStore(RoomMemberStore, RoomStore, cols["unrecognized_keys"] = json.dumps(unrec_keys) + cols["ts"] = cols.pop("origin_server_ts") + logger.debug("Persisting: %s", repr(cols)) if pdu.is_state: diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index 30c5103cdd..65a86e9056 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -354,6 +354,7 @@ class SQLBaseStore(object): d.pop("stream_ordering", None) d.pop("topological_ordering", None) d.pop("processed", None) + d["origin_server_ts"] = d.pop("ts", 0) d.update(json.loads(row_dict["unrecognized_keys"])) d["content"] = json.loads(d["content"]) @@ -361,7 +362,7 @@ class SQLBaseStore(object): if "age_ts" not in d: # For compatibility - d["age_ts"] = d["origin_server_ts"] if "origin_server_ts" in d else 0 + d["age_ts"] = d.get("origin_server_ts", 0) return self.event_factory.create_event( etype=d["type"], diff --git a/synapse/storage/pdu.py b/synapse/storage/pdu.py index 61ea979b8a..d70467dcd6 100644 --- a/synapse/storage/pdu.py +++ b/synapse/storage/pdu.py @@ -789,7 +789,7 @@ class PdusTable(Table): "origin", "context", "pdu_type", - "origin_server_ts", + "ts", "depth", "is_state", "content_json", diff --git a/synapse/storage/schema/pdu.sql b/synapse/storage/schema/pdu.sql index 5cc8669912..16e111a56c 100644 --- a/synapse/storage/schema/pdu.sql +++ b/synapse/storage/schema/pdu.sql @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS pdus( origin TEXT, context TEXT, pdu_type TEXT, - origin_server_ts INTEGER, + ts INTEGER, depth INTEGER DEFAULT 0 NOT NULL, is_state BOOL, content_json TEXT, diff --git a/synapse/storage/schema/transactions.sql b/synapse/storage/schema/transactions.sql index 5f8d01327a..88e3e4e04d 100644 --- a/synapse/storage/schema/transactions.sql +++ b/synapse/storage/schema/transactions.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS received_transactions( transaction_id TEXT, origin TEXT, - origin_server_ts INTEGER, + ts INTEGER, response_code INTEGER, response_json TEXT, has_been_referenced BOOL default 0, -- Whether thishas been referenced by a prev_tx @@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS sent_transactions( destination TEXT, response_code INTEGER DEFAULT 0, response_json TEXT, - origin_server_ts INTEGER + ts INTEGER ); CREATE INDEX IF NOT EXISTS sent_transaction_dest ON sent_transactions(destination); diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py index a9fa959d49..2ba8e30efe 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py @@ -87,7 +87,8 @@ class TransactionStore(SQLBaseStore): txn.execute(query, (code, response_json, transaction_id, origin)) - def prep_send_transaction(self, transaction_id, destination, origin_server_ts, pdu_list): + def prep_send_transaction(self, transaction_id, destination, + origin_server_ts, pdu_list): """Persists an outgoing transaction and calculates the values for the previous transaction id list. @@ -109,8 +110,8 @@ class TransactionStore(SQLBaseStore): transaction_id, destination, origin_server_ts, pdu_list ) - def _prep_send_transaction(self, txn, transaction_id, destination, origin_server_ts, - pdu_list): + def _prep_send_transaction(self, txn, transaction_id, destination, + origin_server_ts, pdu_list): # First we find out what the prev_txs should be. # Since we know that we are only sending one transaction at a time, @@ -131,7 +132,7 @@ class TransactionStore(SQLBaseStore): None, transaction_id=transaction_id, destination=destination, - origin_server_ts=origin_server_ts, + ts=origin_server_ts, response_code=0, response_json=None )) @@ -251,7 +252,7 @@ class ReceivedTransactionsTable(Table): fields = [ "transaction_id", "origin", - "origin_server_ts", + "ts", "response_code", "response_json", "has_been_referenced", @@ -267,7 +268,7 @@ class SentTransactions(Table): "id", "transaction_id", "destination", - "origin_server_ts", + "ts", "response_code", "response_json", ] |