Skip to content

Conversation

@jirhiker
Copy link
Member

Why

This PR addresses the following problem / context:

  • Use bullet points here

How

Implementation summary - the following was changed / added / removed:

  • Use bullet points here

Notes

Any special considerations, workarounds, or follow-up work to note?

  • Use bullet points here

Copilot AI review requested due to automatic review settings January 13, 2026 23:05
Copy link
Contributor

Copilot AI left a 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_id column from required to optional in the ChemistrySampleInfo model
  • 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>
Copilot AI review requested due to automatic review settings January 13, 2026 23:06
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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
Comment on lines 176 to 179
# FK to Thing - nullable for legacy orphans
thing_id: Mapped[Optional[int]] = mapped_column(
Integer, ForeignKey("thing.id", ondelete="CASCADE"), nullable=True
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Contributor

Copilot AI left a 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),
Copy link

Copilot AI Jan 13, 2026

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.

Copilot uses AI. Check for mistakes.
@jirhiker jirhiker merged commit e35bedb into staging Jan 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants