Upgrading from 2.36 to 2.40 (Issue with OptionSets)

I’m having issue with OptionSet after doing dhis2 migration to version 2.40. I had a successful database restore but I get popup message Can not add a Model without id to a ModelCollection Ok whenever I click on any OptionSet.

What I have tried.

I have manually updated the sortOrder for options under each optionSet id. However when importing the metadata, the process fails with:
TypeError: Cannot read properties of undefined (reading ‘imported’)
TypeError: Cannot read properties of undefined (reading ‘imported’)
What could be the issue? Do I have to upgrade one version at a time?

Hi @salad_guyo

Welcome back to the community!

Would you please share the step by step process you are following to import the OptionSets?

Thanks!

Thanks @Gassim,
I just exported the entire metadata for my instance through import/export app. I used the default selections without unselecting anything.
I found an interesting solution shared by @stratosilva in this post

So, the solution is to edit optionvalue table to re-order sortOrder properly before exporting metadata from the source instance. You may also have to run the same query on the destination database too.

Here is the query:

postgres~# \c dhis_db
dhis_db=># UPDATE optionvalue SET sort_order = temp.orderIndex FROM ( SELECT optionvalueid, optionsetid, row_number() OVER ( PARTITION BY optionsetid ORDER BY sort_order ) AS orderIndex FROM optionvalue ) temp WHERE temp.optionvalueid = optionvalue.optionvalueid AND temp.optionsetid = optionvalue.optionsetid AND ( optionvalue.sort_order <> temp.orderIndex OR optionvalue.sort_order IS NULL );
3 Likes

Thank you for sharing the solution! :pray::pray:

1 Like