mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Don't create event_search index on sqlite
... because the table is virtual
This commit is contained in:
parent
114f290947
commit
34194aaff7
@ -211,7 +211,8 @@ class BackgroundUpdateStore(SQLBaseStore):
|
|||||||
|
|
||||||
def register_background_index_update(self, update_name, index_name,
|
def register_background_index_update(self, update_name, index_name,
|
||||||
table, columns, where_clause=None,
|
table, columns, where_clause=None,
|
||||||
unique=False):
|
unique=False,
|
||||||
|
psql_only=False):
|
||||||
"""Helper for store classes to do a background index addition
|
"""Helper for store classes to do a background index addition
|
||||||
|
|
||||||
To use:
|
To use:
|
||||||
@ -227,6 +228,9 @@ class BackgroundUpdateStore(SQLBaseStore):
|
|||||||
index_name (str): name of index to add
|
index_name (str): name of index to add
|
||||||
table (str): table to add index to
|
table (str): table to add index to
|
||||||
columns (list[str]): columns/expressions to include in index
|
columns (list[str]): columns/expressions to include in index
|
||||||
|
unique (bool): true to make a UNIQUE index
|
||||||
|
psql_only: true to only create this index on psql databases (useful
|
||||||
|
for virtual sqlite tables)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def create_index_psql(conn):
|
def create_index_psql(conn):
|
||||||
@ -288,13 +292,16 @@ class BackgroundUpdateStore(SQLBaseStore):
|
|||||||
|
|
||||||
if isinstance(self.database_engine, engines.PostgresEngine):
|
if isinstance(self.database_engine, engines.PostgresEngine):
|
||||||
runner = create_index_psql
|
runner = create_index_psql
|
||||||
|
elif psql_only:
|
||||||
|
runner = None
|
||||||
else:
|
else:
|
||||||
runner = create_index_sqlite
|
runner = create_index_sqlite
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def updater(progress, batch_size):
|
def updater(progress, batch_size):
|
||||||
logger.info("Adding index %s to %s", index_name, table)
|
if runner is not None:
|
||||||
yield self.runWithConnection(runner)
|
logger.info("Adding index %s to %s", index_name, table)
|
||||||
|
yield self.runWithConnection(runner)
|
||||||
yield self._end_background_update(update_name)
|
yield self._end_background_update(update_name)
|
||||||
defer.returnValue(1)
|
defer.returnValue(1)
|
||||||
|
|
||||||
|
@ -216,6 +216,7 @@ class EventsStore(SQLBaseStore):
|
|||||||
table="event_search",
|
table="event_search",
|
||||||
columns=["event_id"],
|
columns=["event_id"],
|
||||||
unique=True,
|
unique=True,
|
||||||
|
psql_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._event_persist_queue = _EventPeristenceQueue()
|
self._event_persist_queue = _EventPeristenceQueue()
|
||||||
|
Loading…
Reference in New Issue
Block a user