Skip to content

BDMS-540: Add missing thing_id foreign key to NMA_WeatherData#468

Open
ksmuczynski wants to merge 2 commits intokas-bdms-540-standardize-PKs-FKsfrom
kas-bdms-540-NMA_WeatherData-FK-relationship
Open

BDMS-540: Add missing thing_id foreign key to NMA_WeatherData#468
ksmuczynski wants to merge 2 commits intokas-bdms-540-standardize-PKs-FKsfrom
kas-bdms-540-NMA_WeatherData-FK-relationship

Conversation

@ksmuczynski
Copy link
Contributor

@ksmuczynski ksmuczynski commented Feb 5, 2026

Why

This PR addresses the following problem / context:

  • Adds a missing, required thing_id relationship for NMA WeatherData to ensure legacy rows link to Thing records and avoid orphaned children

How

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

  • Added thing_id FK + relationship on NMA_WeatherData with validation
  • Updated WeatherData transfer to resolve thing_id by matching each row’s location to Thing.nma_pk_location, linking NMA_WeatherData → Thing and skipping rows without a match to avoid orphaned records.
  • Add alembic migration to backfill thing_id and enforce NOT NULL
  • update WeatherData legacy tests to include Thing linkage

Notes

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

…ablish relationship with Thing

- add thing_id FK + relationship on NMA_WeatherData with validation
- cache Thing.nma_pk_location and resolve thing_id in WeatherData transfer
- skip unlinked WeatherData rows to prevent orphaned children
- add alembic migration to backfill thing_id and enforce NOT NULL
- update WeatherData legacy tests to include Thing linkage
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.

1 participant