Hello Peter,
if you're already on 2.0.0 then you could do the following. ..
Download the latest keycloak-2.1.0.Final relase and extract it.
Then just run the liquibase scripts within the keycloak-model-jpa-2.1.0.Final.jar from the classpath as shown below.
This works because since version 1.9.1.Final until now (2.2.0..) the liquibase scripts
only contain declarative changes (that have no deps on Keycloak classes), however
earlier versions run custom migration code that requires a bunch of Keycloak application classes on the classpath.
So this approach (currently) works but will require additional classpath / infrastructure changes
once keycloak needs to perform some programmatic migration operations in future releases.
In my test I used a database with very little data so I'd recommend that you try this
on a database backup first :-)
The following example is based on a database created by Keycloak version 1.9.1.Final that
I want to upgrade to 2.1.0.Final.
My current directory:
tom@euler ~/dev/playgroud/keycloak/keycloak-2.1.0.Final
# Configure PG JDBC Driver jar
POSTGRES_JDBC_LIB=~/.m2/repository/org/postgresql/postgresql/9.4.1209.jre7/postgresql-9.4.1209.jre7.jar
# Keycloak Deps
KEYCLOAK_DEPS_LIB=modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.3.0.Final.jar
# Keycloak JPA Model jar contains the liquibase migration scripts
KEYCLOAK_JPA_MODEL_LIB=modules/system/layers/keycloak/org/keycloak/keycloak-model-jpa/main/keycloak-model-jpa-2.1.0.Final.jar
# Manually execute the database update
java -jar modules/system/layers/keycloak/org/liquibase/main/liquibase-core-3.4.1.jar \
--driver=org.postgresql.Driver \
--classpath="$POSTGRES_JDBC_LIB:$KEYCLOAK_DEPS_LIB:$KEYCLOAK_JPA_MODEL_LIB" \
--changeLogFile=META-INF/jpa-changelog-master.xml \
--url="jdbc:postgresql://localhost:5432/keycloak_migration_test" \
--username=keycloak \
--password=keycloak \
--logLevel=debug \
update
The migration logs were actually quite big so I pasted them here for reference:
And yes, I could successfully start Keycloak 2.1.0 on the migrated database.
With that said, I agree with you that it would be a good idea to provide a script that only performs the database
migration to ease testing of new releases.
Cheers,
Thomas