Fix support for SQLite 3.7.

Partial indices support was added in 3.8.0, so we need to use the
background updates that handles this correctly.
This commit is contained in:
Erik Johnston 2019-12-09 15:09:13 +00:00
parent 0f3614f0f6
commit 4cade96616
3 changed files with 22 additions and 2 deletions

View file

@ -90,6 +90,22 @@ class EventsBackgroundUpdatesStore(SQLBaseStore):
"event_store_labels", self._event_store_labels
)
self.db.updates.register_background_index_update(
"redactions_have_censored_idx",
index_name="redactions_have_censored",
table="redactions",
columns=["event_id"],
where_clause="NOT have_censored",
)
self.db.updates.register_background_index_update(
"redactions_have_censored_ts_idx",
index_name="redactions_have_censored_ts",
table="redactions",
columns=["received_ts"],
where_clause="NOT have_censored",
)
@defer.inlineCallbacks
def _background_reindex_fields_sender(self, progress, batch_size):
target_min_stream_id = progress["target_min_stream_id_inclusive"]

View file

@ -14,4 +14,6 @@
*/
ALTER TABLE redactions ADD COLUMN have_censored BOOL NOT NULL DEFAULT false;
CREATE INDEX redactions_have_censored ON redactions(event_id) WHERE not have_censored;
INSERT INTO background_updates (update_name, progress_json) VALUES
('redactions_have_censored_idx', '{}');

View file

@ -14,7 +14,9 @@
*/
ALTER TABLE redactions ADD COLUMN received_ts BIGINT;
CREATE INDEX redactions_have_censored_ts ON redactions(received_ts) WHERE not have_censored;
INSERT INTO background_updates (update_name, progress_json) VALUES
('redactions_received_ts', '{}');
INSERT INTO background_updates (update_name, progress_json) VALUES
('redactions_have_censored_ts_idx', '{}');