# `PhoenixKit.Migrations.Postgres.V159`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v2.13.8/lib/phoenix_kit/migrations/postgres/v159.ex#L1)

V159: Publishing categories + post view counters
(`phoenix_kit_publishing` module).

## phoenix_kit_publishing_categories

Hierarchical, per-group taxonomy (WordPress-parity categories). The tree
is a nullable `parent_uuid` self-FK — same shape as V103's catalogue
categories; cycle/scope rules are context-layer responsibilities. `slug`
is unique per group (not globally — two groups can both have "news").
`name_i18n` carries per-language display names keyed by language code,
mirroring the group-name convention in the groups table's `data` JSONB.

Deleting a group cascades its categories; deleting a parent lifts its
children to the root (`ON DELETE SET NULL`) rather than orphaning a
subtree.

## phoenix_kit_publishing_post_categories

Post↔category assignment (M:N — WordPress semantics: taxonomy is
post-level, not per-version). Both sides cascade.

## phoenix_kit_publishing_post_views

Per-day view rollups: one `(post_uuid, view_date)` row incremented in
place. Totals are `SUM(count)`; time-series come free. Deduplication /
bot filtering happen app-side before the increment — the table stores
accepted counts only, no per-request rows and no reader PII.

All operations are idempotent.

# `down`

Rolls V159 back by dropping the categories, assignment, and view tables.

**Lossy rollback:** all categories, assignments, and view counts are
lost. Back up before rolling back in production.

# `up`

---

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