-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix enrollment and event tables [DHIS2-12600] #19193
Conversation
79f093d
to
b17652f
Compare
b17652f
to
47e9a0e
Compare
@@ -133,6 +136,8 @@ private void addProgramInstance(Program program) { | |||
enrollment.setProgram(program); | |||
enrollment.setStatus(EnrollmentStatus.ACTIVE); | |||
enrollment.setStoredBy("system-process"); | |||
enrollment.setOrganisationUnit( | |||
organisationUnitService.getRootOrganisationUnits().iterator().next()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like there could be multiple root org units? I guess it still does not matter that we arbitrarily chose one of the root org unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised as well that the method is potentially returning more that one root.
In our case, it doesn't matter, we need just a value in order to make the column not null, any random value is actually fine in there.
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Outdated
Show resolved
Hide resolved
if (eventOrgUnit == null) { | ||
log.warn(ORG_UNIT_NO_USER_ASSIGNED, event.getUid()); | ||
} else if (isCreatableInSearchScope | ||
if (isCreatableInSearchScope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'm missing something...
but here we validate the user capture scope if the strategy is not an UPDATE.
since this method is only called when the strategy is not update, do we need to validate the org unit scope again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole validator is quite messy and difficult to follow.
We already have a bug to double check that everything in here is correct.
https://dhis2.atlassian.net/browse/DHIS2-17335
What is a placeholder enrollment?
Can the events have different OU? If so, what consequence can it have to pick one?
What is the root OU?
Do you mean Deleting data that is not ours always feels scary 😨 Are we certain we are not deleting anything that might still be of value? Can we move the data somewhere so it could be analyzed/recovered/made valid? If not we should at least add a big notice to the release notes with a sql query to run beforehand to retrieve the data that would be deleted. |
Yes, a placeholder enrollment is the dummy enrollment
Here we are guessing a good OU. This will come together with a big warning in the release notes, if they have a lot of enrollment/events with null OU, they should check the data beforehand and understand what they want to do with them. Our solution is a best effort solution in order to make the system consistent and remove the possibility to have inconsistent data in the DB
It is a OU with no parent, hence a OU with hierarchy level 1
Yes :)
We will have a gib warning on the release notes about it. |
If an enrollment or event doesn't have an org unit, are we currently showing it to the user? If we are not, maybe it'd be better to not update the org unit at all and keep on not showing it. Maybe move it to another table and let the implementation decide what to do with that data, something similar to what we've done with change logs. |
4f183f6
to
8b939bb
Compare
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Outdated
Show resolved
Hide resolved
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Outdated
Show resolved
Hide resolved
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Outdated
Show resolved
Hide resolved
8b939bb
to
c1b1eb8
Compare
c1b1eb8
to
89730ac
Compare
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Show resolved
Hide resolved
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Outdated
Show resolved
Hide resolved
...esources/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql
Show resolved
Hide resolved
…es/org/hisp/dhis/db/migration/2.42/V2_42_28__Make_ou_event_and_enrollment_not_null.sql Co-authored-by: teleivo <[email protected]>
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
In the DB
enrollment
andevent
tables were allowing null values fororganisationunitid
column even though the API is validating that organisation unit is not null forEnrollment
andEvent
when importing.The PR is changing the DB with a flyway migration to force
organisationunitid
column to be not null.If the migration fails, it displays a message detailing how to detect and fix the issue.
The migration notes will be published together with the release notes, a PR can be found here.
Changes needed after having an organisation unit for placeholder enrollment