summary refs log tree commit diff
path: root/synapse/storage/schema/delta/44
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-09-28 12:37:53 +0100
committerErik Johnston <erik@matrix.org>2017-09-28 12:37:53 +0100
commitae79764fe55ab15156b4f28658326bd2c9c0b937 (patch)
treeba96aced53980f87ec119722983bc5942260b5de /synapse/storage/schema/delta/44
parentMore brackets (diff)
downloadsynapse-ae79764fe55ab15156b4f28658326bd2c9c0b937.tar.xz
Change expires column to expires_ts
Diffstat (limited to 'synapse/storage/schema/delta/44')
-rw-r--r--synapse/storage/schema/delta/44/expire_url_cache.sql21
1 files changed, 20 insertions, 1 deletions
diff --git a/synapse/storage/schema/delta/44/expire_url_cache.sql b/synapse/storage/schema/delta/44/expire_url_cache.sql
index 997e790b6d..9475d53e84 100644
--- a/synapse/storage/schema/delta/44/expire_url_cache.sql
+++ b/synapse/storage/schema/delta/44/expire_url_cache.sql
@@ -14,4 +14,23 @@
  */
 
 CREATE INDEX local_media_repository_url_idx ON local_media_repository(created_ts) WHERE url_cache IS NOT NULL;
-CREATE INDEX local_media_repository_url_cache_expires_idx ON local_media_repository_url_cache((download_ts + expires));
+
+-- we need to change `expires` to `expires_ts` so that we can index on it. SQLite doesn't support
+-- indices on expressions until 3.9.
+CREATE TABLE local_media_repository_url_cache_new(
+    url TEXT,
+    response_code INTEGER,
+    etag TEXT,
+    expires_ts BIGINT,
+    og TEXT,
+    media_id TEXT,
+    download_ts BIGINT
+);
+
+INSERT INTO local_media_repository_url_cache_new
+    SELECT url, response_code, etag, expires + download_ts, og, media_id, download_ts FROM local_media_repository_url_cache;
+
+DROP TABLE local_media_repository_url_cache;
+ALTER TABLE local_media_repository_url_cache_new RENAME TO local_media_repository_url_cache;
+
+CREATE INDEX local_media_repository_url_cache_expires_idx ON local_media_repository_url_cache(expires_ts);