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
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.
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.
Thanks @netroms this fixed my issue.
I’ll review my backup scripts
Best regards
Hi
Just a quick update on this
I did a review on backup script we’ve been using for a while, and saw that the script was excluding the following tables: analytics_* | aggregated* | completeness*
So the aggregatedataexchange was excluded because of this.
I got the backup scripts from this repo dhis2-tools dhis2-backup a while ago
Because of the issue I had, I removed aggregated* from the script, so it will be part of the backup
Now, I would like to know if there any kind of new recomendations for dhis2 database backup?
Best regards
Thanks for the follow-up information! This will probably help other community members avoid fall to the same issue.
Would you to open a new thread for this new topic question so we have a more focused discussion. Thanks!
Hi Joao. That repo you refer to has been archived. It is very old and I note that the exclusion list has a mistake (missing underscores).
If you look at this one (a little more up to date and widely used though also a bit old) you can see that it makes use of an env file which shows:
EXCLUDED=“-T aggregated_* -T analytics_* -T completeness_*”
Note the underscores
We have been working on a newer version of this which I will share here shortly.
Regards
Bob