PhoenixKit.Migrations.Postgres.V105 (phoenix_kit v1.7.105)

Copy Markdown View Source

V105: CRM tables.

Two tables supporting the upcoming phoenix_kit_crm plugin:

phoenix_kit_crm_role_settings

Tracks which user roles have opted into the CRM module. One row per role; the FK cascades on role deletion so no orphan cleanup is needed.

  • role_uuid UUID PRIMARY KEY — FK → phoenix_kit_user_roles(uuid) ON DELETE CASCADE
  • enabled BOOLEAN NOT NULL DEFAULT false — opt-in flag; false by default so existing roles are unaffected until an admin explicitly enables CRM.
  • inserted_at, updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()

phoenix_kit_crm_user_role_view

Per-user, per-scope view preferences for CRM tables (column selection, ordering, active filters). One row per (user, scope) pair; scope values are strings like "role:<uuid>" or "companies".

  • uuid UUID PRIMARY KEY DEFAULT uuid_generate_v7()
  • user_uuid UUID NOT NULL — FK → phoenix_kit_users(uuid) ON DELETE CASCADE
  • scope VARCHAR(100) NOT NULL — e.g. "role:<uuid>", "companies"
  • view_config JSONB NOT NULL DEFAULT '{}' — arbitrary UI preferences blob
  • inserted_at, updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
  • UNIQUE (user_uuid, scope) — one preference row per user/scope pair
  • Index on (user_uuid) for per-user lookups

All operations are idempotent.

Summary

Functions

Rolls V105 back by dropping both CRM tables in reverse creation order.

Functions

down(opts)

Rolls V105 back by dropping both CRM tables in reverse creation order.

Lossy rollback: all role CRM opt-in settings and user view preferences are lost. Back up before rolling back in production.

up(opts)