PhoenixKit.Migrations.Postgres.V47 (phoenix_kit v1.7.39)

Copy Markdown View Source

V47: Shop Localized Fields

Converts Shop module from separate translations JSONB to localized fields approach.

Changes

  • Product fields (title, slug, description, body_html, seo_title, seo_description) change from VARCHAR/TEXT to JSONB maps
  • Category fields (name, slug, description) change from VARCHAR/TEXT to JSONB maps
  • Removes translations column from both tables
  • Each field stores language → value map: %{"en" => "Product", "ru" => "Продукт"}

Migration Strategy

  1. Add temporary _new columns as JSONB
  2. Migrate canonical data with default language key from settings
  3. Merge existing translations into new fields
  4. Drop old columns, rename _new to original names
  5. Create GIN indexes for slug lookups

Rollback

Extracts default language values back to string columns and rebuilds the translations map from non-default language data.

Summary

Functions

down(opts)

up(opts)