PhoenixKit.Migrations.Postgres.V54 (phoenix_kit v1.7.71)

Copy Markdown View Source

V54: Category Featured Product + Import Config download_images

Categories currently have two image fields: image_id (Storage upload) and image_url (external URL fallback). This migration replaces image_url with featured_product_id — a FK to products — so the category image automatically comes from a representative product.

Also adds the missing download_images column to import_configs that was present in the Ecto schema but never added via migration.

Changes

  • Adds featured_product_id BIGINT column to categories with FK to products
  • Creates index on featured_product_id
  • Auto-populates featured_product_id for categories without image_id (picks first active product with featured_image_id)
  • Drops image_url column
  • Adds download_images BOOLEAN column to import_configs (default: false)

Image Resolution Priority (new)

  1. image_id — direct Storage upload (unchanged)
  2. featured_product_id → product's featured_image_id

Summary

Functions

down(opts)

up(opts)