PhoenixKit.Migrations.Postgres.V92 (phoenix_kit v1.7.108)

Copy Markdown View Source

V92: Add organization accounts support and organization invitations.

User schema changes

Adds three new columns to phoenix_kit_users:

  • account_type (VARCHAR(20), NOT NULL, DEFAULT 'person') with CHECK constraint
  • organization_name (VARCHAR(255)) for organization display names
  • organization_uuid (UUID) self-referencing FK to link persons to organizations

Organization invitations table

Creates phoenix_kit_organization_invitations:

  • BYTEA token (SHA-256 hash of raw 32-byte token, unique)
  • Status CHECK constraint: pending | accepted | declined | cancelled

  • FK to phoenix_kit_users: organization_uuid (CASCADE), invited_by_uuid (SET NULL)
  • Partial unique index on (organization_uuid, email) WHERE status = 'pending'

All operations are idempotent.

Summary

Functions

down(opts)

up(opts)