Unable to migrate dhis2 2.30 to dhis2 2.32

Hi all,
While upgrading from dhis2 2.30 to 2.32, I got bellow error message:

Blockquote
ERROR 2020-02-14 16:51:10,198 Migration of schema “public” to version 2.31.1 - Migrations for release v31 failed! Changes successfully rolled back. (Slf4jLog.java [localhost-startStop-1])

  • WARN 2020-02-14 16:51:10,203 Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.hisp.dhis.node.NodeService’: Unsatisfied dependency expressed through field ‘fieldFilterService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.hisp.dhis.fieldfilter.FieldFilterService’ defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/dhis32/WEB-INF/lib/dhis-service-node-2.32.4.jar!/META-INF/dhis/beans.xml]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.hisp.dhis.schema.SchemaService’ defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/dhis32/WEB-INF/lib/dhis-service-schema-2.32.4.jar!/META-INF/dhis/beans.xml]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.hisp.dhis.schema.PropertyIntrospectorService’: Unsatisfied dependency expressed through field ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘flyway’ defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/dhis32/WEB-INF/lib/dhis-support-db-migration-2.32.4.jar!/META-INF/dhis/beans.xml]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
    Migration V2_31_1__Migrations_for_release_v31.sql failed

SQL State : 42501
Error Code : 0
Message : ERREUR: doit être le propriétaire de la fonction generate_uid
Location : org/hisp/dhis/db/migration/2.31/V2_31_1__Migrations_for_release_v31.sql (/home/dhis/file:/home/dhis/tomcat-dhis/webapps/dhis32/WEB-INF/lib/dhis-support-db-migration-2.32.4.jar!/org/hisp/dhis/db/migration/2.31/V2_31_1__Migrations_for_release_v31.sql)
Line : 1
Statement : --Function for creating uids.
create or replace function generate_uid() returns text as
$$
declare
chars text := ‘{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}’;
result text := chars [11 + random() * (array_length(chars, 1) - 11)];
begin
for i in 1…10 loop
result := result || chars [1 + random() * (array_length(chars, 1) - 1)];
end loop;
return result;
end;
$$

Blockquote
Please can someone help me save this issue?
Thanks

1 Like

Hi @Isidoreadje,

Sorry for the delay on getting back to you on this!

I have reached out to the @dhis2-backend team and hope that they will be able to help you out very soon.

Best regards,
Karoline

Hi @Isidoreadje
The issue is that you already have a “generate_uid” function your db with a different owner than the dhis2 db user.
To fix it, simply drop that function DROP FUNCTION command and restart the application.

1 Like

Thank you @Ameen for the response

1 Like

Thank you @Karoline for your help. it was very great

1 Like