Designing a CRM import you can take back: batch ids, reviewed mappings and an undo that touches nothing else
Designing a CRM import you can take back: batch ids, reviewed mappings and an undo that touches nothing else
I'm the founder of Vectrox, a CRM for agencies and other firms that run on retainers. This post is about the part of a CRM that does the most damage when it goes wrong: the import.
Why migrations break
A CRM migration is rarely one clean file. It is an export from the old system, the spreadsheets sales kept on the side, the contract list finance maintains and a folder of documents. The failures are dull and expensive: a column mapped to the wrong field, dates read month-first when they were written day-first, the same client arriving more than once under slightly different names.
Rule: nothing is written until a person has seen the mapping
The importer reads CSV in any common encoding, Excel and OpenDocument workbooks, JSON and zip archives, up to 300,000 rows per file. It proposes a mapping for every column and shows it for review before any record is written. A date column whose values could be read either way is kept as typed rather than guessed.
Rule: every import is a batch with a name
Each import runs under its own batch id, and every record it creates (clients, assets, deals, contacts, documents) carries that id. Undo becomes a set operation instead of an excavation: remove what this batch created, and nothing else.
Undo is a database function, not application code walking a list. Only the workspace Owner can run it, because it can remove a very large number of records. A very large undo works through in steps; if it is interrupted by a closed tab or a lost connection, the import shows "Undo in progress" and "Continue undo" removes the rest. If people have added work to imported clients since (deals, quotes, invoices, tasks, notes), the dialog says what would go with them and asks first. Every undo is written to an audit log that no user can edit.
The trade-off we accepted: undo works per batch, not per record. Per-record undo needs a full change history for every field. Per batch covers the case that actually hurts, which is a whole import going wrong.
Contract end dates as first-class data
Most CRMs model the deal. Firms that live on retainers also need to model what happens after it: the contract, its end date and the renewal. In Vectrox an asset with an expiry date is a renewal. Contract Shield reminds the client 30 days ahead (7 for monthly terms) from the workspace's own mailbox, sends owners a digest, and a nightly job marks the assets whose date has passed. A repeating asset is rolled forward to its next date instead.
The same nightly job scores every current client for retention risk. Those figures come from a survival model in code, never from a language model, so the same data always gives the same score.
What I would do again
- Show the mapping before writing. Most of the support we never had to give started there.
- Give every import an identity. Undo by batch is easy to reason about and easy to audit.
- Keep the destructive path narrow: Owner only, resumable, logged.
You can run the importer on an invented, deliberately messy sample spreadsheet in the public demo, no account needed: https://vectrox.app/demo. How do you handle undo in your own systems: by batch, per record, or with event sourcing?