Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4cade96

Browse files
committed
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.
1 parent 0f3614f commit 4cade96

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

synapse/storage/data_stores/main/events_bg_updates.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ def __init__(self, database: Database, db_conn, hs):
9090
"event_store_labels", self._event_store_labels
9191
)
9292

93+
self.db.updates.register_background_index_update(
94+
"redactions_have_censored_idx",
95+
index_name="redactions_have_censored",
96+
table="redactions",
97+
columns=["event_id"],
98+
where_clause="NOT have_censored",
99+
)
100+
101+
self.db.updates.register_background_index_update(
102+
"redactions_have_censored_ts_idx",
103+
index_name="redactions_have_censored_ts",
104+
table="redactions",
105+
columns=["received_ts"],
106+
where_clause="NOT have_censored",
107+
)
108+
93109
@defer.inlineCallbacks
94110
def _background_reindex_fields_sender(self, progress, batch_size):
95111
target_min_stream_id = progress["target_min_stream_id_inclusive"]

synapse/storage/data_stores/main/schema/delta/56/redaction_censor.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
*/
1515

1616
ALTER TABLE redactions ADD COLUMN have_censored BOOL NOT NULL DEFAULT false;
17-
CREATE INDEX redactions_have_censored ON redactions(event_id) WHERE not have_censored;
17+
18+
INSERT INTO background_updates (update_name, progress_json) VALUES
19+
('redactions_have_censored_idx', '{}');

synapse/storage/data_stores/main/schema/delta/56/redaction_censor2.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
*/
1515

1616
ALTER TABLE redactions ADD COLUMN received_ts BIGINT;
17-
CREATE INDEX redactions_have_censored_ts ON redactions(received_ts) WHERE not have_censored;
1817

1918
INSERT INTO background_updates (update_name, progress_json) VALUES
2019
('redactions_received_ts', '{}');
20+
21+
INSERT INTO background_updates (update_name, progress_json) VALUES
22+
('redactions_have_censored_ts_idx', '{}');

0 commit comments

Comments
 (0)