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

V148: CRM v2 — party roles (suppliers, clients).

One table for the `phoenix_kit_crm` plugin's commercial party typing: a
polymorphic role edge that marks an existing CRM company **or** contact as
a `supplier`, `client`, or other commercial counterparty role. This is the
Odoo `supplier_rank`/`customer_rank` / SAP Business-Partner-roles property
expressed as rows: one party can hold several roles simultaneously (a
company that is both supplier and client has two rows).

## phoenix_kit_crm_party_roles
`roleable_type` + `roleable_uuid` point at `phoenix_kit_crm_companies` or
`phoenix_kit_crm_contacts` (sole-trader suppliers are contacts). The pair
carries **no FK** — a single FK cannot express the polymorphic target;
integrity lives in the CRM changesets, mirroring the `staff_person_uuid`
soft-ref precedent in V138's `interaction_parties`.

`role` is a free string (initial vocabulary: supplier/client/partner) so
the set can grow without a migration; the CRM module validates allowed
values. `valid_from`/`valid_to` give roles a lifecycle ("former supplier")
without deleting history; `is_active` is the quick filter. `metadata`
absorbs role-scoped commercial attributes (payment terms, tax id, account
number, default currency) until they stabilize into typed columns.

Design doc: `phoenix_kit_crm` `dev_docs/design/crm_v2_parties_suppliers_clients.md`.

All operations are idempotent.

# `down`

Rolls V148 back by dropping the party-roles table.

**Lossy rollback:** all supplier/client role assignments are lost. The
underlying companies/contacts (V138) are untouched.

# `up`

---

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