mix phoenix_kit_crm.rename_client_role (PhoenixKitCRM v0.4.0)

Copy Markdown View Source

One-time data migration for the clientcustomer party-role rename.

0.2.x granted the commercial roles supplier / client / partner. The middle one was renamed to customer in 0.4.0, but only in code — rows already written by an earlier version keep role = "client" and become unmanageable: invisible under the Customers filter, absent from the company/contact role checkboxes, and rendered as a raw grey badge. This task rewrites them.

Rows for a party that already holds customer are deleted rather than renamed (the (roleable_type, roleable_uuid, role) unique index forbids the duplicate, and the newer row wins). Everything runs in one transaction and is idempotent — a second run reports nothing to do.

Usage

mix phoenix_kit_crm.rename_client_role           # dry-run
mix phoenix_kit_crm.rename_client_role --apply   # write