Files
romm/backend/models
Sam Dornan 2ffe41c516 test(backend): catch column nullability drift between models and migrations (#4756)
* test(backend): catch column nullability drift between models and migrations

Alembic's autogenerate ignores a nullability mismatch on a generated
column whenever the model leaves `nullable=` unset, which `Mapped[...]`
inference does. Such a mismatch surfaced in review on #4647 with no
check here able to see it.

Two guards close the gap:
- a reflection test comparing every mapped column's nullability (and
  existence) against the migrated schema, skipping views;
- a static test requiring every database-filled column to pass
  `nullable=` explicitly, so autogenerate compares it again.

The five existing `FetchedValue` columns on `roms` now declare
`nullable=True`, matching their DDL. No schema change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

* test(backend): check server_onupdate in the database-filled nullability guard

Alembic skips the nullability comparison whenever the reflected column
is generated, so a column mapped with only `server_onupdate=FetchedValue()`
is just as invisible to autogenerate as one with `server_default`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

* test(backend): trim the drift test docstrings to one sentence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:41:02 -05:00
..
2026-07-23 14:44:56 -04:00
2026-03-14 23:35:04 -04:00