From b4d720d6152b52417645d5a4a0e176ec3584d49c Mon Sep 17 00:00:00 2001 From: vramik Date: Tue, 14 Dec 2021 17:23:07 +0100 Subject: [PATCH] Fix DB Migration Script to 13.0.0 Closes #9138 --- .../custom/JpaUpdate13_0_0_MigrateDefaultRoles.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/JpaUpdate13_0_0_MigrateDefaultRoles.java b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/JpaUpdate13_0_0_MigrateDefaultRoles.java index 8bcec48da5..b3a1ec92c8 100644 --- a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/JpaUpdate13_0_0_MigrateDefaultRoles.java +++ b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/custom/JpaUpdate13_0_0_MigrateDefaultRoles.java @@ -48,26 +48,26 @@ public class JpaUpdate13_0_0_MigrateDefaultRoles extends CustomKeycloakTask { // create new default role new InsertStatement(null, null, database.correctObjectName("KEYCLOAK_ROLE", Table.class)) .addColumnValue("ID", id) - .addColumnValue("CLIENT_REALM_CONSTRAINT", entry.getValue()) + .addColumnValue("CLIENT_REALM_CONSTRAINT", entry.getKey()) .addColumnValue("CLIENT_ROLE", Boolean.FALSE) .addColumnValue("DESCRIPTION", "${role_" + roleName + "}") .addColumnValue("NAME", roleName) - .addColumnValue("REALM_ID", entry.getValue()) - .addColumnValue("REALM", entry.getValue()) + .addColumnValue("REALM_ID", entry.getKey()) + .addColumnValue("REALM", entry.getKey()) ); statements.add( // assign the role to the realm new UpdateStatement(null, null, database.correctObjectName("REALM", Table.class)) .addNewColumnValue("DEFAULT_ROLE", id) .setWhereClause("REALM.ID=?") - .addWhereParameter(entry.getValue()) + .addWhereParameter(entry.getKey()) ); statements.add( // copy data from REALM_DEFAULT_ROLES to COMPOSITE_ROLE new RawSqlStatement("INSERT INTO " + compositeRoleTable + " (COMPOSITE, CHILD_ROLE) " + "SELECT '" + id + "', ROLE_ID FROM " + getTableName("REALM_DEFAULT_ROLES") + - " WHERE REALM_ID = '" + database.escapeStringForDatabase(entry.getValue()) + "'") + " WHERE REALM_ID = '" + database.escapeStringForDatabase(entry.getKey()) + "'") ); statements.add( // copy data from CLIENT_DEFAULT_ROLES to COMPOSITE_ROLE @@ -75,7 +75,7 @@ public class JpaUpdate13_0_0_MigrateDefaultRoles extends CustomKeycloakTask { "SELECT '" + id + "', " + clientDefaultRolesTable + ".ROLE_ID FROM " + clientDefaultRolesTable + " INNER JOIN " + clientTable + " ON " + clientTable + ".ID = " + clientDefaultRolesTable + ".CLIENT_ID AND " + - clientTable + ".REALM_ID = '" + database.escapeStringForDatabase(entry.getValue()) + "'") + clientTable + ".REALM_ID = '" + database.escapeStringForDatabase(entry.getKey()) + "'") ); } }