[keycloak-dev] Database script for manual migration?

Marek Posolda mposolda at redhat.com
Tue Dec 16 10:20:46 EST 2014


For Postgresql I have those SQL commands:

alter table REALM_AUDIT_LISTENERS rename to REALM_EVENTS_LISTENERS;
alter table REALM rename column AUDIT_ENABLED to EVENTS_ENABLED;
alter table REALM rename column AUDIT_EXPIRATION to EVENTS_EXPIRATION;

Tested with PostgreSQL 9.1. Unfortunately same commands doesn't work for 
MySQL :/

Marek

On 12.12.2014 14:22, Marek Posolda wrote:
> This is related to renaming of 'audit' to 'events', which was done 
> after 1.0-beta-4 and affect db schema.
>
> I've checked that there are no more major changes to db schema and 
> these 3 commands helped to migrate my MySQL 5 from beta-4 to 1.0.4.Final:
>
> rename table REALM_AUDIT_LISTENERS to REALM_EVENTS_LISTENERS;
> alter table REALM change AUDIT_ENABLED EVENTS_ENABLED bit(1);
> alter table REALM change AUDIT_EXPIRATION EVENTS_EXPIRATION bigint(20);
>
> However not sure if same commands work for other databases.
>
> Marek
>
> On 12.12.2014 12:27, Matthias Wessendorf wrote:
>> I *think* I tracked it down to this commit:
>>
>> https://github.com/keycloak/keycloak/commit/3bfe3d256ed0c292fbb040fa2276c737c3798864
>>
>> the 'org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled' 
>> field is present in KC 1.0.Final, but not in the 1.0-beta-4.
>>
>>
>>
>>
>> On Fri, Dec 12, 2014 at 11:50 AM, Matthias Wessendorf 
>> <matzew at apache.org <mailto:matzew at apache.org>> wrote:
>>
>>     Hi Marek,
>>
>>     any chance to get a script to get that kinda migration done
>>     manually? I think this is now blocking us from upgrading to
>>     1.0.4.Final (from 1.0-beta-4, which we used in our 1.0.0.Final)
>>
>>     thanks,
>>     Matthias
>>
>>     On Fri, Dec 12, 2014 at 10:32 AM, Marek Posolda
>>     <mposolda at redhat.com <mailto:mposolda at redhat.com>> wrote:
>>
>>         Unfortunately I don't think that we have this. We have
>>         automatic migration available with liquibase, but this is
>>         from 1.0.0.Final (or newer) to 1.1.0.X .
>>
>>         Marek
>>
>>
>>         On 11.12.2014 16:50, Matthias Wessendorf wrote:
>>>         Hi,
>>>
>>>         I am wondering do you guys have a .sql script for going from
>>>         '1.0-beta-4' to '1.0.4.Final' ?
>>>
>>>         My motivation is updating the an instance of UPS 1.0.0.Final
>>>         (was using Keycloak-1.0-beta-4) to latest stable release
>>>         candidate (1.0.3-SNAPSHOT, which is using Keycloak-1.0.4.Final)
>>>
>>>         Deploying the new auth-server (that we build ourselfs), is
>>>         giving me this (with Postgres and MySQL)
>>>
>>>
>>>
>>>
>>>         13:32:29,191 ERROR [org.jboss.msc.service.fail] (MSC service
>>>         thread 1-15) MSC000001: Failed to start service
>>>         jboss.undertow.deployment.default-server.default-host./auth:
>>>         org.jboss.msc.service.StartException in service
>>>         jboss.undertow.deployment.default-server.default-host./auth:
>>>         Failed to start service
>>>         at
>>>         org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
>>>         [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
>>>         at
>>>         java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>>         [rt.jar:1.7.0_65]
>>>         at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
>>>         Caused by: java.lang.RuntimeException: Failed to construct
>>>         public
>>>         org.jboss.aerogear.unifiedpush.keycloak.UpsKeycloakApplication(javax.servlet.ServletContext,org.jboss.resteasy.core.Dispatcher)
>>>         at
>>>         org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:160)
>>>         at
>>>         org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2211)
>>>         at
>>>         org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:295)
>>>         at
>>>         org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:236)
>>>         at
>>>         org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:112)
>>>         at
>>>         org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
>>>         at
>>>         io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
>>>         at
>>>         org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79)
>>>         at
>>>         io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
>>>         at
>>>         io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220)
>>>         at
>>>         io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125)
>>>         at
>>>         io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:508)
>>>         at
>>>         org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)
>>>         at
>>>         org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
>>>         at
>>>         org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
>>>         [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
>>>         at
>>>         org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
>>>         [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
>>>         ... 3 more
>>>         Caused by: org.keycloak.models.ModelException:
>>>         javax.persistence.PersistenceException:
>>>         org.hibernate.PropertyAccessException: Null value was
>>>         assigned to a property of primitive type setter of
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>         at
>>>         org.keycloak.connections.jpa.PersistenceExceptionConverter.convert(PersistenceExceptionConverter.java:44)
>>>         at
>>>         org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:34)
>>>         at com.sun.proxy.$Proxy128.find(Unknown Source)
>>>         at
>>>         org.keycloak.models.jpa.JpaRealmProvider.getRealm(JpaRealmProvider.java:51)
>>>         at
>>>         org.keycloak.models.cache.DefaultCacheRealmProvider.getRealm(DefaultCacheRealmProvider.java:173)
>>>         at
>>>         org.keycloak.services.managers.ApplianceBootstrap.bootstrap(ApplianceBootstrap.java:42)
>>>         at
>>>         org.keycloak.services.managers.ApplianceBootstrap.bootstrap(ApplianceBootstrap.java:33)
>>>         at
>>>         org.keycloak.services.resources.KeycloakApplication.setupDefaultRealm(KeycloakApplication.java:137)
>>>         at
>>>         org.jboss.aerogear.unifiedpush.keycloak.UpsKeycloakApplication.setupDefaultRealm(UpsKeycloakApplication.java:40)
>>>         at
>>>         org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:86)
>>>         at
>>>         org.jboss.aerogear.unifiedpush.keycloak.UpsKeycloakApplication.<init>(UpsKeycloakApplication.java:35)
>>>         at
>>>         sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:148)
>>>         ... 18 more
>>>         Caused by: javax.persistence.PersistenceException:
>>>         org.hibernate.PropertyAccessException: Null value was
>>>         assigned to a property of primitive type setter of
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>         at
>>>         org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)
>>>         at
>>>         org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1694
>>>         <tel:1694>)
>>>         at
>>>         org.hibernate.jpa.spi.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:1141)
>>>         at
>>>         org.hibernate.jpa.spi.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:1068)
>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>>         Method) [rt.jar:1.7.0_65]
>>>         at
>>>         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>         [rt.jar:1.7.0_65]
>>>         at java.lang.reflect.Method.invoke(Method.java:606)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:32)
>>>         ... 32 more
>>>         Caused by: org.hibernate.PropertyAccessException: Null value
>>>         was assigned to a property of primitive type setter of
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>         at
>>>         org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:126)
>>>         at
>>>         org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:713)
>>>         at
>>>         org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:362)
>>>         at
>>>         org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:4718)
>>>         at
>>>         org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:188)
>>>         at
>>>         org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:144)
>>>         at
>>>         org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:244)
>>>         at
>>>         org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:215)
>>>         at
>>>         org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:140)
>>>         at
>>>         org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:138)
>>>         at
>>>         org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:102)
>>>         at
>>>         org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:186)
>>>         at
>>>         org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4126)
>>>         at
>>>         org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:503)
>>>         at
>>>         org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:468)
>>>         at
>>>         org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:213)
>>>         at
>>>         org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:275)
>>>         at
>>>         org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
>>>         at
>>>         org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1070)
>>>         at
>>>         org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:176)
>>>         at
>>>         org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2551)
>>>         at org.hibernate.internal.SessionImpl.get(SessionImpl.java:955)
>>>         at
>>>         org.hibernate.jpa.spi.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:1110)
>>>         ... 38 more
>>>         Caused by: java.lang.IllegalArgumentException: Can not set
>>>         boolean field
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>         to null value
>>>         at
>>>         sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
>>>         [rt.jar:1.7.0_65]
>>>         at
>>>         sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImpl.java:80)
>>>         [rt.jar:1.7.0_65]
>>>         at java.lang.reflect.Field.set(Field.java:741) [rt.jar:1.7.0_65]
>>>         at
>>>         org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:122)
>>>         ... 60 more
>>>
>>>         13:32:29,205 ERROR
>>>         [org.jboss.as.controller.management-operation] (Controller
>>>         Boot Thread) JBAS014613: Operation ("deploy") failed -
>>>         address: ([("deployment" => "auth-server.war")]) - failure
>>>         description: {"JBAS014671: Failed services" =>
>>>         {"jboss.undertow.deployment.default-server.default-host./auth"
>>>         => "org.jboss.msc.service.StartException in service
>>>         jboss.undertow.deployment.default-server.default-host./auth:
>>>         Failed to start service
>>>             Caused by: java.lang.RuntimeException: Failed to
>>>         construct public
>>>         org.jboss.aerogear.unifiedpush.keycloak.UpsKeycloakApplication(javax.servlet.ServletContext,org.jboss.resteasy.core.Dispatcher)
>>>             Caused by: org.keycloak.models.ModelException:
>>>         javax.persistence.PersistenceException:
>>>         org.hibernate.PropertyAccessException: Null value was
>>>         assigned to a property of primitive type setter of
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>             Caused by: javax.persistence.PersistenceException:
>>>         org.hibernate.PropertyAccessException: Null value was
>>>         assigned to a property of primitive type setter of
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>             Caused by: org.hibernate.PropertyAccessException: Null
>>>         value was assigned to a property of primitive type setter of
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>             Caused by: java.lang.IllegalArgumentException: Can not
>>>         set boolean field
>>>         org.keycloak.models.jpa.entities.RealmEntity.eventsEnabled
>>>         to null value"}}
>>>
>>>
>>>         Thanks,
>>>         Matthias
>>>
>>>         -- 
>>>         Matthias Wessendorf
>>>
>>>         blog: http://matthiaswessendorf.wordpress.com/
>>>         sessions: http://www.slideshare.net/mwessendorf
>>>         twitter: http://twitter.com/mwessendorf
>>>
>>>
>>>         _______________________________________________
>>>         keycloak-dev mailing list
>>>         keycloak-dev at lists.jboss.org  <mailto:keycloak-dev at lists.jboss.org>
>>>         https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>
>>
>>
>>     -- 
>>     Matthias Wessendorf
>>
>>     blog: http://matthiaswessendorf.wordpress.com/
>>     sessions: http://www.slideshare.net/mwessendorf
>>     twitter: http://twitter.com/mwessendorf
>>
>>
>>
>> -- 
>> Matthias Wessendorf
>>
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> twitter: http://twitter.com/mwessendorf
>
>
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20141216/87cc36a0/attachment-0001.html 


More information about the keycloak-dev mailing list