You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migration 545a5b77e5e8 should handle missing NMA_Radionuclides.thing_id idempotently #572
The current data model correctly uses Thing -> NMA_Chemistry_SampleInfo -> NMA_Radionuclides.
Problem
alembic/versions/545a5b77e5e8_add_chemistry_backfill_columns_to_.py upgrade drops NMA_Radionuclides.thing_id and its FK as if always present, while d9f1e2c3b4a5 already drops that column. This can fail in environments with different migration history/state.
Proposed fix
Make 545a5b77e5e8 drop logic defensive (introspect columns/constraints before dropping).
Keep downgrade restoration safe (add nullable, backfill from NMA_Chemistry_SampleInfo.thing_id, then enforce NOT NULL + FK).
Add migration tests for both preconditions (thing_id present vs already absent).
Acceptance criteria
alembic upgrade head succeeds in both preconditions.
Downgrade of 545a5b77e5e8 succeeds with existing radionuclide rows.
Runtime association model remains unchanged (NMA_Radionuclides linked via chemistry_sample_info_id).
Activity
github-actions commentedon Feb 28, 2026
Linked Jira ticket created: BDMS-622