CRM 0.7.0: Link CRM records to user accounts, by hand
CRM 0.7.0 connects CRM records with the site’s user accounts: a company can be linked to an organization account and a contact to a person’s account. Every link is made by hand, and when the two sides disagree you choose what to keep. The module also starts managing its own database tables.
The mirror account panel
The contact and company edit forms get a Mirror account panel. A record without an account offers Create mirror user, which makes a new account from the record, and Link existing…, which connects one that already exists. A linked record shows the account’s email, a View account link and Unlink. For companies the panel needs organization accounts to be turned on in Settings, and says so when they are off. The contact’s existing login checkbox stays as it was.
The same works from the other side. On the organizations page, an organization account without a company has Create CRM company and Link existing…, and a linked one is marked Linked.
Nothing changes on its own
The CRM never syncs in the background. The form you work from is the one that wins. A field that is blank on the other side is filled in. When the name or email differ, a Resolve differences dialog lists each field and asks which side to keep, and the differences are checked again when you press Apply, so an edit made in the meantime is not overwritten by an old choice. Both records are written together or not at all.
A company can be linked to one account only, and an account to one company.
The CRM owns its migrations
Until now PhoenixKit core created the CRM’s tables. From this release the CRM has its own migration chain. Its first step takes over the ten existing tables without changing them, and adds the one new column, the account link on companies.
Upgrading
Run mix phoenix_kit.update to apply the CRM’s migration V01. On an existing site it creates nothing new except the company account column. mix phoenix_kit.repair reports that column as an extra object at info level; it is expected, and repair leaves it in place.
Full release notes: CRM 0.7.0
0.7.0 · 14 August 2026
Added
-
Manual two-way mirror between CRM records and system users (#22). Company ↔ organization-user (via a new optional
phoenix_kit_crm_companies.user_uuid) and Contact ↔ person-user (building on the existingcontacts.user_uuid). Every direction is an explicit admin action — Create mirror, Link existing, Unlink — available from both sides, alongside the existingallow_logincheckbox rather than replacing it.Nothing is automatic: no PubSub, no background sync. The form you act from is the master, and when a mirrored field diverges a per-field conflict modal asks which side to keep instead of silently overwriting; a blank field on the target is simply filled from the master.
resolverecomputes the diff fresh at submit time, so a stale selection or an out-of-band edit cannot drive a bad write, and every write touching two records runs in one transaction.user_uuidis never cast from form params on either schema — only through a dedicatedlink_user_changeset/2, preserving the invariantContactalready had. -
The module now owns its migrations (
migration_module/0→PhoenixKitCRM.Migrations), following thephoenix_kit_legalprecedent. V01 idempotently adopts the 10phoenix_kit_crm_*tables the core chain historically created (CREATE TABLE IF NOT EXISTS, shape-identical, a no-op on existing installs) and adds the one genuinely new object:companies.user_uuid(FK →phoenix_kit_users(uuid)ON DELETE SET NULL) with a partial unique index, so any number of companies may be unlinked while a linked user maps to at most one. Version tracked by acrm_schema:1COMMENT ON TABLE;down/1never drops a table, and a committed test pins that.Note for hosts: because the column is not in core’s manifest,
mix phoenix_kit.repairreports it as an info-levelextra_object. Repair takes no action on it — it will not be dropped.
Changed
- Dependency updates:
phoenix_kit2.4.0. The~> 2.0pin is unchanged — nothing here uses core’s newSlug.put_slug/3.
CRM 0.7.0. Install or update: {:phoenix_kit_crm, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.