From 044e0775990c414f6b323c16433daad13899e33b Mon Sep 17 00:00:00 2001
From: Travis Ralston <travpc@gmail.com>
Date: Sat, 19 Aug 2023 20:20:14 -0600
Subject: [PATCH] Add index for datastore ID in tables

Fixes https://github.com/turt2live/matrix-media-repo/issues/439
---
 migrations/26_add_datastore_id_indexes_down.sql | 2 ++
 migrations/26_add_datastore_id_indexes_up.sql   | 2 ++
 2 files changed, 4 insertions(+)
 create mode 100644 migrations/26_add_datastore_id_indexes_down.sql
 create mode 100644 migrations/26_add_datastore_id_indexes_up.sql

diff --git a/migrations/26_add_datastore_id_indexes_down.sql b/migrations/26_add_datastore_id_indexes_down.sql
new file mode 100644
index 00000000..9f060977
--- /dev/null
+++ b/migrations/26_add_datastore_id_indexes_down.sql
@@ -0,0 +1,2 @@
+DROP INDEX IF EXISTS idx_datastore_id_thumbnails;
+DROP INDEX IF EXISTS idx_datastore_id_media;
diff --git a/migrations/26_add_datastore_id_indexes_up.sql b/migrations/26_add_datastore_id_indexes_up.sql
new file mode 100644
index 00000000..6930c6a5
--- /dev/null
+++ b/migrations/26_add_datastore_id_indexes_up.sql
@@ -0,0 +1,2 @@
+CREATE INDEX IF NOT EXISTS idx_datastore_id_thumbnails ON thumbnails(datastore_id);
+CREATE INDEX IF NOT EXISTS idx_datastore_id_media ON media(datastore_id);
-- 
GitLab