Modifying uids of Organisation Unit Levels in database

Hi dhis2-devs,

We are in the midst of an upgrade from DHIS v2.19 to v2.22 and have encountered the new d2 library, specifically the feature that validates the uids of objects (must be an 11-character string). The problem we’re facing is that our metadata in DHIS was initially setup using automated scripts and at that time (~2.14) the validation rules in the API around uids were possibly not as strict. As a result our Organisation Unit Levels have invalid uids because their length is not 11 characters.

We are considering a database script that updates the uids to be valid 11-character hexadecimal strings, however we’re looking to this mailing list to help point out any downstream effects. From inspection of the API responses, DB tables, DB indexes and DB foreign keys the organisation unit levels seem to be just metadata that attaches domain definitions to each level of the organisation unit hierarchy. The important attribute of Organisation Unit Levels seems to be level which is represented as an integer.

Can anybody confirm?

Thanks for your help.

Cheers,

···

-doh

Hi David,

I won’t dare to guarantee no downstream effects of doing so, but I also agree that there probably shouldn’t be any. Lars Helge Øverland is the authorative source on these types of questions, however, so I’d wait for his confirmation to proceed. In any case running with invalid UIDs cannot be guaranteed to not cause issues further down the line, so they should be changed if possible.

That said, please make yourself familiar with the formatting rules for UIDs. They are not hexadecimal strings as you indicate, but rather two character groups like so:

The first group is a single lower or upper case ascii letter (A-Za-z).

The second group is ten characters randomly chosen from the set of upper + lower case letters and numbers from 0 to 9 (A-Za-z0-9).

The UIDs must therefore match the following regex: [A-Za-z][A-Za-z0-9]{10}.

···

On Wed, Jun 1, 2016 at 5:22 PM, David Siang Fong Oh doh@thoughtworks.com wrote:

Hi dhis2-devs,

We are in the midst of an upgrade from DHIS v2.19 to v2.22 and have encountered the new d2 library, specifically the feature that validates the uids of objects (must be an 11-character string). The problem we’re facing is that our metadata in DHIS was initially setup using automated scripts and at that time (~2.14) the validation rules in the API around uids were possibly not as strict. As a result our Organisation Unit Levels have invalid uids because their length is not 11 characters.

We are considering a database script that updates the uids to be valid 11-character hexadecimal strings, however we’re looking to this mailing list to help point out any downstream effects. From inspection of the API responses, DB tables, DB indexes and DB foreign keys the organisation unit levels seem to be just metadata that attaches domain definitions to each level of the organisation unit hierarchy. The important attribute of Organisation Unit Levels seems to be level which is represented as an integer.

Can anybody confirm?

Thanks for your help.

Cheers,

-doh


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Halvdan Hoem Grelland

Software developer, DHIS 2

University of Oslo

http://www.dhis2.org

Thanks for the input Halvdan.

My mistake about the hexadecimal string. We’re aware of the correct format for UIDs; we encountered them whilst fixing the data approval workflows migration as part of the 2.19 to 2.22 upgrade. I was writing the email and happened to be looking at an object with a UID which was coincidentally also hexadecimal…

I agree that invalid UIDs could cause issues down the line (they already do in 2.22) so we’ll make sure to change them. We’ll wait to see if Lars has anything else to add.

Cheers,

···

On Thu, Jun 2, 2016 at 9:51 PM, Halvdan Hoem Grelland halvdan@dhis2.org wrote:

Hi David,

I won’t dare to guarantee no downstream effects of doing so, but I also agree that there probably shouldn’t be any. Lars Helge Øverland is the authorative source on these types of questions, however, so I’d wait for his confirmation to proceed. In any case running with invalid UIDs cannot be guaranteed to not cause issues further down the line, so they should be changed if possible.

That said, please make yourself familiar with the formatting rules for UIDs. They are not hexadecimal strings as you indicate, but rather two character groups like so:

The first group is a single lower or upper case ascii letter (A-Za-z).

The second group is ten characters randomly chosen from the set of upper + lower case letters and numbers from 0 to 9 (A-Za-z0-9).

The UIDs must therefore match the following regex: [A-Za-z][A-Za-z0-9]{10}.

-doh

On Wed, Jun 1, 2016 at 5:22 PM, David Siang Fong Oh doh@thoughtworks.com wrote:

Hi dhis2-devs,

We are in the midst of an upgrade from DHIS v2.19 to v2.22 and have encountered the new d2 library, specifically the feature that validates the uids of objects (must be an 11-character string). The problem we’re facing is that our metadata in DHIS was initially setup using automated scripts and at that time (~2.14) the validation rules in the API around uids were possibly not as strict. As a result our Organisation Unit Levels have invalid uids because their length is not 11 characters.

We are considering a database script that updates the uids to be valid 11-character hexadecimal strings, however we’re looking to this mailing list to help point out any downstream effects. From inspection of the API responses, DB tables, DB indexes and DB foreign keys the organisation unit levels seem to be just metadata that attaches domain definitions to each level of the organisation unit hierarchy. The important attribute of Organisation Unit Levels seems to be level which is represented as an integer.

Can anybody confirm?

Thanks for your help.

Cheers,

-doh


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Halvdan Hoem Grelland

Software developer, DHIS 2

University of Oslo

http://www.dhis2.org