-
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
Changes from 6 commits
0807c7b
1bb7f34
36dd387
89730ac
aef51e0
691dd33
73757cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,11 +96,7 @@ public void validate( | |
// If event is newly created, or going to be deleted, capture scope | ||
// has to be checked | ||
if (program.isWithoutRegistration() || strategy.isCreate() || strategy.isDelete()) { | ||
if (organisationUnit == null) { | ||
log.warn(ORG_UNIT_NO_USER_ASSIGNED, event.getUid()); | ||
} else { | ||
checkOrgUnitInCaptureScope(reporter, event, organisationUnit, bundle.getUser()); | ||
} | ||
checkOrgUnitInCaptureScope(reporter, event, organisationUnit, bundle.getUser()); | ||
} | ||
|
||
UID teUid = getTeUidFromEvent(bundle, event, program); | ||
|
@@ -304,9 +300,7 @@ private void checkEventOrgUnitWriteAccess( | |
OrganisationUnit eventOrgUnit, | ||
boolean isCreatableInSearchScope, | ||
UserDetails user) { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. maybe I'm missing something... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole validator is quite messy and difficult to follow. |
||
? !user.isInUserEffectiveSearchOrgUnitHierarchy(eventOrgUnit.getPath()) | ||
: !user.isInUserHierarchy(eventOrgUnit.getPath())) { | ||
reporter.addError(event, ValidationCode.E1000, user, eventOrgUnit); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
DO $$ | ||
enricocolasante marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BEGIN | ||
-- Set null organisation unit of dummy enrollments to root organisation unit | ||
update enrollment en | ||
set organisationunitid = (select organisationunitid from organisationunit order by hierarchylevel limit 1) | ||
where en.organisationunitid is null | ||
and en.programid in (select programid from program where type = 'WITHOUT_REGISTRATION'); | ||
|
||
alter table if exists enrollment alter column organisationunitid set not null; | ||
|
||
alter table if exists event alter column organisationunitid set not null; | ||
|
||
EXCEPTION | ||
WHEN not_null_violation THEN | ||
RAISE EXCEPTION 'There are inconsistent data in your DB. Please check https://github.com/dhis2/dhis2-releases/blob/master/releases/2.42/migration-notes.md#null-organisation-unit to have more information on the issue and to find ways to fix it. Detailed error message: %', SQLERRM; | ||
enricocolasante marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
END; | ||
$$; |
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.