diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/jpa/QuarkusJpaConnectionProviderFactory.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/jpa/QuarkusJpaConnectionProviderFactory.java index fc887c16fa..1dd16d6a09 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/jpa/QuarkusJpaConnectionProviderFactory.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/jpa/QuarkusJpaConnectionProviderFactory.java @@ -81,7 +81,7 @@ public final class QuarkusJpaConnectionProviderFactory implements JpaConnectionP public static final String QUERY_PROPERTY_PREFIX = "kc.query."; private static final Logger logger = Logger.getLogger(QuarkusJpaConnectionProviderFactory.class); - private static final String SQL_GET_LATEST_VERSION = "SELECT VERSION FROM %sMIGRATION_MODEL"; + private static final String SQL_GET_LATEST_VERSION = "SELECT VERSION FROM %sMIGRATION_MODEL ORDER BY UPDATE_TIME DESC"; enum MigrationStrategy { UPDATE, VALIDATE, MANUAL