Skip to content
Snippets Groups Projects
Commit 9236136f authored by Erik Johnston's avatar Erik Johnston
Browse files

Make work in both Maria and SQLite. Fix tests

parent 0e8f5095
No related branches found
No related tags found
No related merge requests found
Showing
with 196 additions and 85 deletions
......@@ -20,6 +20,7 @@ sys.dont_write_bytecode = True
from synapse.storage import (
prepare_database, prepare_sqlite3_database, UpgradeDatabaseException,
)
from synapse.storage.engines import create_engine
from synapse.server import HomeServer
......@@ -376,7 +377,7 @@ def setup(config_options):
if name in ["MySQLdb", "mysql.connector"]:
db_config.setdefault("args", {}).update({
"sql_mode": "TRADITIONAL",
"charset": "utf8",
"charset": "utf8mb4",
"use_unicode": True,
})
elif name == "sqlite3":
......@@ -388,6 +389,8 @@ def setup(config_options):
else:
raise RuntimeError("Unsupported database type '%s'" % (name,))
database_engine = create_engine(name)
hs = SynapseHomeServer(
config.server_name,
domain_with_port=domain_with_port,
......@@ -398,6 +401,7 @@ def setup(config_options):
config=config,
content_addr=config.content_addr,
version_string=version_string,
database_engine=database_engine,
)
hs.create_resource_tree(
......@@ -409,12 +413,14 @@ def setup(config_options):
logger.info("Preparing database: %s...", db_name)
try:
# with sqlite3.connect(db_name) as db_conn:
# prepare_sqlite3_database(db_conn)
# prepare_database(db_conn)
import mysql.connector
db_conn = mysql.connector.connect(**db_config.get("args", {}))
prepare_database(db_conn)
db_conn = database_engine.module.connect(**db_config.get("args", {}))
if name == "sqlite3":
prepare_sqlite3_database(db_conn)
prepare_database(db_conn, database_engine)
db_conn.commit()
except UpgradeDatabaseException:
sys.stderr.write(
"\nFailed to upgrade database.\n"
......
......@@ -77,9 +77,6 @@ class DataStore(RoomMemberStore, RoomStore,
self.min_token_deferred = self._get_min_token()
self.min_token = None
self._next_stream_id_lock = threading.Lock()
self._next_stream_id = int(hs.get_clock().time_msec()) * 1000
def insert_client_ip(self, user, access_token, device_id, ip, user_agent):
return self._simple_upsert(
"user_ips",
......@@ -127,19 +124,21 @@ class UpgradeDatabaseException(PrepareDatabaseException):
pass
def prepare_database(db_conn):
def prepare_database(db_conn, database_engine):
"""Prepares a database for usage. Will either create all necessary tables
or upgrade from an older schema version.
"""
try:
cur = db_conn.cursor()
version_info = _get_or_create_schema_state(cur)
version_info = _get_or_create_schema_state(cur, database_engine)
if version_info:
user_version, delta_files, upgraded = version_info
_upgrade_existing_database(cur, user_version, delta_files, upgraded)
_upgrade_existing_database(
cur, user_version, delta_files, upgraded, database_engine
)
else:
_setup_new_database(cur)
_setup_new_database(cur, database_engine)
# cur.execute("PRAGMA user_version = %d" % (SCHEMA_VERSION,))
......@@ -150,7 +149,7 @@ def prepare_database(db_conn):
raise
def _setup_new_database(cur):
def _setup_new_database(cur, database_engine):
"""Sets up the database by finding a base set of "full schemas" and then
applying any necessary deltas.
......@@ -210,7 +209,7 @@ def _setup_new_database(cur):
executescript(cur, sql_loc)
cur.execute(
_convert_param_style(
database_engine.convert_param_style(
"REPLACE INTO schema_version (version, upgraded)"
" VALUES (?,?)"
),
......@@ -221,12 +220,13 @@ def _setup_new_database(cur):
cur,
current_version=max_current_ver,
applied_delta_files=[],
upgraded=False
upgraded=False,
database_engine=database_engine,
)
def _upgrade_existing_database(cur, current_version, applied_delta_files,
upgraded):
upgraded, database_engine):
"""Upgrades an existing database.
Delta files can either be SQL stored in *.sql files, or python modules
......@@ -335,26 +335,22 @@ def _upgrade_existing_database(cur, current_version, applied_delta_files,
# Mark as done.
cur.execute(
_convert_param_style(
database_engine.convert_param_style(
"INSERT INTO applied_schema_deltas (version, file)"
" VALUES (?,?)"
" VALUES (?,?)",
),
(v, relative_path)
)
cur.execute(
_convert_param_style(
database_engine.convert_param_style(
"REPLACE INTO schema_version (version, upgraded)"
" VALUES (?,?)"
" VALUES (?,?)",
),
(v, True)
)
def _convert_param_style(sql):
return sql.replace("?", "%s")
def get_statements(f):
statement_buffer = ""
in_comment = False # If we're in a /* ... */ style comment
......@@ -409,7 +405,7 @@ def executescript(txn, schema_path):
txn.execute(statement)
def _get_or_create_schema_state(txn):
def _get_or_create_schema_state(txn, database_engine):
try:
# Bluntly try creating the schema_version tables.
schema_path = os.path.join(
......@@ -426,7 +422,7 @@ def _get_or_create_schema_state(txn):
if current_version:
txn.execute(
_convert_param_style(
database_engine.convert_param_style(
"SELECT file FROM applied_schema_deltas WHERE version >= ?"
),
(current_version,)
......@@ -446,6 +442,8 @@ def prepare_sqlite3_database(db_conn):
new. This only affects sqlite databases since they were the only ones
supported at the time.
"""
import sqlite3
with db_conn:
schema_path = os.path.join(
dir_path, "schema", "schema_version.sql",
......@@ -466,7 +464,8 @@ def prepare_sqlite3_database(db_conn):
db_conn.execute(
_convert_param_style(
"REPLACE INTO schema_version (version, upgraded)"
" VALUES (?,?)"
" VALUES (?,?)",
sqlite3
),
(row[0], False)
)
......@@ -29,6 +29,7 @@ import functools
import simplejson as json
import sys
import time
import threading
logger = logging.getLogger(__name__)
......@@ -118,19 +119,16 @@ def cached(max_entries=1000, num_args=1):
return wrap
def _convert_param_style(sql):
return sql.replace("?", "%s")
class LoggingTransaction(object):
"""An object that almost-transparently proxies for the 'txn' object
passed to the constructor. Adds logging and metrics to the .execute()
method."""
__slots__ = ["txn", "name"]
__slots__ = ["txn", "name", "database_engine"]
def __init__(self, txn, name):
def __init__(self, txn, name, database_engine):
object.__setattr__(self, "txn", txn)
object.__setattr__(self, "name", name)
object.__setattr__(self, "database_engine", database_engine)
def __getattr__(self, name):
return getattr(self.txn, name)
......@@ -142,7 +140,7 @@ class LoggingTransaction(object):
# TODO(paul): Maybe use 'info' and 'debug' for values?
sql_logger.debug("[SQL] {%s} %s", self.name, sql)
sql = _convert_param_style(sql)
sql = self.database_engine.convert_param_style(sql)
try:
if args and args[0]:
......@@ -227,9 +225,14 @@ class SQLBaseStore(object):
self._get_event_cache = LruCache(hs.config.event_cache_size)
self.database_engine = hs.database_engine
# Pretend the getEventCache is just another named cache
caches_by_name["*getEvent*"] = self._get_event_cache
self._next_stream_id_lock = threading.Lock()
self._next_stream_id = int(hs.get_clock().time_msec()) * 1000
def start_profiling(self):
self._previous_loop_ts = self._clock.time_msec()
......@@ -281,7 +284,10 @@ class SQLBaseStore(object):
sql_scheduling_timer.inc_by(time.time() * 1000 - start_time)
transaction_logger.debug("[TXN START] {%s}", name)
try:
return func(LoggingTransaction(txn, name), *args, **kwargs)
return func(
LoggingTransaction(txn, name, self.database_engine),
*args, **kwargs
)
except:
logger.exception("[TXN FAIL] {%s}", name)
raise
......@@ -588,7 +594,7 @@ class SQLBaseStore(object):
select_sql = "SELECT %s FROM %s WHERE %s" % (
", ".join(retcols),
table,
" AND ".join("%s = ?" % (k) for k in keyvalues)
" AND ".join("%s = ?" % (k,) for k in keyvalues)
)
txn.execute(select_sql, keyvalues.values())
......@@ -836,6 +842,12 @@ class SQLBaseStore(object):
result = txn.fetchone()
return result[0] if result else None
def get_next_stream_id(self):
with self._next_stream_id_lock:
i = self._next_stream_id
self._next_stream_id += 1
return i
class _RollbackButIsFineException(Exception):
""" This exception is used to rollback a transaction without implying
......
# -*- coding: utf-8 -*-
# Copyright 2015 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from .maria import MariaEngine
from .sqlite3 import Sqlite3Engine
SUPPORTED_MODULE = {
"sqlite3": Sqlite3Engine,
"mysql.connector": MariaEngine,
}
def create_engine(name):
engine_class = SUPPORTED_MODULE.get(name, None)
if engine_class:
module = __import__(name)
return engine_class(module)
raise RuntimeError(
"Unsupported database engine '%s'" % (name,)
)
# -*- coding: utf-8 -*-
# Copyright 2015 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import types
class MariaEngine(object):
def __init__(self, database_module):
self.module = database_module
def convert_param_style(self, sql):
return sql.replace("?", "%s")
def encode_parameter(self, param):
if isinstance(param, types.BufferType):
return str(param)
return param
# -*- coding: utf-8 -*-
# Copyright 2015 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Sqlite3Engine(object):
def __init__(self, database_module):
self.module = database_module
def convert_param_style(self, sql):
return sql
def encode_parameter(self, param):
return param
......@@ -64,7 +64,7 @@ class KeyStore(SQLBaseStore):
"fingerprint": fingerprint,
"from_server": from_server,
"ts_added_ms": time_now_ms,
"tls_certificate": tls_certificate_bytes,
"tls_certificate": buffer(tls_certificate_bytes),
},
)
......@@ -113,6 +113,6 @@ class KeyStore(SQLBaseStore):
"key_id": "%s:%s" % (verify_key.alg, verify_key.version),
"from_server": from_server,
"ts_added_ms": time_now_ms,
"verify_key": verify_key.encode(),
"verify_key": buffer(verify_key.encode()),
},
)
......@@ -42,6 +42,7 @@ class RegistrationStore(SQLBaseStore):
yield self._simple_insert(
"access_tokens",
{
"id": self.get_next_stream_id(),
"user_id": user_id,
"token": token
},
......@@ -78,8 +79,11 @@ class RegistrationStore(SQLBaseStore):
# it's possible for this to get a conflict, but only for a single user
# since tokens are namespaced based on their user ID
txn.execute("INSERT INTO access_tokens(user_id, token) " +
"VALUES (?,?)", [user_id, token])
txn.execute(
"INSERT INTO access_tokens(id, user_id, token)"
" VALUES (?,?,?)",
(self.get_next_stream_id(), user_id, token,)
)
@defer.inlineCallbacks
def get_user_by_id(self, user_id):
......
......@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS rejections(
reason VARCHAR(255) NOT NULL,
last_check VARCHAR(255) NOT NULL,
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
-- Push notification endpoints that users have configured
CREATE TABLE IF NOT EXISTS pushers (
......@@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS pushers (
last_success BIGINT,
failing_since BIGINT,
UNIQUE (app_id, pushkey)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS push_rules (
id BIGINT PRIMARY KEY,
......@@ -48,7 +48,7 @@ CREATE TABLE IF NOT EXISTS push_rules (
conditions VARCHAR(255) NOT NULL,
actions VARCHAR(255) NOT NULL,
UNIQUE(user_name, rule_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
......@@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS user_filters(
user_id VARCHAR(255),
filter_id BIGINT,
filter_json BLOB
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS user_filters_by_user_id_filter_id ON user_filters(
user_id, filter_id
......
......@@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS application_services(
hs_token VARCHAR(255),
sender VARCHAR(255),
UNIQUE(token)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS application_services_regex(
id BIGINT PRIMARY KEY,
......@@ -28,4 +28,4 @@ CREATE TABLE IF NOT EXISTS application_services_regex(
namespace INTEGER, /* enum[room_id|room_alias|user_id] */
regex VARCHAR(255),
FOREIGN KEY(as_id) REFERENCES application_services(id)
) ENGINE = INNODB;
) ;
......@@ -4,6 +4,6 @@ CREATE TABLE IF NOT EXISTS push_rules_enable (
rule_id VARCHAR(255) NOT NULL,
enabled TINYINT,
UNIQUE(user_name, rule_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS push_rules_enable_user_name on push_rules_enable (user_name);
......@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS event_forward_extremities(
event_id VARCHAR(255) NOT NULL,
room_id VARCHAR(255) NOT NULL,
UNIQUE (event_id, room_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS ev_extrem_room ON event_forward_extremities(room_id);
CREATE INDEX IF NOT EXISTS ev_extrem_id ON event_forward_extremities(event_id);
......@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS event_backward_extremities(
event_id VARCHAR(255) NOT NULL,
room_id VARCHAR(255) NOT NULL,
UNIQUE (event_id, room_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS ev_b_extrem_room ON event_backward_extremities(room_id);
CREATE INDEX IF NOT EXISTS ev_b_extrem_id ON event_backward_extremities(event_id);
......@@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS event_edges(
room_id VARCHAR(255) NOT NULL,
is_state BOOL NOT NULL,
UNIQUE (event_id, prev_event_id, room_id, is_state)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS ev_edges_id ON event_edges(event_id);
CREATE INDEX IF NOT EXISTS ev_edges_prev_id ON event_edges(prev_event_id);
......@@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS room_depth(
room_id VARCHAR(255) NOT NULL,
min_depth INTEGER NOT NULL,
UNIQUE (room_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS room_depth_room ON room_depth(room_id);
......@@ -59,7 +59,7 @@ create TABLE IF NOT EXISTS event_destinations(
destination VARCHAR(255) NOT NULL,
delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
UNIQUE (event_id, destination)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS event_destinations_id ON event_destinations(event_id);
......@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS state_forward_extremities(
type VARCHAR(255) NOT NULL,
state_key VARCHAR(255) NOT NULL,
UNIQUE (event_id, room_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS st_extrem_keys ON state_forward_extremities(
room_id, type, state_key
......@@ -83,7 +83,7 @@ CREATE TABLE IF NOT EXISTS event_auth(
auth_id VARCHAR(255) NOT NULL,
room_id VARCHAR(255) NOT NULL,
UNIQUE (event_id, auth_id, room_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS evauth_edges_id ON event_auth(event_id);
CREATE INDEX IF NOT EXISTS evauth_edges_auth_id ON event_auth(auth_id);
......@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS event_content_hashes (
algorithm VARCHAR(255),
hash BLOB,
UNIQUE (event_id, algorithm)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS event_content_hashes_id ON event_content_hashes(event_id);
......@@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS event_reference_hashes (
algorithm VARCHAR(255),
hash BLOB,
UNIQUE (event_id, algorithm)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS event_reference_hashes_id ON event_reference_hashes(event_id);
......@@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS event_signatures (
key_id VARCHAR(255),
signature BLOB,
UNIQUE (event_id, signature_name, key_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS event_signatures_id ON event_signatures(event_id);
......@@ -50,6 +50,6 @@ CREATE TABLE IF NOT EXISTS event_edge_hashes(
algorithm VARCHAR(255),
hash BLOB,
UNIQUE (event_id, prev_event_id, algorithm)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS event_edge_hashes_id ON event_edge_hashes(event_id);
......@@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS events(
outlier BOOL NOT NULL,
depth BIGINT DEFAULT 0 NOT NULL,
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS events_stream_ordering ON events (stream_ordering);
CREATE INDEX IF NOT EXISTS events_topological_ordering ON events (topological_ordering);
......@@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS event_json(
internal_metadata BLOB NOT NULL,
json BLOB NOT NULL,
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS event_json_room_id ON event_json(room_id);
......@@ -50,7 +50,7 @@ CREATE TABLE IF NOT EXISTS state_events(
state_key VARCHAR(255) NOT NULL,
prev_state VARCHAR(255),
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS state_events_room_id ON state_events (room_id);
CREATE INDEX IF NOT EXISTS state_events_type ON state_events (type);
......@@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS current_state_events(
state_key VARCHAR(255) NOT NULL,
UNIQUE (event_id),
UNIQUE (room_id, type, state_key)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS current_state_events_room_id ON current_state_events (room_id);
CREATE INDEX IF NOT EXISTS current_state_events_type ON current_state_events (type);
......@@ -77,7 +77,7 @@ CREATE TABLE IF NOT EXISTS room_memberships(
room_id VARCHAR(255) NOT NULL,
membership VARCHAR(255) NOT NULL,
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS room_memberships_room_id ON room_memberships (room_id);
CREATE INDEX IF NOT EXISTS room_memberships_user_id ON room_memberships (user_id);
......@@ -89,14 +89,14 @@ CREATE TABLE IF NOT EXISTS feedback(
sender VARCHAR(255),
room_id VARCHAR(255),
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS topics(
event_id VARCHAR(255) NOT NULL,
room_id VARCHAR(255) NOT NULL,
topic VARCHAR(255) NOT NULL,
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS topics_room_id ON topics(room_id);
......@@ -113,12 +113,12 @@ CREATE TABLE IF NOT EXISTS rooms(
room_id VARCHAR(255) PRIMARY KEY NOT NULL,
is_public BOOL,
creator VARCHAR(255)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS room_hosts(
room_id VARCHAR(255) NOT NULL,
host VARCHAR(255) NOT NULL,
UNIQUE (room_id, host)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS room_hosts_room_id ON room_hosts (room_id);
......@@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS server_tls_certificates(
ts_added_ms BIGINT, -- When the certifcate was added.
tls_certificate BLOB, -- DER encoded x509 certificate.
UNIQUE (server_name, fingerprint)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS server_signature_keys(
server_name VARCHAR(255), -- Server name.
......@@ -28,4 +28,4 @@ CREATE TABLE IF NOT EXISTS server_signature_keys(
ts_added_ms BIGINT, -- When the key was added.
verify_key BLOB, -- NACL verification key.
UNIQUE (server_name, key_id)
) ENGINE = INNODB;
) ;
......@@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS local_media_repository (
upload_name VARCHAR(255), -- The name the media was uploaded with.
user_id VARCHAR(255), -- The user who uploaded the file.
UNIQUE (media_id)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
media_id VARCHAR(255), -- The id used to refer to the media.
......@@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
UNIQUE (
media_id, thumbnail_width, thumbnail_height, thumbnail_type
)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS local_media_repository_thumbnails_media_id
ON local_media_repository_thumbnails (media_id);
......@@ -47,7 +47,7 @@ CREATE TABLE IF NOT EXISTS remote_media_cache (
media_length INTEGER, -- Length of the media in bytes.
filesystem_id VARCHAR(255), -- The name used to store the media on disk.
UNIQUE (media_origin, media_id)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
media_origin VARCHAR(255), -- The remote HS the media came from.
......@@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
media_origin, media_id, thumbnail_width, thumbnail_height,
thumbnail_type
)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS remote_media_cache_thumbnails_media_id
ON remote_media_cache_thumbnails (media_id);
......@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS presence(
status_msg VARCHAR(255),
mtime BIGINT, -- miliseconds since last state change
UNIQUE(user_id)
) ENGINE = INNODB;
) ;
-- For each of /my/ users which possibly-remote users are allowed to see their
-- presence state
......@@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS presence_allow_inbound(
observed_user_id VARCHAR(255) NOT NULL,
observer_user_id VARCHAR(255), -- a UserID,
UNIQUE(observed_user_id)
) ENGINE = INNODB;
) ;
-- For each of /my/ users (watcher), which possibly-remote users are they
-- watching?
......@@ -35,4 +35,4 @@ CREATE TABLE IF NOT EXISTS presence_list(
observed_user_id VARCHAR(255), -- a UserID,
accepted BOOLEAN,
UNIQUE(user_id)
) ENGINE = INNODB;
) ;
......@@ -14,7 +14,7 @@
*/
CREATE TABLE IF NOT EXISTS profiles(
user_id VARCHAR(255) NOT NULL,
displayname VARBINARY(255),
displayname VARCHAR(255),
avatar_url VARCHAR(255),
UNIQUE(user_id)
) ENGINE = INNODB;
) ;
......@@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS redactions (
event_id VARCHAR(255) NOT NULL,
redacts VARCHAR(255) NOT NULL,
UNIQUE (event_id)
) ENGINE = INNODB;
) ;
CREATE INDEX IF NOT EXISTS redactions_event_id ON redactions (event_id);
CREATE INDEX IF NOT EXISTS redactions_redacts ON redactions (redacts);
......@@ -14,12 +14,12 @@
*/
CREATE TABLE IF NOT EXISTS room_aliases(
room_alias VARCHAR(255) NOT NULL,
room_alias VARBINARY(255) NOT NULL,
room_id VARCHAR(255) NOT NULL,
UNIQUE (room_alias)
) ENGINE = INNODB;
) ;
CREATE TABLE IF NOT EXISTS room_alias_servers(
room_alias VARCHAR(255) NOT NULL,
room_alias VARBINARY(255) NOT NULL,
server VARCHAR(255) NOT NULL
) ENGINE = INNODB;
) ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment