From 85574bce21c5b50c35a3b314e3676500a6f1b5b4 Mon Sep 17 00:00:00 2001 From: gnuxie Date: Mon, 14 Apr 2025 15:09:39 +0100 Subject: [PATCH] Add indexes to SqliteUserRestrictionAuditLog. Should help with isUserRestricted. Co-authored-by: Bea <20361868+enbea@users.noreply.github.com> --- .../SqliteUserRestrictionAuditLog.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/protections/HomeserverUserPolicyApplication/SqliteUserRestrictionAuditLog.ts b/src/protections/HomeserverUserPolicyApplication/SqliteUserRestrictionAuditLog.ts index 38433667..0b5b2f00 100644 --- a/src/protections/HomeserverUserPolicyApplication/SqliteUserRestrictionAuditLog.ts +++ b/src/protections/HomeserverUserPolicyApplication/SqliteUserRestrictionAuditLog.ts @@ -46,11 +46,13 @@ const SchemaText = [ created_at INTEGER DEFAULT (unixepoch()) NOT NULL, FOREIGN KEY (policy_id) REFERENCES policy_info(policy_id) ) STRICT; + CREATE INDEX idx_user_restriction ON user_restriction (target_user_id, created_at); CREATE TABLE user_unrestriction ( target_user_id TEXT NOT NULL, sender_user_id TEXT NOT NULL, created_at INTEGER DEFAULT (unixepoch()) NOT NULL - ) STRICT;`, + ) STRICT; + CREATE INDEX idx_user_unrestriction ON user_unrestriction (target_user_id, created_at);`, ]; const SchemaOptions = {