-
Type:
Task
-
Status: Done (View Workflow)
-
Priority:
Normal
-
Resolution: Done
-
Component/s: spt_operational_database
-
Labels:
-
Story Points:2
I've bumped into this a few time running alembic on the current summit opdb.
So basically, models.py declare there is a contraint between pfs_visit.pfs_visit_id and agc_exposure_visit_id.
So, that you cannot insert on a pfs_visit_id that does not exist.
This is the right thing to do but, but right now, on the current instance, there is no constraint, so agc_visit.pfs_visit_id can take whatever value, erk...
I cannot easily add the contraint because there is pfs_visit_id in agc_exposure which does not exist in pfs_visit table :
set(agc[:,1]) - set(pfs[:,0]) {0, 99999, 779594}
From what I understand, cloomis, agc_exposure does not necessarily have a valid pfs_visit, so it's set to 0 in that case, which is fine and we could add that "fake" pfs_visit_id into pfs_visit to respect the constraint. but 99999, 779594 are valid pfs_visit_id and those will eventually exist causing troubles.
Fixing the issue boils down to basically 3 things to do :
- setting pfs_visit_id to 0 where pfs_visit_id==99999 or 779594
- adding a row in pfs_visit where pfs_visit_id=0
- adding the contraint between agc_exposure.pfs_visit_id and pfs_visit.pfs_visit_id