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

V129: Add the missing `subscription_type_uuid` column to subscriptions.

`phoenix_kit_subscriptions` was created in V33 with an integer `plan_id`
(renamed to `subscription_type_id` in V65). The UUID foreign key the
`PhoenixKitBilling.Schemas.Subscription` schema actually uses —
`subscription_type_uuid` — was only ever *renamed* (V65:
`plan_uuid` → `subscription_type_uuid`), never **added**, and `plan_uuid`
never existed. So on a fresh `ensure_current/2` build the column is absent
and every subscription insert / Subscriptions LiveView query raises
`undefined_column`.

This migration adds it idempotently:

  * `subscription_type_uuid` UUID → FK
    `phoenix_kit_subscription_types(uuid) ON DELETE SET NULL`
  * a partial index for "subscriptions of type X" lookups.

Nullable + `ON DELETE SET NULL` so deleting a subscription type un-links
its subscriptions rather than cascading. Databases that already acquired
the column (via a historic `plan_uuid` rename) are untouched — every step
is guarded.

# `down`

# `up`

---

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