Migration of sessions in KC25 should run only on migration, not on imports

Closes #30351

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
Alexander Schwartz 2024-06-11 19:09:41 +02:00 committed by Alexander Schwartz
parent 8eda167312
commit a161827766

View file

@ -45,6 +45,12 @@ public class MigrateTo25_0_0 implements Migration {
@Override @Override
public void migrate(KeycloakSession session) { public void migrate(KeycloakSession session) {
// Can be null during store model tests.
if (session.sessions() != null) {
// Offer a migration for persistent user sessions which was added in KC25.
session.sessions().migrate(VERSION.toString());
}
session.realms().getRealmsStream().forEach(realm -> migrateRealm(session, realm)); session.realms().getRealmsStream().forEach(realm -> migrateRealm(session, realm));
} }
@ -66,8 +72,6 @@ public class MigrateTo25_0_0 implements Migration {
LOG.warnf("Client scope '%s' already exists in the realm '%s'. Please migrate this realm manually if you need basic claims in your tokens.", basicScope.getName(), realm.getName()); LOG.warnf("Client scope '%s' already exists in the realm '%s'. Please migrate this realm manually if you need basic claims in your tokens.", basicScope.getName(), realm.getName());
} }
// offer a migration for persistent user sessions which was added in KC25
session.sessions().migrate(VERSION.toString());
} }
} }