PhoenixKit.Migrations.Postgres.V124 (phoenix_kit v1.7.133)

Copy Markdown View Source

V124: Make the (name, parent_uuid) unique index on phoenix_kit_media_folders partial — restrict to non-trashed rows.

Without WHERE trashed_at IS NULL, a soft-deleted "untitled" folder in trash still reserves its slot in the index, blocking re-creation of the same name in the same parent. The trash bucket is invisible to the user, so the collision surfaces as either "Failed to create folder" (when the chosen name happens to land on a trashed sibling) or as an unhelpful jump in the auto-numbering (e.g. "untitled 3" when the user sees an empty parent). Restricting the index to active rows resolves both: trashed folders no longer reserve names, and Storage.list_folders/2 (active-only) is now an accurate predictor of what the constraint will accept.

The COALESCE(parent_uuid, '00000000-...') expression is preserved so root-level rows (NULL parent) still cluster under a single group — without it PostgreSQL's default NULLS-DISTINCT semantics would let multiple identically-named root folders coexist.

Idempotent: each step guards on prior state.

Summary

Functions

down(opts)

up(opts)