-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Summary
There is an unnecessary and redundant FK relationship in NMA_Radionuclides that adds confusion and risks masking the real FK path, creating confusion in ORM behavior and usage. While addressing it, we should also standardize PK/FK placement and naming in db/nma_legacy.py to reduce future mistakes.
Example of the Issue
NMA_Radionuclidesdefines a directthingrelationship that is not needed, because it already links toChemistrySampleInfo, which in turn links toThing. This creates redundant linkage and can mislead developers about the intended association path.- That same
thingrelationship is duplicated, which overrides the earlierback_populatesdefinition and can break ORM expectations. - PK/FK fields are defined in multiple positions depending on the model rather than consistently grouped, and naming varies across the file.
Tasks to resovle issue
- Remove the unnecessary
thingrelationship fromNMA_Radionuclidesand eliminate duplicate definitions. Ensure relationships use the intendedChemistrySampleInfo → Thinglinkage path. - Add a file-wide convention: under each
__tablename__, place PK/FK fields in this exact order:
# PK# FK# Legacy PK (for audit)# Legacy FK (for audit)
- Move all PK/FK fields to the top of each model, immediately under the table name.
- Ensure legacy UUID FKs are labeled and grouped under the # Legacy UUID FK section.
- Review naming consistency for model classes and relationship attributes; document exceptions when legacy table/view naming must be preserved.
Metadata
Metadata
Assignees
Labels
No labels