Merge duplicate client accounts safely: La Suvi + kauneussaimaa.fi (needs oma.admin_merge_clients)
Imported from GitHub issue El-SaMa/oma#239 by @El-SaMa.
Situation (checked 2026-10-15)
One client, two OMA accounts:
La Suvi ca8dab08-5ee2-4c02-87fa-f09ea86d8aca (KEEP) | "kauneussaimaa.fi" c264c4f5-aa1c-4fe8-8694-eba3b113e36a (duplicate) | |
|---|---|---|
| Origin | WHMCS import, client since 2020 | created 2026-06-29 by ferry cutover / Enhance sync |
| Service | 9d0561ce… active, Ready Legacy 7.98 €/mo, next due 2026-11-01, external_ref = "kauneussaimaa" (old cPanel username, stale) | a353e5f6… active, no billing, external_ref = live Enhance website b4e4d4da-620b-44db-bc9c-586b47365083 (laituri, customer org e2732e9d…, subscription 101); also 39140b16… terminated |
| Invoices | 60 | 0 |
| Owner | [email protected] | [email protected], her real login, which is also a member of La Suvi |
| Phone | +358452679057 | none |
oma.admin_hosting_locate kauneussaimaa.fi resolves to the duplicate. All live-site tooling (Arx, DNS health, previews) currently runs under the duplicate account.
Rows on the duplicate org: services 2, enhance_provisioned_service 1, cpanel_provisioned_service 1, memberships 1, tickets 1 (#LH-1007 "Lomalla", closed), notifications 3, arx_hardening_measures 19, arx_vulnerabilities 4, arx_site_checks 1, arx_tasks 1, site_previews 1, client_email_log 1, email_campaign_recipients 1, hosting_migration_notices 1, dns_health 1.
Traps
oma.admin_delete_clientalso deletes the owner's auth user. The duplicate's owner is her real login. Never delete the duplicate before ownership is moved, and the merge must never delete a login that is a member of another org.- Never terminate the duplicate service with
oma.admin_set_service_status. Terminate de-provisions, and it points at the live website. - The Enhance sync created the duplicate because no OMA service had the website id. Re-point La Suvi's service before removing the duplicate's, or the sync recreates it.
- Do not touch the Enhance website, subscription or customer. This is OMA data only. Subscription 101 shows plan "OMA · Autotalo mail aliases", which looks wrong for a WordPress site. Check it separately and do not change it in the merge.
Build: oma.admin_merge_clients (staff, confirm)
Input: fromOrganizationId, intoOrganizationId.
- preview (read): every table with
organization_idrows onfrom, the services on both sides, owner and members, and conflicts (two services on the same website or domain). - merge (confirm), in one transaction:
- Re-point the keep service: set
services.external_ref(andenhance_provisioned_service) of La Suvi9d0561ceto websiteb4e4d4da…, keeping its billing, plan and price. Re-point rows that reference the duplicate service id (Arx, previews, dns_health) to9d0561ce. - Move all other
organization_idrows fromfromtointo(tickets, notifications, arx_*, site_previews, logs, dns_health, notices). Skip rows that would duplicate unique keys and report them. - Retire the duplicate's OMA service rows (
a353e5f6, terminated39140b16) as records only, with no adapter or Enhance call. - Memberships: add
from's members tointo([email protected] is already a member). Ask whether she should become the La Suvi owner (operator decision). - Delete the
fromorganization row only, never auth users. - Audit-log the full move list.
- Re-point the keep service: set
- Same code from an admin button on the client page (Clients → client → Merge into…), en/fi/sv strings, handbook line in the clients/billing docs.
Verify after the merge
oma.admin_hosting_locate kauneussaimaa.fi→ org La Suvi, service9d0561ce,dnsMatchesApp: true.oma.admin_hosting_subscriptions organizationId=La Suvishows websiteb4e4d4daactive.- Arx (
oma.admin_arx) shows her site under La Suvi with its 19 hardening measures and 4 vulnerabilities intact. - The site loads (https://kauneussaimaa.fi), her mail works, and her login can open La Suvi and sees the 60 invoices.
- Wait one Enhance sync cycle: no new duplicate service or org appears.
- Tests: preview lists the rows; merge refuses when
from=into, refuses the staff org, and never calls the adapter.
Also worth a scan: other ferry-cutover duplicates (orgs created 2026-06/07 by ferry_cutover / enhance_sync that share a website or domain with a WHMCS org).