Expand description
SQL generator for MigrationAction::RemapEnumValues.
Integer-backed enums in vespertide are stored as plain INTEGER on
every supported backend. When the user changes a variant’s numeric
value (e.g. medium: 5 → 10), the DB does not detect the drift and
the next ORM-side deserialisation silently re-interprets every
existing row. This module emits a single atomic UPDATE ... SET col = CASE WHEN ... END WHERE col IN (...) that re-stamps affected rows
before the new ORM mapping takes effect.
The SQL is portable across PostgreSQL, MySQL and SQLite —
CASE WHEN and IN (...) are universal.
Functions§
- build_
remap_ enum_ values - Build a single atomic UPDATE that re-stamps every row whose stored
integer value is being remapped. Empty
mappingyieldsOk(vec![])so callers can blindly forward zero-change actions without special casing them.