summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-02-26 12:38:32 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-02-26 12:38:32 +0000
commit589903d88a0d4731ad9feef8ed318cb281b1e61d (patch)
tree06e04f27f9b4d1721102239ffd87ddbdaee65361 /synapse
parentMerge pull request #6193 from matrix-org/uhoreg/interpret_device_key_in_storage (diff)
parentMerge pull request #6185 from matrix-org/erikj/fix_censored_evnets (diff)
downloadsynapse-589903d88a0d4731ad9feef8ed318cb281b1e61d.tar.xz
Merge pull request #6185 from matrix-org/erikj/fix_censored_evnets
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres17
1 files changed, 9 insertions, 8 deletions
diff --git a/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres b/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
index 67471f3ef5..f7bcc5e2f2 100644
--- a/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
+++ b/synapse/storage/schema/delta/56/redaction_censor3_fix_update.sql.postgres
@@ -15,11 +15,12 @@
 
 
 -- There was a bug where we may have updated censored redactions as bytes,
--- which can (somehow) cause json to be inserted hex encoded. These updates go
--- and undoes any such hex encoded JSON.
-
-INSERT into background_updates (update_name, progress_json)
-  VALUES ('event_fix_redactions_bytes_create_index', '{}');
-
-INSERT into background_updates (update_name, progress_json, depends_on)
-  VALUES ('event_fix_redactions_bytes', '{}', 'event_fix_redactions_bytes_create_index');
+-- which can (somehow) cause json to be inserted hex encoded. This goes and
+-- undoes any such hex encoded JSON.
+UPDATE event_json SET json = convert_from(json::bytea, 'utf8')
+WHERE event_id IN (
+  SELECT event_json.event_id
+  FROM event_json
+  INNER JOIN redactions ON (event_json.event_id = redacts)
+  WHERE have_censored AND json NOT LIKE '{%'
+);