PhoenixKit.Migrations.Postgres.V103 (phoenix_kit v1.7.112)

Copy Markdown View Source

V103: Nested categories.

Adds a nullable self-referential parent_uuid column on phoenix_kit_cat_categories, turning the previously flat one-level taxonomy into an arbitrary-depth tree. Existing rows stay parent_uuid = NULL and become roots — no backfill needed.

The column is nullable (roots have no parent) with no ON DELETE cascade: parent/child linkage is managed by the context layer, which runs subtree-walking cascades inside a transaction. A DB-level cascade would bypass the soft-delete machinery and the activity log.

A plain b-tree index on (parent_uuid) covers the "list children" query used when rendering the tree. The existing index on (catalogue_uuid) still covers "list all categories in a catalogue".

Summary

Functions

Rolls V103 back by dropping the parent index and column.

Functions

down(opts)

Rolls V103 back by dropping the parent index and column.

Lossy rollback: the tree collapses — every category becomes a root and all parent linkage is lost. Back up before rolling back in production.

up(opts)