fix(migrations): exempt internal own-company from duplicate-name unique index (staging hotfix, PMS-413) #311
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-413-own-company-name-unique-collision"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hotfix: staging mokosh-server crash-looped immediately after the PMS-413 deploy because migration 062's backfill (create one
internalcompany per tenant, named after the tenant) violated PMS-400'sidx_companies_tenant_name_unique (tenant_id, lower(btrim(name)))on any tenant that already held a company named like the tenant. The migration aborts (fatal at boot), so the server never starts.Fix: 062 now recreates that index as a PARTIAL unique index
WHERE company_type <> 'internal'before the backfill, and the runtime duplicate-name checks increate_company/update_companyexempt internal too. The own-company is a system row exempt from the customer duplicate-name rule. Reproduced the exact unique violation locally and verified the corrected migration applies cleanly against colliding data; clippy + contacts (inclcompany_rejects_duplicate_name) + tenants integration all green.Editing migration 062 in place is safe: it failed transactionally on staging (never recorded in
_sqlx_migrations), and production ships via releases so 062 has not been applied there.#PMS-413