# `PhoenixKit.Migrations.Postgres.V96`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/phoenix_kit/migrations/postgres/v96.ex#L1)

V96: Attach catalogue items directly to a catalogue.

Adds a nullable `catalogue_uuid` FK on `phoenix_kit_cat_items` so items
can belong to a catalogue independently of having a category. This lets
"uncategorized" items (items with no category) still be scoped to a
catalogue instead of floating in a global pool.

- Adds `catalogue_uuid` column with a FK to `phoenix_kit_cat_catalogues`
  (`on_delete: :nilify_all`) — in-app cascades handle soft-delete lifecycle
- Backfills existing items from their category's catalogue_uuid
- Pins any remaining orphans (items with no category at all) to the
  oldest non-deleted catalogue so they stay visible in the UI
- Adds indexes on `catalogue_uuid` and `(catalogue_uuid, status)`

All operations are idempotent.

# `down`

Rolls V96 back by dropping the `catalogue_uuid` column (and its indexes).

**Lossy rollback:** items that were created *after* V96 as uncategorized
(no category) have their catalogue linkage stored solely in
`catalogue_uuid`. Dropping the column means those items can no longer
be attributed to a catalogue — they'll become global orphans again
(their pre-V96 shape). Back up before rolling back in production.

# `up`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
