PhoenixKit.Migrations.Postgres.V148 (phoenix_kit v1.7.207)

Copy Markdown View Source

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.

Summary

Functions

Rolls V148 back by dropping the party-roles table.

Functions

down(opts)

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(opts)