Skip to content

chore: Separate eventid column in relationshipitem table [DHIS2-19889] #21485

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

enricocolasante
Copy link
Contributor

@enricocolasante enricocolasante commented Jul 23, 2025

This is the first of a series of PRs to prepare the tables that have a foreign key to event table for the split into trackerevent and singleevent tables.

In this PR

  • Update RelationshipItem hibernate object: split event field into singleEvent and trackerEvent fields and update XML mapping file.
  • Split eventid column in relationshipitem table with a flyway script and populate those columns with the correct data (put into singleevent column only single events and same for trackerevent column).
  • Update RelationshipItemMapper in web layer to map either a single event or a tracker event to a view event.

Next steps

  • Use SingleEvent and TrackerEvent in ProgramNotificationInstance and separate columns in programnotificationinstance table.
  • Use SingleEvent and TrackerEvent in ProgramMessage and separate columns in programmessage table.
  • Split eventchangelog table to singleeventchangelog and trackereventchangelog tables
  • Split event_notes table to singleevent_notes and trackerevent_notes tables
  • Split event table to trackerevent and singleevent and update all foreign keys and solve all added TODOs

@enricocolasante enricocolasante force-pushed the DHIS2-19889 branch 4 times, most recently from 6f6b514 to 0512ed0 Compare July 23, 2025 13:13
@enricocolasante enricocolasante marked this pull request as ready for review July 23, 2025 13:44
@enricocolasante enricocolasante requested a review from a team as a code owner July 23, 2025 13:44
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@@ -0,0 +1,24 @@
alter table if exists relationshipitem add column if not exists trackereventid bigint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can group several of these alter table commands together. Which should reduce migration time.
At the very least all add column can happen in a single DDL sql. And drop constraint in a single one and add constraints in a single one.

But I am also wondering about the migration as a whole. This leaves us in an intermediate state right? The overall migration for this initiative is going to be big. So I think we should avoid migrating to intermediate stages. We need to plan this properly.

alter table if exists relationshipitem
add constraint fk_relationshipitem_trackereventid FOREIGN KEY (trackereventid) REFERENCES event(eventid);
alter table if exists relationshipitem
add constraint fk_relationshipitem_singleeventid FOREIGN KEY (singleeventid) REFERENCES event(eventid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I said intermediate stage is because of this. This ideally should be the single event table eventually right?

Let us discuss how we should plan our migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants