PhoenixKit.Migrations.Postgres.V129 (phoenix_kit v1.7.138)

Copy Markdown View Source

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_uuidsubscription_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.

Summary

Functions

down(opts)

up(opts)