Skip to content

Rename location_id on patient_locations (part 1 of 3)#6743

Open
thomasleese wants to merge 3 commits intonextfrom
rename-patient-location-location-id-1
Open

Rename location_id on patient_locations (part 1 of 3)#6743
thomasleese wants to merge 3 commits intonextfrom
rename-patient-location-location-id-1

Conversation

@thomasleese
Copy link
Copy Markdown
Contributor

@thomasleese thomasleese commented Apr 30, 2026

This is the first part of renaming the location_id column on patient_locations to school_id. To ensure a zero-downtime migration, we need to rename the column in multiple parts.

We're renaming the column to school_id as the table itself is going to be renamed to patient_schools, to better reflect the fact that this is used to model the relationship between children and their school. Although it currently, and will for now continue, to be used for clinic sessions as well, this will eventually be replaced by a different model as the relationship between children and clinics works differently.

Jira Issue - MAV-7114 · Jira Issue - MAV-7113

This adds a `school_id` column to the `patient_locations` table which
will eventually replace the `location_id` column. We're doing this
because the plan is for the patient-location association to belong an
explicit patient-school association, while the association between
patients and clinics is built using a different mechanism.

Jira-Issue: MAV-7114
Jira-Issue: MAV-7113
In the previous commit we added a `school_id` column which will
eventually replace the `location_id` column. This change ensures that
when saving or updating patient locations, we set the `school_id` column
matching the value of the `location_id` column. Once we're confident
both columns are being written to we will stop writing to `location_id`
and eventually remove it.

Jira-Issue: MAV-7114
Jira-Issue: MAV-7113
In the previous two commits we added a `school_id` column on
`patient_locations`. This commit adds a data migration to make sure it
is populated for existing rows.

Jira-Issue: MAV-7114
Jira-Issue: MAV-7113
@thomasleese thomasleese added this to the v8.5.0 milestone Apr 30, 2026
@thomasleese thomasleese added the refactor Improving maintainability label Apr 30, 2026
@thomasleese thomasleese changed the title Rename location_id on patient_locations (part 1 of 3) Rename location_id on patient_locations (part 1 of 3) Apr 30, 2026
@thomasleese thomasleese changed the title Rename location_id on patient_locations (part 1 of 3) Rename location_id on patient_locations (part 1 of 3) Apr 30, 2026
@thomasleese thomasleese marked this pull request as ready for review April 30, 2026 14:00
@thomasleese thomasleese requested a review from a team as a code owner April 30, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Improving maintainability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant