Skip to content

Rename location_id on patient_locations (part 2 of 3)#6744

Open
thomasleese wants to merge 2 commits intorename-patient-location-location-id-1from
rename-patient-location-location-id-2
Open

Rename location_id on patient_locations (part 2 of 3)#6744
thomasleese wants to merge 2 commits intorename-patient-location-location-id-1from
rename-patient-location-location-id-2

Conversation

@thomasleese
Copy link
Copy Markdown
Contributor

@thomasleese thomasleese commented Apr 30, 2026

This is the second 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.

Depends on #6743

Jira Issue - MAV-7115 · Jira Issue - MAV-7113

This changes the `school_id` column on the `patient_locations` table to
ensure that it cannot be a `NULL` value, in preparation for it to
replace the `location_id` column.

At the same time, this makes the `location_id` column allowed to be
`NULL`, and removes some related indexes.

Jira-Issue: MAV-7115
Jira-Issue: MAV-7113
This stops reading from and writing to the `location_id` column on
`patient_locations` and replaces this with the `school_id` column. We're
doing this as we're renaming this column, and once we're safely no
longer using it, we can drop `location_id` from the table.

Jira-Issue: MAV-7115
Jira-Issue: MAV-7113
@thomasleese thomasleese added the refactor Improving maintainability label Apr 30, 2026
@thomasleese thomasleese added this to the v8.6.0 milestone Apr 30, 2026
@thomasleese thomasleese changed the title Rename location_id on patient_locations (part 2 of 3) Rename location_id on patient_locations (part 2 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