Error when upgrading from 2.39.8 to 2.39.9

Hi

I’m facing the attached following erron when trying to update my dhis2 instance from version 2.39.8 to 2.39.9.

My current installation is:
Postgres 14.8
Tomcat 9
Java 11

Best regards

Oops that shouldn’t happen. Did you take a backup before performing the upgrade? It could be there was some problem restoring the backup which caused this table not to be created. Short of some problem between backup and restore there isn’t really any way I can think of the table being dropped. Unless for some reason it was never created.

Can you connect to the data base and list all the tables (the \dt command) ? If you can share we could verify that it is only this table which is missing and not others.

If so it should be possible to just create that (empty) table manually. But it would be important to understand how this has happened. I am a bit concerned you might have restored off a bad backup.

1 Like

Hi @bobj
Thanks for the reply

See attached file for the output of \dt command
data-1742808755011.csv (8.1 KB)

Best regards

Hi there,

Thanks for the detailed info and screenshots!

It looks like the issue is that the aggregatedataexchange table is missing from your database after the upgrade. This table should have been created as part of the update to 2.39.

To fix this manually, you can create the missing table by running the following SQL in your database:

create table aggregatedataexchange (
    aggregatedataexchangeid int8 not null,
    uid varchar(11) null,
    code varchar(100) null,
    created timestamp null,
    userid int8 null,
    lastupdated timestamp null,
    lastupdatedby int8 null,
    translations jsonb null,
    sharing jsonb null default '{}'::jsonb,
    attributevalues jsonb null default '{}'::jsonb,
    name varchar(230) not null,
    "source" jsonb not null,
    "target" jsonb not null,
    constraint aggregatedataexchange_uid_key unique (uid),
    constraint aggregatedataexchange_code_key unique (code),
    constraint aggregatedataexchange_name_key unique (name),
    constraint aggregatedataexchange_pkey primary key (aggregatedataexchangeid)
);

-- Add foreign key constraints
alter table aggregatedataexchange add constraint fk_aggregatedataexchange_userid_userinfoid 
    foreign key (userid) references userinfo(userinfoid);

alter table aggregatedataexchange add constraint fk_aggregatedataexchange_lastupdateby_userinfoid 
    foreign key (lastupdatedby) references userinfo(userinfoid);

After creating the table, make sure to set the appropriate ownership/permissions. If you’re running this as a superuser, a simple way to assign ownership to your DHIS2 database user is:

ALTER TABLE aggregatedataexchange OWNER TO your_dhis2_db_user;

Just replace your_dhis2_db_user with the actual database user that DHIS2 is running under.

Let us know if you need help checking for any other missing tables — or if anything else looks off after the upgrade. Also, it might be worth double-checking the backup used during the upgrade to ensure it was complete.

Best regards,

Morten S.

1 Like

Thanks @netroms this fixed my issue.
I’ll review my backup scripts

Best regards