Conversation
The error we see with CVD Risks is because its introduction assumes the association which holds at the application layer also holds at the logical layer. While this assumption is intuitive, it goes against how sync was designed. The association in the logical layer is a loose association which allows for orphan associations. This allows for some late-binding after sync is completed. This is necessary because — for some reason!!! (and this is the flaw) — the ID the server should use in persisting a resource is generated on the client side. Fixes SIMPLEBACK-52
| CREATE TABLE public.cvd_risks ( | ||
| id uuid DEFAULT gen_random_uuid() NOT NULL, | ||
| risk_score character varying, | ||
| patient_id uuid NOT NULL, |
There was a problem hiding this comment.
We should just remove the constraint no? This is removing the column patient_id
There was a problem hiding this comment.
You're right. The migration only removes the constraint. But because I run a different version of PostgreSQL locally. db:migrate needs manual cleanup. I'll fix this soon
| ('20251215113615'), | ||
| ('20251219061210'), | ||
| ('20260128094448'); | ||
| ('20260105123000'), |
There was a problem hiding this comment.
This is already added in the master. Probably just a rebasing issue.
There was a problem hiding this comment.
I rebased again and this is still here. I guess if it's in master, and the PR is mergeable, it should be okay.
|
I've fixed the DB structure, @aagrawalrtsl |
|
|
||
| CREATE INDEX index_cvd_risks_on_patient_id ON public.cvd_risks USING btree (patient_id); | ||
|
|
||
|
|
There was a problem hiding this comment.
I think we can leave this index added.
thoughts ?
There was a problem hiding this comment.
Yes. Technically. But where else is the link between CVD Risks and Patients?
There was a problem hiding this comment.
We are using cvd_risks for statin reports in metabase. Having this index would affect that
There was a problem hiding this comment.
That's odd that the Rails migration took this away. Or maybe this is an effect of the state of structure.sql which causes migrations to need manual clean-ups.
|
I'll create a new PR for this. |
Story card: SIMPLEBACK-52
Because
Patients with CVD Risks cannot sync
This addresses
Removing the foreign key to allow loose association
Test instructions
n/a