-
Notifications
You must be signed in to change notification settings - Fork 1
consolidate-backfill-transfers #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modifies the thing_id foreign key column in the ChemistrySampleInfo model to be nullable, allowing for legacy orphaned records that don't have an associated Thing entity.
Changes:
- Modified
thing_idcolumn from required to optional in theChemistrySampleInfomodel - Updated the Alembic migration to create the column as nullable instead of NOT NULL
- Updated comments to reflect the new nullable behavior for legacy orphan handling
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| db/nma_legacy.py | Changed thing_id foreign key from required to optional with updated comment |
| alembic/versions/95d8b982cd5d_add_nma_chemistry_lineage_relations.py | Updated migration to create thing_id column as nullable with clarified comment |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 158def46c5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
db/nma_legacy.py
Outdated
| # FK to Thing - nullable for legacy orphans | ||
| thing_id: Mapped[Optional[int]] = mapped_column( | ||
| Integer, ForeignKey("thing.id", ondelete="CASCADE"), nullable=True | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make ORM validation consistent with nullable thing_id
The column is now declared nullable=True, but ChemistrySampleInfo.validate_thing_id still raises when thing_id is None (see @validates("thing_id") below this block). That means any ORM-created legacy orphan (the stated motivation for this change) will still fail validation even though the DB allows it, so the backfill/ingest path that creates these rows via SQLAlchemy will still error. Consider relaxing or removing the validator when allowing nulls.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| op.add_column( | ||
| "NMA_Chemistry_SampleInfo", | ||
| sa.Column("thing_id", sa.Integer(), nullable=False), | ||
| sa.Column("thing_id", sa.Integer(), nullable=True), |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration creates thing_id as nullable, but the model in db/nma_legacy.py defines it as nullable=False. This inconsistency means existing NULL values from the migration will violate the model constraint. Either update the model to allow NULL values or add a data migration step to populate NULL values before enforcing the NOT NULL constraint.
Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
Notes
Any special considerations, workarounds, or follow-up work to note?