diff --git a/CHANGELOG.md b/CHANGELOG.md index 58479d46..ec788311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [5.0.4] - 2023-11-23 + +- Adds `app_id_to_user_id_primary_user_id_index` index on `app_id_to_user_id` table + +### Migration + +Run the following sql script: + +```sql +CREATE INDEX IF NOT EXISTS app_id_to_user_id_primary_user_id_index ON app_id_to_user_id (primary_or_recipe_user_id, app_id); +``` + ## [5.0.3] - 2023-11-10 - Fixes issue with email verification with user id mapping diff --git a/build.gradle b/build.gradle index 61405636..bc639aae 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java-library' } -version = "5.0.3" +version = "5.0.4" repositories { mavenCentral() diff --git a/src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java b/src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java index 976c3337..0099c2ff 100644 --- a/src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java +++ b/src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java @@ -231,6 +231,11 @@ static String getQueryToCreateAppIdIndexForAppIdToUserIdTable(Start start) { + Config.getConfig(start).getAppIdToUserIdTable() + "(app_id);"; } + static String getQueryToCreatePrimaryUserIdIndexForAppIdToUserIdTable(Start start) { + return "CREATE INDEX IF NOT EXISTS app_id_to_user_id_primary_user_id_index ON " + + Config.getConfig(start).getAppIdToUserIdTable() + "(primary_or_recipe_user_id, app_id);"; + } + public static void createTablesIfNotExists(Start start) throws SQLException, StorageQueryException { int numberOfRetries = 0; boolean retry = true; @@ -264,6 +269,7 @@ public static void createTablesIfNotExists(Start start) throws SQLException, Sto // index update(start, getQueryToCreateAppIdIndexForAppIdToUserIdTable(start), NO_OP_SETTER); + update(start, getQueryToCreatePrimaryUserIdIndexForAppIdToUserIdTable(start), NO_OP_SETTER); } if (!doesTableExists(start, Config.getConfig(start).getUsersTable())) {