Migration V30: Move preferred_locale from column to custom_fields JSONB.
This migration removes the dedicated preferred_locale column and stores
the value in the existing custom_fields JSONB column instead. This reduces
schema complexity by leveraging the flexible JSONB storage for user preferences.
Changes
- Migrates existing
preferred_localevalues intocustom_fieldsJSONB - Drops the
preferred_localeindex - Drops the
preferred_localecolumn
Requirements
- PostgreSQL database
- PhoenixKit V29 or higher
- The
custom_fieldsJSONB column must exist (added in V18)
Data Migration
Existing preferred_locale values are preserved by copying them into custom_fields:
user.preferred_locale = "en-GB"becomesuser.custom_fields["preferred_locale"] = "en-GB"- NULL values are not migrated (same behavior: use system default)
Backward Compatibility
- Reading:
get_in(user.custom_fields, ["preferred_locale"])oruser.custom_fields["preferred_locale"] - Writing: Merge into custom_fields map
- NULL handling: Missing key = use system default (same as before)
Rollback
The down migration restores the column and migrates data back from custom_fields.