diff --git a/alembic/versions/95d8b982cd5d_add_nma_chemistry_lineage_relations.py b/alembic/versions/95d8b982cd5d_add_nma_chemistry_lineage_relations.py index b6b2b213f..c9f6a79e3 100644 --- a/alembic/versions/95d8b982cd5d_add_nma_chemistry_lineage_relations.py +++ b/alembic/versions/95d8b982cd5d_add_nma_chemistry_lineage_relations.py @@ -29,10 +29,10 @@ def upgrade() -> None: inspector = inspect(bind) columns = {col["name"] for col in inspector.get_columns("NMA_Chemistry_SampleInfo")} if "thing_id" not in columns: - # Add thing_id FK to NMA_Chemistry_SampleInfo (NOT NULL - no orphans) + # Add thing_id FK to NMA_Chemistry_SampleInfo (nullable to allow legacy orphans) op.add_column( "NMA_Chemistry_SampleInfo", - sa.Column("thing_id", sa.Integer(), nullable=False), + sa.Column("thing_id", sa.Integer(), nullable=True), ) existing_fks = { diff --git a/db/nma_legacy.py b/db/nma_legacy.py index 14cd9b728..053276af0 100644 --- a/db/nma_legacy.py +++ b/db/nma_legacy.py @@ -173,7 +173,7 @@ class ChemistrySampleInfo(Base): "SamplePointID", String(10), nullable=False ) - # FK to Thing - required (no orphans) + # FK to Thing - required for all ChemistrySampleInfo records thing_id: Mapped[int] = mapped_column( Integer, ForeignKey("thing.id", ondelete="CASCADE"), nullable=False )