From 2caa02d339673d58700b7889fb30abf58b9849a3 Mon Sep 17 00:00:00 2001 From: tamassoltesz Date: Fri, 25 Oct 2024 16:55:28 +0200 Subject: [PATCH] fix: one more index plus changelog --- CHANGELOG.md | 2 ++ .../io/supertokens/inmemorydb/queries/GeneralQueries.java | 1 + .../io/supertokens/inmemorydb/queries/OAuthQueries.java | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d53d75a1..46a4d369d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ CREATE TABLE IF NOT EXISTS oauth_sessions ( ); CREATE INDEX IF NOT EXISTS oauth_session_exp_index ON oauth_sessions(exp DESC); +CREATE INDEX IF NOT EXISTS oauth_session_external_refresh_token_index ON oauth_sessions(app_id, external_refresh_token DESC); CREATE TABLE IF NOT EXISTS oauth_m2m_tokens ( app_id VARCHAR(64) DEFAULT 'public', @@ -121,6 +122,7 @@ CREATE TABLE IF NOT EXISTS oauth_sessions ( ); CREATE INDEX IF NOT EXISTS oauth_session_exp_index ON oauth_sessions(exp DESC); +CREATE INDEX IF NOT EXISTS oauth_session_external_refresh_token_index ON oauth_sessions(app_id, external_refresh_token DESC); CREATE TABLE oauth_m2m_tokens ( app_id VARCHAR(64) DEFAULT 'public', diff --git a/src/main/java/io/supertokens/inmemorydb/queries/GeneralQueries.java b/src/main/java/io/supertokens/inmemorydb/queries/GeneralQueries.java index b45792fbb..eb2fe4809 100644 --- a/src/main/java/io/supertokens/inmemorydb/queries/GeneralQueries.java +++ b/src/main/java/io/supertokens/inmemorydb/queries/GeneralQueries.java @@ -438,6 +438,7 @@ public static void createTablesIfNotExists(Start start, Main main) throws SQLExc // index update(start, OAuthQueries.getQueryToCreateOAuthSessionsExpIndex(start), NO_OP_SETTER); + update(start, OAuthQueries.getQueryToCreateOAuthSessionsExternalRefreshTokenIndex(start), NO_OP_SETTER); } if (!doesTableExists(start, Config.getConfig(start).getOAuthM2MTokensTable())) { diff --git a/src/main/java/io/supertokens/inmemorydb/queries/OAuthQueries.java b/src/main/java/io/supertokens/inmemorydb/queries/OAuthQueries.java index ede943cd2..28bef9cfd 100644 --- a/src/main/java/io/supertokens/inmemorydb/queries/OAuthQueries.java +++ b/src/main/java/io/supertokens/inmemorydb/queries/OAuthQueries.java @@ -71,6 +71,12 @@ public static String getQueryToCreateOAuthSessionsExpIndex(Start start) { + oAuth2SessionTable + "(exp DESC);"; } + public static String getQueryToCreateOAuthSessionsExternalRefreshTokenIndex(Start start) { + String oAuth2SessionTable = Config.getConfig(start).getOAuthSessionsTable(); + return "CREATE INDEX IF NOT EXISTS oauth_session_external_refresh_token_index ON " + + oAuth2SessionTable + "(app_id, external_refresh_token DESC);"; + } + public static String getQueryToCreateOAuthM2MTokensTable(Start start) { String oAuth2M2MTokensTable = Config.getConfig(start).getOAuthM2MTokensTable(); // @formatter:off